I have UniPi Axon with API EVOK. I can control this via a command line switch. Turning the thing on and off works. But getting the status is the hard part.
When calling http://192.168.1.100:8080/rest/relay/3_01
the UniPi returns a json:
{"glob_dev_id": 1, "modes": ["Simple"], "value": 1, "circuit": "3_01", "pending": false, "relay_type": "physical", "dev": "relay", "mode": "Simple"}
where the value changes from 0 to 1 when turned on.
Based on the documentation found i put this in the configurations.yaml to control the smart plug and reads its status:
switch:
- platform: command_line
switches:
unipi_switch_1:
command_on: "curl -X POST -d 'value=1' http://192.168.1.100:8080/rest/relay/3_01"
command_off: "curl -X POST -d 'value=0' http://192.168.1.100:8080/rest/relay/3_01"
command_state: "curl -X GET http://192.168.1.100:8080/rest/relay/3_01"
value_template: '{{ value_json.value == "1" }}'
But the command state doesn’t ever change the switch to on.
Because there is no error (not even in debug) I don’t know what’s going on.
Where am I going wrong?