Xiaomi Body Sensor - "No motion since"?

Hi there,

I’m having trouble extracting a certain attribute from a sensor.
I can see the attribute “No motion since” in teh dev-tool:

.

I want to use this value (300 in the example) but can’t find the proper syntax.

{{ states.binary_sensor.motion_sensor_158d00016db13b.attributes.no_motion_since }} does nothing.

I also tried {{ states.binary_sensor.motion_sensor_158d00016db13b.attributes.last_motion }} and {{ states.binary_sensor.motion_sensor_158d00016db13b.attributes.last_trigerred }} without any luck. There are also no errors in the dev-tool.

Can anyone help me out?

1 Like

Have you tried {{ states.binary_sensor.motion_sensor_158d00016db13b.attributes.No_motion_since }}, with an uppercase N for “No_motion_since”?

Yes I did, same result (which is none)

Use {{states.binary_sensor.motion_sensor_158d00016db13b.attributes['No motion since']}}

@arsaboo that works, thanks for the prompt reply!

What does no motion since “300” mean? My one says that but I can interpret

300 seconds (so 5 minutes).

Thanks @Bob_NL

Does it max out at 300 seconds?

Is there anyway to do last motion 6:45pm Wednesday for example? That would be really nice to see!

If you want to display the last motion event date and time you could use this is your configuration.yaml:

  • platform: template
    sensors:
    last_motion:
    friendly_name: “Last motion date-time”
    value_template: >-
    {{(as_timestamp(now()) - states.binary_sensor.motion_sensor_xxxxxxxxxxx.attributes[‘No motion since’] | int) | timestamp_custom(’%Y-%m-%d %H:%M’)}}

This will take the current timestamp then substract the “No motion since” value from it and format the result to “2019-03-27 16:48” date&time format.