fribse
(Kenneths Teknik)
June 19, 2019, 8:25pm
1
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?
petro
(Petro)
June 21, 2019, 12:03pm
2
fribse:
payload: ‘’‘12345off’‘’
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?
fribse
(Kenneths Teknik)
June 21, 2019, 4:25pm
3
It only has an ‘on’ indicator, so I’m trying to ‘fake’ an off state.
fribse
(Kenneths Teknik)
June 23, 2019, 12:20pm
4
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' %}
petro
(Petro)
June 23, 2019, 3:17pm
5
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 %}
fribse
(Kenneths Teknik)
June 23, 2019, 7:46pm
6
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.
petro
(Petro)
June 24, 2019, 12:00am
7
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’.