This works to send relay state 0/1 to mqtt
- id: relay1_state_to_mqtt
alias: Relay1_State_ToMqtt
initial_state: 'on'
trigger:
- platform: state
entity_id: switch.qubino_zmnhadx_flush_1_relay_switch
action:
- service: mqtt.publish
data:
topic: "service/hasszw1/device/relay_1/state"
payload_template: '{% if is_state("switch.qubino_zmnhadx_flush_1_relay_switch","on") %}1{% else %}0{% endif %}'
retain: true
but this ALWAYS publishes 1
- id: relay1_failed_to_mqtt
alias: Relay1_Failed_ToMqtt
initial_state: 'on'
trigger:
platform: state
entity_id: zwave.qubino_zmnhadx_flush_1_relay
action:
- service: mqtt.publish
data:
topic: "service/hasszw1/device/relay_1/failed"
payload_template: '{% if is_state("zwave.qubino_zmnhadx_flush_1_relay.attributes.is_failed",false) %}0{% else %}1{% endif %}'
retain: true
If I replace the payload template with
payload_template: "{{states.zwave.qubino_zmnhadx_flush_1_relay.attributes.is_failed}}"
Then I get True and False.
I’ve tried using in the line
is_state("zwave.qubino_zmnhadx_flush_1_relay.attributes.is_failed",false)
multiple values: false, False, “false”, “False”. None of it worked - the result is always 1.
I’m almost pulling my hair…
Thank you for your time!