Hello, I have some temperature sensors at home via zigbegg connected to a hub. I have that hub in home assistant. The fact is that I receive the house temperatures perfectly in home assistant.
My problem comes from the fact that these sensors do not have a battery meter and I don’t know how to make home assistant notify me that I have not received data from them for more than 2 hours. That would help me detect a warning that it has no battery since it sends data every 5 minutes.
trigger:
- platform: state
entity_id: sensor.foo_bar
to:
for:
hours: 2
action:
...
Note: this will trigger if the sensor state stays the same value for 2 hours. So that may give you false triggers if you have a rarely changing sensor.
I have been reviewing both options you give me @_dev_null and @tom_l but I now have a sensor no batteries and it seems that it does not stay at a continuous fixed value or fixed state but rather goes to unavailable. Can I have HA alert me if a device appears as unavailable for several minutes?
Ohh, i guess you “missed” (/dev /null ) 's Solution !
== state
PS: And please Mark ( /dev /null )'s Answer as Solution, as it cover yours and +100000 other users “thoughts”
EDIT: Would also be appropriate if you would go through your other Topics, and mark those which have a “helped” you with , Marking it as Solution, This would help other who uses the Search Function, to find similar Answers/Solutions
Sorry but I didn’t understand the code, I don’t doubt that it is correct but I need some more help.
I have created this code adapted to my HA
alias: "test - Notificacion: Dispositivos sin envio de datos"
description: ""
trigger:
- alias: Comprobacion de datos Temperatura Habitacion Grande
platform: template
value_template: >-
{{ now() - states.sensor.humidity_158d000101d0d0.last_changed >= timedelta (minutes=1)
}}
id: Temperatura Habitacion Grande
- alias: Comprobacion de datos Temperatura Cochera
platform: template
value_template: >-
{{ now() - states.sensor.humidity_158d00010c37e3.last_changed >= timedelta (minutes=1)
}}
id: Temperatura Cochera
condition: []
action:
- service: notify.push_msg_javier
data:
title: "test - Notificacion: Dispositivos sin envio de datos"
message: "test - Notificacion: Dispositivos sin envio de datos"
mode: single
but I don’t quite understand this part:
- alias: Comprobacion de datos Temperatura Cochera
platform: template
value_template: >-
{{ now() - states.sensor.humidity_158d00010c37e3.last_changed >= timedelta (minutes=1)
}}
id: Temperatura Cochera
that would be::
alias: Comprobacion de datos Temperatura Cochera ------> Name you want to give?
platform: template -------------> Is it always a template?
value_template: >-
{{ now() - states.sensor.humidity_158d00010c37e3.last_changed >= timedelta (minutes=1)
}} ----------------------------> Is it only necessary to change the humidity_158d00010c37e3 value here to the appropriate one, do the states and the last_changed always exist by default in all sensors?
id: Temperatura Cochera ------> Name you want to give?
Could you please format this to something human readable ?
Alias: Name ( a reference )
Platform: No it’s only “template” when it’s the template-platform you are addressing(want to use)
Not sure what you mean ( You don’t change the sensor value in the equation/template )
You basically check “now()” whether last_change >= specified “timedelta”
(if not =false change to true when it is)
State: if it’s working( thou broken is also a state
last_changed: NO , it’s a state in the DB When i.e a sensor change State, the DB/recorder add a timestamp to the column in DB ( Called last_changed )
id: ID ( a reference )
Sometimes it receives a temperature signal, sometimes a battery signal and sometimes a humidity signal. How can I make a condition to know if in the last 4 hours I have received any data?
{# Temp Int Pasillo #}
{{
now() - states.sensor.battery_158d000110799c.last_changed >= timedelta (hours=4)
and
now() - states.sensor.humidity_158d000110799c.last_changed >= timedelta (hours=4)
and
now() - states.sensor.temperature_158d000110799c.last_changed >= timedelta (hours=4)
}}
First , you should Not put them all in same double brackets, as it result in true or false ( 1 result )
And not i.e True, False, False, or false, true, false
Use /Developer-Tools/Templates, to test and play with your templates
It works perfect for me, I think it is correct, could you show a view with this value? How would you do that? To know the last update received from a sensor?
Do you actually know what the code Does ?, and what the “output/state” of those is ?
No, but sometimes ( When the Value is actually changed )
I:E You look in your wallet, you have 10 buck: Next time you want to check(next Update) You still have 10 Buck, Nothing have change NO Last_Change before you spend a dime