Hello I’m new to home assistant. I have written a code in configuration.yaml to create a rest switch which hits inception board APIs and eventually changes states of devices(Here device is door). Now I want to update the switch state in Home assistant if someone manually closes/opens the door.I have inception board API which returns state of door(I get response from API is {
“State”: 2,
“Info1”: “”,
“Info2”: “”
}).If state is 2 then door is close if its 1 then door is open. Is there any way to read this response continuously and then update switch state in home assistant? Here is my code which just toggles the switch from home assistant and changes device’s state. Now all I want to do is just opposite to this.Change the state of switch in home assistant or simply toggle the switch if device’s state changed manually.
rest_command:
door1_close:
method: POST
url: "http://9528dfd63d07.ngrok.io/output"
headers:
accept: 'application/json, text/html'
content-type: application/json
payload: '{"Entity" : "2a2c03b6-48fa-493d-a3de", "OutputControlType" : "Off"}'
door1_open:
method: POST
url: "http://9528dfd63d07.ngrok.io/output"
headers:
accept: 'application/json, text/html'
content-type: application/json
payload: '{"Entity" : "2a2c03b6-48fa-493d-a3de", "OutputControlType" : "On"}'
input_boolean:
door1_state:
name: Door1 State
script:
door1_open:
sequence:
- service: rest_command.door1_open
- service: input_boolean.turn_on
entity_id: input_boolean.door1_state
door1_close:
sequence:
- service: rest_command.door1_close
- service: input_boolean.turn_off
entity_id: input_boolean.door1_state
switch:
- platform: template
switches:
door1:
value_template: "{{ is_state('input_boolean.door1_state', 'on') }}"
turn_on:
service: script.door1_open
turn_off:
service: script.door1_close