I would really appreciate a tip from a Home Assistant expert on how to tackle the following problem:
I use several Shelly Flood devices. These WiFi-enabled devices generate an alarm in case of a water leakage.
The Shelllies are very conservative in battery usage which is, in principle, a great feature. I.e., they are generally triggered by leakage event. In addition, they connect to the WiFi and send an update about their status every couple of hours. Otherwise they are in sleep mode and thus disconnected from the WiFi.
When the sensor is disconnected from the WiFi, the sensor disappears from HA yielding an error message in the Lovelace interface that a sensor with such a name does not exist.
How can I avoid this error? For example, it is possible to store and show the sensor value until the next update?
thanks for your quick response. Currently I am not connected via MQTT since I have been playing around with the Shelly-integrated cloud features recently.
You could create a template sensor that uses the status of the original sensor to determine what it displays as the value - if the sensor status is actually working then use the actual value otherwise use the old value.
here is an example that you can modify to your needs:
thanks for the suggestion. I will try it later today.
If I understand correctly, this if statement should also work if the entity does not exist? I am asking because when the sensor is in sleep mode and thus disconnected from WiFi, HA reports âEntity is not available: shelly_floodâ.
the template as written above wonât but you can add another clause to check if the entity isnât defined which will return true if the entity doesnât exist:
{% if states.sensor.your_shelly.state is not defined or is_state('sensor.your_shelly', 'unavailable') or is_state('sensor.your_shelly', 'unknown') %}
Thanks again for all the feedback! I have adjusted and tested all suggestions and they all worked flawlessly. I have not decided yet which one I will use in the long term. This decision will most likely be made based on my future Shelly purchases.
One quick question to a related problem: I own a couple of AVM FRITZ!DECT 200 smart plugs which work fine. They comprise smart plug functionality with power monitoring and temperature sensing. The power filter attribute is called âcurrent_power_wâ as usual. Unfortunately, if the switch in the plug is turned off, this filter attribute disappears in HA yielding to an error message in a card displaying this value. Is there a trick similar to the one above posted by finity to just display the value zero when the switch is turned off?
Note: you must adjust the state-topic, i used the following command on SSH command line to get the correct values: mosquitto_sub -h 192.168.178.45 -u <user> -P <password> --insecure -t 'shellies/#' -v
Shelly is correctly reporting the values into mqtt. During the flodding, it sounds the speaker and during that time, the last of above values is correctly set o âtrueâ
The only thing i am currently still struggling around is that the Push notification is not working correctly - but i am far away from beeing an expert in automations as i did only a few so far. Hereâs my config, mybe s.o. can point me into right direction here?
- alias: "Water alarm"
trigger:
platform: state
entity_id:
- binary_sensor.watersensor1_shelly
from: 'Off'
to: 'On'
action:
service: notify.pushover
data_template:
title: "Alarm! Water Alarm!"
message: "Water detected!"
Thx @Ralf. I used your example of the binary_sensor to fix a bug in my configuration. I forgot to use the quotation marks in payload_on: "true". It worked on other sensors, but not for Shelly.
I donât know if you got your push notification working already, but I noticed capital casing in your sensor values. Maybe from: 'off' and to: 'on' fixes it? And/or leave the from out completely because youâll miss an update from status unknown to status on.
sorry for late reply.
Unfortunately i did not had time validating it. Must really do it soon.
Thanks for your note and tipps, will try it and give feedback.
Itâs hard to tell since you didnât correctly format your code by putting three back-ticks (```) on the line before and after the code block.
but it looks OK syntactically except that the âentity_id:â line needs removed because that option is deprecatated and is no longer needed.
But logically, Iâm not so sure.
I canât see how you are getting the temperature of the flood sensor.
It looks like you are just using the state of the flood sensor in the new sensor. But I would think that the state of a flood sensor would likely be âwetâ or âdryâ or something more binary.
If the state of the flood sensor actually is the temperature then Iâm not sure why you need to create a different sensor for temperature if you already have it.
You probably would need to use an attribute of the flood sensor that reports temperature instead.
But (I seem to say âbutâ a lotâŠ) I donât have your entities so I canât really say for sure.