of course! duh. Thank you! no querying the Zwave hub required, just subscribing to the published events…
check this:
regular mqtt sensors reading property: State
binary sensors reading the same property: State
this might even be better than the command_line version, since we can now use the Qos=1, making sure the message is red and delivered. Before, quite often the command wouldn’t stick because of several intermediate issues (timing, availability, sequence etc etc)
I am still a bit puzzled how to combine these into one template switch though, please give me a nudge:
this is the code i use now for a regular mqtt sensor:
- platform: mqtt
state_topic: 'mac_address/powerswitch-zwave/4e6eeb01/state'
name: "Tester state"
unit_of_measurement: "State"
# value_template: "{{ value | round(2) }}"
the code for the binary sensor:
- platform: mqtt
name: "Tester state bin"
state_topic: 'mac_address/powerswitch-zwave/4e6eeb01/state'
payload_on: "on"
payload_off: "off"
# availability_topic: "home-assistant/window/availability"
# payload_available: "online"
# payload_not_available: "offline"
qos: 1
device_class: plug
# value_template: '{{ value.x }}'
And the current Command_line Switch:
sw_tester_cl:
friendly_name: 7 - Tester
command_on: >-
curl -X POST -d '{"seq":1, "method":"object_prop_set", "arguments":{"oid":"4e6eeb01", "prop":"command", "value":"on"}}' http://192.168.xxx.xxx/iungo/api_request
command_off: >-
curl -X POST -d '{"seq":1, "method":"object_prop_set", "arguments":{"oid":"4e6eeb01", "prop":"command", "value":"off"}}' http://192.168.xxx.xxx/iungo/api_request# command_state: >-
command_state: >-
curl -X POST -d '{"seq":1, "method":"object_prop_get", "arguments":{"oid":"4e6eeb01", "prop":"state"}}' http://192.168.xxx.xxx/iungo/api_request
value_template: >-
{%- if value_json.rv.value == 'on' -%}
{{ true }}
{%- else -%}
{{ false }}
{%- endif -%}
trying this preliminary code for starters:
- platform: template
switches:
switch_template_tester:
friendly_name: "Tester"
value_template: "{{ is_state('binary_sensor.tester_state_bin.state', 'on') }}"
turn_on:
service: switch.turn_on
data:
entity_id: switch.sw_tester_cl
turn_off:
service: switch.turn_off
data:
entity_id: switch.sw_tester_cl
Thanks!