Trying to set up water flood alarm that can be reset with tap action

Hi All

I have gotten these nice simple 433 MHz water sensors, and I’m trying to have the water alert show up in a card so that I can reset it with a tap action.

So far I’ve gotten to this, the sensor:

  - platform: mqtt
    name: "Waterleak Bathroom"
    state_topic: 'tele/rfbridge/RESULT'
    value_template: >-
      {% if value_json.RfReceived.Data == '12345' %}
        {{'ON'}}
      {% elif value_json == '12345off' %}
        {{'OFF'}}
      {% else %}
        {{states('binary_sensor.waterleak_bathroom') | upper}}
      {% endif %}
    device_class: moisture 

Then the card I made:

columns: 3
entities:
  - entity: sensor.badevaerelse_temperatur
  - entity: sensor.badevaerelse_luftfugtighed
  - entity: binary_sensor.badevaerelse_bevaegelse
  - entity: light.bad_led
  - entity: binary_sensor.waterleak_bathroom
    tap_action:
      action: call-service
      service: mqtt.publish
      service_data:
        payload: '''12345off'''
        topic: tele/rfbridge/RESULT
show_name: false
show_state: true
type: glance

I can see the payload showing up with the right topic, but it doesn’t ‘hit’ it, so what did I do wrong?

too many quotes, this should work.

        payload: '12345off'

Also, your setup seems odd for the button. Does the devcie only have ‘12345off’ when it’s powered off?

It only has an ‘on’ indicator, so I’m trying to ‘fake’ an off state.

For some reason, the IF statement is not triggered
I can see 12345off in the MQTT queue, but it doesn’t trigger it?

    {% elif value_json == '12345off' %}

It’s probably because of your syntax. This would probably work

      {% if value_json.RfReceived is defined and value_json.RfReceived.Data == '12345'%}
        {{'ON'}}
      {% elif value_json == '12345off' %}
        {{'OFF'}}
      {% else %}
        {{states('binary_sensor.waterleak_bathroom') | upper}}
      {% endif %}

I don’t see what the difference is, apart from checking that the value is defined? Is that really necessary? I have quite a few sensors set up this way but they have two states of course.

Yes because if it’s not defined you’ll get an error. If you get the error, the code wont execute. I’m assuming that’s what’s happening because the first thing you hit is value_json.RfReceived.Data but it won’t be defined because value_json should be equal to ‘12345off’.