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
you are right something that does not change value and receives data continuously changes only in last-updated but does not change in last_changed, right?
That’s better! thank you!
{# Trastero Temperatura #}
{{
now() - states.sensor.battery_158d0001e89657.last_updated >= timedelta (hours=4)
and
now() - states.sensor.humidity_158d0001e89657.last_updated >= timedelta (hours=4)
and
now() - states.sensor.temperature_158d0001e89657.last_updated >= timedelta (hours=4)
}}
Seriously, I know you didn’t answer my question, whether you understand/Know what the Code, you got served does, that´’s fine with me
Then i provide you Hint’s,Tips, And links To The Most Basic INFO, EXAMPLES RTFM
Stop Asking more questions in this Topic
Start Reading The Docs, or Don’t ADD Another CARD, If you Dont want to read about What you DO, Or want to Do
It’s Kind of like the “Last_Changed VS Last_Updated”
You get “Updated” with Served “Solutions” But You never Change !, Before you start To Read
the difference between Last_Changed VS Last_Updated I read it here:
about the code…
{# Trastero Temperatura #}
{{
now() - states.sensor.battery_158d0001e89657.last_updated >= timedelta (hours=4)
and
now() - states.sensor.humidity_158d0001e89657.last_updated >= timedelta (hours=4)
and
now() - states.sensor.temperature_158d0001e89657.last_updated >= timedelta (hours=4)
}}
is a TRUE or FALSE template.
That is, if any of the entities in the device has not been updated for more than 4 hours it will return a TRUE. It calculates this by taking the current time and subtracting it from the time of the last update.
There are 3 conditions joined by an AND so that if one of them is FALSE it returns FALSE.
So the entire template will only be true when all the data has not been updated for more than 4 hours.
They are sensors that must be updated several times per hour, I use this template so that HA warns me that something bad happens with any sensor.
The problem comes from the fact that I have 40 sensors in the same automation, and all of them return the same warning message. And once I get the warning on the mobile that there is a sensor that does not work, I do not know which of the 40 is. So I need to create a panel to see which of the 40 I have is the one that does not update.
that’s why I was asking if I can make a list similar to this one showing the last update time of my sensors?