Sensor template lock changed_by attribute not refreshing

- platform: template
  Sensors:
    1door_last_action
      Value_template: " {{ states.lock['1door'].attributes.changed_by }}"
      friendly_name: Door 1 changed by
    door2_last_action
      Value_template: " {{ states.lock.door2.attributes.changed_by }}"
      friendly_name: Door 2 changed by

Door 2 working properly. 1door not working properly.

The value template works well in template testing page however doesn’t work for sensor.

Current Hassio: 0.83 also had trouble in 0.82.1
Error in log:
Template sensor 1door_last_action has no entity ids configured to track nor were we able to extract the entities to track from the value template (s). This entity will need to be updated manually.

The problem is the automatic entity parsing won’t find the entity in the first template given the way you’re specifying it. Try this instead:

- platform: template
  Sensors:
    1door_last_action
      Value_template: " {{ state_attr('lock.1door', 'changed_by') }}"
      friendly_name: Door 1 changed by
    door2_last_action
      Value_template: " {{ state_attr('lock.door2', 'changed_by') }}"
      friendly_name: Door 2 changed by

In general it makes things more difficult if Object IDs (the second part of the Entity ID) starts with a number. You should avoid that.

1 Like

Awesome. Works now.
Thanks.