I can get the status of a switch using curl
curl -X GET https://us.wio.seeed.io/v1/node/GroveRelayD1/onoff_status?access_token=xxxxxxx
This returns json of either:
{ "onoff": "0" }
or
{ "onoff": "1" }
How do I use command_state
in the command_line
switch
What I’ve tried
switch:
platform: command_line
switches:
port_1_wiolink_1_d0:
command_on: "/usr/bin/curl -X POST https://us.wio.seeed.io/v1/node/GroveRelayD0/onoff/1?access_token=xxx"
command_off: "/usr/bin/curl -X POST https://us.wio.seeed.io/v1/node/GroveRelayD0/onoff/0?access_token=xxx"
command_state: "/usr/bin/curl -X GET https://us.wio.seeed.io/v1/node/GroveRelayD0/onoff_status?access_token=xxx"
value_template: '{{ onoff == "1" }}'
Also
switch:
platform: command_line
switches:
port_1_wiolink_1_d0:
command_on: "/usr/bin/curl -X POST https://us.wio.seeed.io/v1/node/GroveRelayD0/onoff/1?access_token=xxx"
command_off: "/usr/bin/curl -X POST https://us.wio.seeed.io/v1/node/GroveRelayD0/onoff/0?access_token=xxx"
command_state: "/usr/bin/curl -X GET https://us.wio.seeed.io/v1/node/GroveRelayD0/onoff_status?access_token=xxx"
value_template: '{{ value_json.onoff == "1" }}'
Yet I find when I restart home assistant, it always shows the switches as being off.
How do I use value_template
?
How often does home assistant poll the switch to find its state?