2024年11月24日星期日 上午5:16:13

Aqara Motion Sensor last_updated(lastupdated) vs last_changed

1 年 前
#20499 引用
Aqara Motion Sensor  lastupdated

when you restart, last_changed get’s wiped and you need to wait for a new state change.

If you use an external DB - it’s much easier to create an sql server. Hidden benefit is that you can check last update even after restart of HA. This is very important for me for some kind of events like motion detection and etc.

https://community.home-assistant.io/t/create-sensor-for-showing-sensors-last-update/225761/11

https://github.com/home-assistant/core/issues/29275
0
1 年 前
#20500 引用
step 1.developer tools

http://192.168.2.50:38123/developer-tools/template

now() {{ (now())}}
states.binary_sensor.motion_sensor_4.last_changed
{{ (states.binary_sensor.motion_sensor_4.last_changed ) }}

{{ (as_timestamp(states.binary_sensor.motion_sensor_4.last_changed))  | timestamp_local }}

{{ (as_timestamp(now()) - as_timestamp(states.binary_sensor.motion_sensor_4.last_changed)) }}
{{ (as_timestamp(states.binary_sensor.motion_sensor.last_changed) - as_timestamp(states.binary_sensor.motion_sensor_4.last_changed)) }}


output

now() 2023-05-17 01:53:17.236383+08:00
states.binary_sensor.motion_sensor_4.last_changed
2023-05-16 17:53:17.214078+00:00

2023-05-17T01:53:17.214078+08:00

0.022982120513916016
-6120.911509990692
0
1 年 前
#22388 引用
hallway


{{now()}}
{{ states.binary_sensor.aqara_motion_sensor_rtcgq11lm_1_cn_version_by_homekit_contreller_in_hallway_3.last_changed}}
{{ (as_timestamp(now()) -  as_timestamp(states.binary_sensor.aqara_motion_sensor_rtcgq11lm_1_cn_version_by_homekit_contreller_in_hallway_3.last_changed)) }}
{{  (as_timestamp(now()) -  as_timestamp(states.binary_sensor.aqara_motion_sensor_rtcgq11lm_1_cn_version_by_homekit_contreller_in_hallway_3.last_changed)) < 60 }}
0
7 个月 前
#33017 引用
{{  (as_timestamp(now()) -  as_timestamp(states.binary_sensor.motion_sensor_no1_by_homekit_controller_in_living_room.last_changed)) < 60 }}



{{ now().timestamp() - states.binary_sensor.motion_sensor_no1_by_homekit_controller_in_living_room.last_changed.timestamp() < states('input_number.sensoridle') | float }}
0
4 个月 前
#42447 引用
{{now()}} 
{{ states.binary_sensor.aqara_motion_sensor_cn_version_rtcgq11lm_no3.last_changed}}
{{ states.binary_sensor.aqara_motion_sensor_cn_version_rtcgq11lm_no3.last_updated}}


output

2024-07-08 05:06:19.573365+08:00 
2024-07-07 21:05:24.840180+00:00
2024-07-07 21:05:24.840180+00:00
0