Hello, I am trying to get two rest sensors to update when flipping their light switch in home assistant. Currently the sensors do update but sometimes it will be a minute before the switch is correctly updated to the on or off position. I am hoping that I can somehow trigger the update when the switches are flipped but I am struggling to figure out how to accomplish that. I tried using a template with a service call, but I am not sure if I am doing things right. Below is what I have currently set in yaml which does update the sensor just not right away any help is appreciated!
switch:
- platform: command_line
switches:
theater_on_off:
command_on: "/usr/bin/curl -X PUT http://192.168.20.10:3000/v2/scenes/invoke?name=MovieScene_100"
command_off: "/usr/bin/curl -X PUT http://192.168.20.10:3000/v2/scenes/invoke?name=MovieScene_0"
command_state: "/usr/bin/curl -X GET http://192.168.20.10:3000/v2/devices"
value_template: >
{{ states("sensor.theater_light_status") != '0.00' }}
friendly_name: Theater
- platform: command_line
switches:
kitchen_on_off:
command_on: "/usr/bin/curl -X PUT http://192.168.20.10:3000/v2/scenes/invoke?name=KitchenScene_100"
command_off: "/usr/bin/curl -X PUT http://192.168.20.10:3000/v2/scenes/invoke?name=KitchenScene_0"
command_state: "/usr/bin/curl -X GET http://192.168.20.10:3000/v2/devices"
value_template: >
{{ states("sensor.kitchen_light_status") != '0.00' }}
friendly_name: Kitchen
sensor:
- platform: rest
resource: http://192.168.20.10:3000/v2/devices
name: Theater Light Status
value_template: '{{ value_json[0].parameters.powerinfo.measured }}'
unit_of_measurement: Watts
- platform: rest
resource: http://192.168.20.10:3000/v2/devices
name: Kitchen Light Status
value_template: '{{ value_json[1].parameters.powerinfo.measured }}'
unit_of_measurement: Watts