The 'entity_id' option is deprecated, please remove it from your configuration

I mentioned the deprecation of entity_id for Template Sensors in this post (~ 3 weeks ago):

It’s much more difficult to find it in the release notes for 0.115.

If entity_id contains entities you can easily identify within the actual template, you can safely remove it. However, if entity_id contains entities not listed within the template, you will have to remember why you did that because now those entities must be incorporated within the template. In this particular case, simply removing entity_id is likely to negatively affect the Template Sensor.

Ok… and what do I need to do? Just delete that line with entity_id?

You can’t just blindly remove it without first understanding why you put it there in the first place and what are the consequences of removing it now.

Worst case consequence of simply removing entity_id from a Template Sensor is:
The Template Sensor stops working.

I have the following binary sensor which indicates whether there was any motion on any of my motion sensors:

binary_sensor:
  - platform: template
    sensors:
      housewide_movement:
        friendly_name: House-wide movement
        device_class: motion
        entity_id:
          - binary_sensor.kitchen_motion
          - binary_sensor.livingroom_motion
          - binary_sensor.recroom_motion
          - binary_sensor.office_motion
          - binary_sensor.garage_motion
        value_template: >
          {% for state in states.binary_sensor
            if state.object_id.endswith('_motion')
            and (state.state == 'on')
          %}
            {% if loop.first %}
              {{ true }}
            {% endif %}
          {% endfor %}

If I have to remove the entity_id section, it’ll trigger on all binary_sensor updates instead of only the ones that matter. That’s unfortunate. I think I will have to replace this with an automation that manually updates the sensor when one of the applicable sensors is tripped.

1 Like

No, just move your list into the template or make a group using expand. Making a group is probably the easiest because your template just changes to

group:
  my_binary_sensors:
    entities:
          - binary_sensor.kitchen_motion
          - binary_sensor.livingroom_motion
          - binary_sensor.recroom_motion
          - binary_sensor.office_motion
          - binary_sensor.garage_motion
binary_sensor:
  - platform: template
    sensors:
      housewide_movement:
        friendly_name: House-wide movement
        device_class: motion
        value_template: >
          {% for state in expand('group.my_binary_sensors') 
            if state.object_id.endswith('_motion')
            and (state.state == 'on')
          %}
            {% if loop.first %}
              {{ true }}
            {% endif %}
          {% endfor %}

It’s an extremely complicated change and discussed in great detail in this thread by @123.

If I use the groiup, I can just do

{{ is_state('group.motion_sensors', 'on') }}

:slight_smile:

I kind of liked the idea of being able to use an entity’s state in a template sensor, but not have it necessarily cause the state of the sensor to update. Like, I might want to use the value of sensor.time in a template sensor, but not necessarily have it update every minute.

Oh well, can’t please everybody. I’m probably an edge case.

1 Like

I put it there because that’s what all the examples in the documentation said to do.

I guess it comes back to my initial question, which is how would I know which seven entity_ids failed? If the warning messages told me that, I could start to answer those other questions.

In the end, I think I found seven templates which didn’t seem to need an entity_id, and everything seems to be OK after commenting them out. At least, no more warnings in the log. But I don’t really feel like I’ve learned anything, and I can’t help but wonder whether the other ten entity_id lines in my configuration.yaml are going to cause a future problem.

The warning is telling you that the field is deprecated, not that the sensors failed. The field is not being used currently. So you can tell that the sensors ‘failed’ if they aren’t updating properly.

Are those 10 other entity_id fields in template sensors of any kind? If yes, then they should be removed when prompted.

My post was in reply to sender’s question:

If whatever you removed had sensor.time or sensor.date (or similar) in it, that Template Sensor is probably no longer being updated periodically.

So I have it in an automation…

How do I get rid of it?

- id: brightness
  alias: 'Brightness'
  trigger:
    platform: state
    entity_id: input_number.brightness
  action:
  - service: light.turn_on
    entity_id: light.dimmer_712
    data_template:
      brightness: "{{ states('input_number.brightness') | int }}"

… that’s not a template sensor. This doesn’t apply.

I get the error message in my log but I do not have any entity_id in my sensor section

Paste the error.

Logger: homeassistant.components.template.binary_sensor
Source: helpers/config_validation.py:752
Integration: template (documentation, issues)
First occurred: 6:05:08 PM (3 occurrences)
Last logged: 6:05:08 PM

The ‘entity_id’ option is deprecated, please remove it from your configuration

seems like you missed a template

I don’t know where to look then…

in configuration.yaml I have:
sensor: !include sensors.yaml

In sensors.yaml I do not have the word “entity” or “entity_id”…

searched via the hass file editor addon and via samba notepad++…

(also not finding entity or entity_id in configuration.yaml)

Do you use packages?

You should be looking in your binary_sensor section, not sensors.