Help with restful like interface #890
Replies: 6 comments
-
Posted at 2016-10-17 by Ollie
[Edit] This is one, check out the And this one, which covers interactive UI, and makes ajax requests in background:- |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-17 by AaronB Thanks, I had looked at the examples and have used it previously, clearly I needed to sleep on it but I think I get it now. I could type: 192.168.0.13/set?23
to change the varible 'targetRoomTemp' to 23? Or with 192.168.0.13/set/23
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-17 by Ollie Re the first example you'd want a key in the querystring something like ?temp=23 You'd then be able to access as a.query["temp"]. In your second I can see what you want to do but syntax not quite right. You'd split to a new variable for one thing. Happy to give you the right code later - on a mobile currently- but this may help you |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-17 by Ollie Here you go. This is your path routing example.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-17 by AaronB That's great thank you. I will have a play so I understand better but I have it working! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-17 by @allObjects Take a look at apigee blog about design for getting some ideas how to handle the different aspects of identifying a resource - directly/by relationship navigation (in path) or by query (in parms) - and do an operation on them... providing and receiving data. Latter most likely makes you also have a body - url is not sufficient (and verbs and parameters are not exactly the restful way to do it). But if you want everything in the url, you will compromise... ;) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-10-17 by AaronB
Hello,
I currently have a pico running my heating through a few 5V relays. It is not quite as simple as a thermostat; It heats a store of water and uses a pump to provide hot water and heating. I would like to be able to connect to the system over wifi, gather the data and adjust variables. I may install home-assistant so I would like to emulate a rest type interface. I am testing the wifi on a ESP8266 at the moment until I buy a shim.
I have played with examples previously with control over wifi, I can turn on a pin and read variables but I don’t understand how to interrogate the url and move the information into a variable. I thought of using an if statement to check if the number is 1 and incrementing to by 1 if it’s not and rechecking but it seems a bit adhoc.
I would like to be able to type something like:
"192.168.0.13/set/room/23"
and have the 23 move to the variable for the target room temperature. I assume I would need to use the parse function? A simple example of how to achieve this would be very much appreciated.
Basic example that I have been using:
Background information about the actual system:
A thermometer switches the boiler when the store cools below a pre-set limit currently cutting in at 62 and out at 72 deg. A valve lets water from the heating circuit into the cylinder when the flow is above 45 deg and within 10 deg of the cylinder temp and the boiler is running. The water pump starts (and pumps water through a heat exchanger) when a flowmeter picks up a flow higher than 1l/min. so lots for thermometers basically.
Beta Was this translation helpful? Give feedback.
All reactions