I have no previous experience with RESTful so please excuse me if I have this all wrong.
I have an IP connected infra-red interface to my split system A/C (heat-pump).
What I would ultimately like to have is a remote control. i.e. a group with input_select and input_number items that I can use to display the current settings (as retrieved from the device) and that I can use to set a new device state by altering these inputs and sending the control string to the device when I push a button in the group (so I can change more than one item before sending).
If I send this to the interface:
http://[ip_address]/json
I get this JSON string in reply:
{“state”:”0″,”mode”:”4″,”temp”:”21″,”fan”:”176″,”aux”:”0″,”roomt”:”22.9″}
Where:
state has values 0 or 1 meaning off/on
mode has meaning
3 = Cool
4 = Heat
0 = AUTO
2 = DRY
temp shows the set temperature
fan shows the fan speed and has the following meanings:
176=Night mode
160=Auto
48=Speed 1
80=Speed 2
112=Speed 3
aux shows the aux mode i.e.
0=Normal
1=Powerful
16=Silent
roomt is the room temperature in degrees Celsius
Am I correct in defining a sensor this way?:
sensor:
- platform: rest
resource: http://[ip_address]/json
method: GET
value_template: '{ "value_jason.state" : "value_jason.mode" : "value_jason.temp" : "value_jason.fan" : "value_jason.aux" : "value_jason.roomt" }'
Form there I guess I can set slider (input_number) and input_select items to reflect these values in a group.
How is this GET command triggered?
There are other remote controls so I guess I should call this periodically whenever the ac group is visible is that possible? Or would an “update” button (script call) in the group be a better option? Or does it happen automatically (periodically) in the background?
As for controlling the device I can send:
http://[ip_address]/r?d=4&t=21&f=176&a=0&s=1
Which I gather I can do like this:
sensor:
- platform: rest
resource: http://[ip_address]/json
method: POST
payload: ‘r?d={{ value_jason.mode }}&t={{ value_jason.temp }}&f={{ value_jason.fan }}&a={{ value_jason.aux }}&s={{ value_jason.state }}'
Is that correct or should I be using a rest command?
Am I barking up the wrong tree or will this work? Is there a better way of doing it?