Notice due to lack of data

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 :wink:
  • 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 )

yes, it works for me! Thank you, only 2 parameters are required:

platform: template
value_template: >

I leave here the solution:

alias: "test - Notificacion: Dispositivos sin envio de datos 2"
description: ""
trigger:
  - platform: template
    value_template: >-
      {{ now() - states.sensor.temperature_158d0001e89657.last_changed >=
      timedelta (minutes=14) }}
  - platform: template
    value_template: >-
      {{ now() - states.sensor.temperature_158d000101d0d0.last_changed >=
      timedelta (minutes=14) }}
condition: []
action:
  - service: notify.push_msg_javier
    data:
      message: "test - Notificacion: Dispositivos sin envio de datos 2"
      title: "test - Notificacion: Dispositivos sin envio de datos 2"
mode: single

image

I have a xioami temperature sensor which has 3 entities: battery, humidity and temperature.

sensor.battery_158d000110799c
sensor.humidity_158d000110799c
sensor.temperature_158d000110799c

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?

Im not sure what you mean by

Beside This below, is Not what you asked here

To know the last update received from a sensor!, you just add last_updated … Not last_changed

What ever it is you are trying, i have very hard to understand what you actually are doing.
So please Follow my advice above

And read the DOCS about Template And Templating

Also Please open a New Topic, this is marked Solved, Yet you Keep asking New Question, Totally unrelated to This Topic

How to help us help you - or How to ask a good question.

I mean that this type of code works well:

{# Detector de Humo Cocina #}
{{
now() - states.sensor.battery_158d000130744c.last_changed >= timedelta (hours=24)
and
now() - states.binary_sensor.smoke_sensor_158d000130744c.last_changed >= timedelta (hours=24)
}}

Normally the last_changed usually coincides with the last_updated, doesn’t it?

I want to make a view with several sensors where you can see at a glance when they were last changed.

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

type: entities
entities:
  - entity: sensor.forecast_current_temperature
    secondary_info: last-updated

You REALLY should spend a little time reading the DOCS … Please ?

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)
}}



Can I make a list similar to this one showing the last update time of my sensors?

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

1 Like

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?

any help on how to display that view with the last update date?

nobody knows how to do it?

Looks like you’re using my automation that I originally posted

If you see I’m setting the trigger id and using that in the notification, enabling me to see which entity failed

1 Like

a doubt related to this, why can I use this code with some entities and not with others, that is to say:

when I apply it to the entity binary_sensor.10004998a5_9 which I check that it exists and has these fields

it gives me this error and does not let me save the automatism:

Message malformed: invalid template (TemplateSyntaxError: expected token 'end of print statement', got 'a5_9') for dictionary value @ data['action'][10]['if'][0]['conditions'][0]['value_template']

@armedad How can it be that if there is last_updated and last_changed in the developer part, I can’t use them and I get this error?

type: entities
entities:
  - entity: binary_sensor.10004998a5_9
    secondary_info: last-changed

post the whole yaml for that automation. please be sure to use proper formatting.

sorry, I had not seen your code, it is correct, it shows the entity and below it the time of the last change.

But I don’t understand why in the rest I can call “last_changed” like this:

{{states.sensor.temperature_158d0001e89657.last_updated}}

and in this one I can’t and I have to call it like this:


type: entities
entities:
  - entity: binary_sensor.10004998a5_9
    secondary_info: last-changed

Could I call it from a template and only show the time? something like this?

type: custom:mushroom-title-card
title: test
subtitle: |-
  {{states.sensor.temperature_158d0001e89657.last_updated}}

  {{states.binary_sensor.10004998a5_9.last_updated}}