Binary sensor (via ping integration) has no state object?

Hello!

I have created a binary sensor using the ping integration.

Now I would like to use the time of the last change in a template.

However, if I want to output {{ states.binary_sensor.192_168_213_156.last_changed }}, I always get the error “‘None’ has no attribute ‘last_changed’”, because {{ states.binary_sensor.192_168_213_156 }} always returns “None”.

{{ states(“binary_sensor.192_168_213_156”) }} correctly shows the current status “on”.

Why is this the case? Is there no way to get the information?

Thanks in advance,
Chris

It’s a Python thing. You should not start variables or entity/object ids with numbers. See: https://www.home-assistant.io/docs/configuration/templating/#entity_id-that-begins-with-a-number

states.binary_sensor['192_168_213_156']
1 Like

Ah, okay. Didn’t know that.

Thank you very much!