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

Those error messages aren’t for trend. The entity_id is needed for that configuration. Post the error please.

1 Like

It concerns:

  - platform: template

only :wink:

1 Like

Duh! I did not see the forest for the trees :face_with_hand_over_mouth:

Sure yes:

    - platform: template
      sensors:
        temperature_master_bedroom:
          friendly_name: "Temperature Master Bedroom"
          icon_template: mdi:thermometer
          value_template: "{{ (states('sensor.broadlink_rm4_1_master_bedroom_temperature')) |round(1) }}"
          unit_of_measurement: "°C"
          #entity_id: sensor.broadlink_rm4_1_master_bedroom_temperature

All good now. Sorry for the noise :zipper_mouth_face:

Hi.
what do i have to change?
Thanks

sensor:

  • platform: template
    sensors:
    last_alexa:
    entity_id:
    - media_player.eco_1
    - media_player.eco_2
    value_template: >
    {{ states.media_player | selectattr(‘attributes.last_called’,‘eq’,True) | map(attribute=‘entity_id’) | first }}

Remove

entity_id:
  - media_player.eco_1
  - media_player.eco_2

OK, Thanks

1 Like
Help. How to update without entity_id: time_date

sensors:
      datum_mesic: 
        value_template: >
          {% set months = ["leden", "únor", "březen", "duben", "květen", "červen", "červenec", "srpen", "září", "říjen", "listopad", "prosinec"] %}
          {% set month = months[now().strftime('%m') | int -1] %}  
          {{ now().strftime('%d') + ' ' + month + ' '+ now().strftime('%Y') }}

Just stick in this line. It’s the simplest way. You don’t even have to use it. Just having it there is enough to trigger recalculation of the template.

{% set current_time = states('sensor.time_date') %}
1 Like

It took me a while to understand, but it already works. Thank you very much

Your template calculates the current date so it only needs to be updated once, at the start of each new day. For that reason, I recommend you use sensor.date, because it updates at the start of each new day, as opposed to sensor.time_date which updates every minute.

Here’s a streamlined version of your Template Sensor:

sensors:
  datum_mesic: 
    value_template: >
      {% set x = states('sensor.date') %}
      {% set months = ["null", "leden", "únor", "březen", "duben", "květen", "červen", "červenec", "srpen", "září", "říjen", "listopad", "prosinec"] %}
      {{'{:02d} {} {}'.format(now().day, months[now().month], now().year)}}

Hi,

I use entity_id: [] so no trigger on the sensor was executed so I could store the value on fixed time when I call homeassistant.update_entity. But is not working anymore because entity_id is not supported anymore how can this template so it will only be executed at midnight so the value of the sensor: ‘sensor.energy_production_total’ is only retrieved and stored at midnight? and not every moment that sensor values is changing.

Has anybody a suggestion?

       energy_production_daily_start:
         friendly_name: Energy production daily start
         unit_of_measurement: 'kWh'
         # no trigger (trigger will be done time based via automation, normally at the start of the day)
         entity_id: []
         value_template: "{{ (states('sensor.energy_production_total')|float) | round(3) }}"

Easiest way for this would be to have an automation that uses the time trigger at 00:00:00 that calls homeassistant.update_entity to update the sensor.

Or like @123 said, just add a line to reference sensor.date so that it’ll trigger an update when the day changes.

Thanks to everyone. I didn’t expect such support and I really appreciate it.

But will this sensor also not be evaluated when the sensor.energy_production_total is changed? Because that is not what I want. I want the value only once a day not every time sensor.energy_production_total changes.

It seems like what you really want is an input value that you update every day at 00:00:00 with an automation. If you don’t want it to update based on the templated values, then you don’t really want a sensor.

1 Like

Just stumbled onto this in my logs too. PITA figuring out where it’s coming from in all the files.

I’m using a large number of template sensors updated 1x/min to graph the age of some sensors, if I remove the “entity_id” it then gives me negative values sometimes (updated more recently than time).

Anyone have suggestions to avoid negative values and remove the warning?

Here’s my code in one such sensor:

sensor:

  - platform: template
    sensors:
      outside_front_sensor_age:
        friendly_name: "Outside Front Sensor Age"
        entity_id: sensor.time
        value_template: >-
          {% if states.sensor.outside_front_temperature.last_changed > states.sensor.outside_front_humidity.last_changed %}
            {{ (states.sensor.time.last_changed - states.sensor.outside_front_temperature.last_changed).total_seconds() | round(0) }}
          {% else %}
            {{ (states.sensor.time.last_changed - states.sensor.outside_front_humidity.last_changed).total_seconds() | round(0) }}
          {% endif %}
        unit_of_measurement: "Seconds"

And my desired result, a graph of age (but preferably not negative):
image

Anyone have ideas how to resolve the negative values issue post-update?

don’t use last_changed, use now() for sensor.time

Doesn’t this cause the sensor to be updated unnecessarily frequently though? Time isn’t something that should cause the sensor to be recalculated, only something that needs to be used in order to calculate the sensor.

Never mind…I think this is not the case for this particular sensor.

Everything I’d read in guides says now() is only evaluated at startup though? Does now() work now?

Now will get evaluated every minute if an update hasn’t occurred in the past minute.

1 Like