Sensors quit working

I’ve been using Home Assistant Docker for a few weeks and have been adding and learning over the past few weeks. Yesterday I added some things and also updated the Home Assistant to the latest version and my OS also updated Docker and Docker compose. Somewhere along the way, some of my sensors quit working. I’m not seeing anything obvious form the yaml file as far as spacing and I’m not getting any errors when I check but most of the sensors listed in my sensors.yaml file simply will not pull up. Below is my sensors.yaml file. Does anyone see anything obvious? I can add my configuration.yaml file if needed.


- platform: template
  sensors:
    hvac_activity:
      friendly_name: "Current Operating State"
      value_template: "{{ state_attr('climate.my_home_2', 'hvac_action') }}"

  sensors:
    hvac_mode_setting:
      friendly_name: "Heating or Cooling Mode"
      value_template: "{{ states('climate.my_home_2')  }}"
      
  sensors:
    hvac_preset:
      friendly_name: "Home or Away Program"
      value_template: "{{ state_attr('climate.my_home_2', 'preset_mode') }}"


  sensors:
    forecast_total:
      friendly_name: "Rain detector"
      value_template: "{{ state_attr('weather.forecast_home', 'forecast')[0].precipitation }}"
      unit_of_measurement: "in"
      
  sensors:
    pirate_rainfail_forecast_total:
      friendly_name: "Pirate Precipitation"
      value_template: "{{ state_attr('weather.pirateweather', 'forecast')[0].precipitation }}"
      unit_of_measurement: "in"
      
  sensors:
    pirate_forecast_high:
      friendly_name: "Pirate Daily High Temp"
      value_template: "{{ state_attr('weather.pirateweather', 'forecast')[0].temperature }}"
      unit_of_measurement: "°F"

  sensors:
    pirate_rainfail_forecast_percent:
      friendly_name: "Pirate Probability"
      value_template: "{{ state_attr('weather.pirateweather', 'forecast')[0].precipitation_probability }}"
      unit_of_measurement: "%"

  sensors:
    hvac_setpoint:
      friendly_name: "Current Thermostat Set Point"
      value_template: "{{ state_attr('climate.my_home_2', 'temperature') }}"
      unit_of_measurement: "°F"

  sensors:
    front_yard_sprinklers_days_off:
      friendly_name: "Front Yard Sprinkler Days Off"
      entity_id:
        - sensor.zone_history
      value_template: "{{((as_timestamp(now()) - as_timestamp(states('sensor.frontyard_zone_history'))) / 86400) | int }}"
      unit_of_measurement: "Days"

  sensors:
    back_yard_sprinklers_days_off:
      friendly_name: "Back Yard Sprinkler Days Off"
      entity_id:
        - sensor.zone_history
      value_template: "{{((as_timestamp(now()) - as_timestamp(states('sensor.backyard_zone_history'))) / 86400) | int }}"
      unit_of_measurement: "Days"


  sensors:
    indoor_temp_delta:
      friendly_name: "Indoor Temp Delta"
      entity_id:
        - sensor.thermostat_temperature_temperature_6
        - sensor.hvac_setpoint
      value_template: >-
          {% set indoorTemp = states.sensor.thermostat_temperature_temperature_6.state|float %}
          {% set indoorTempsetpoint = states.sensor.hvac_setpoint.state| float %}
          {{ (indoorTempsetpoint  - indoorTemp)|round(1) }}
      unit_of_measurement: "°F"

  sensors:
    outdoor_temp_delta:
      friendly_name: "Outdoor Temp Delta"
      entity_id:
        - sensor.thermostat_temperature_temperature_6
        - sensor.outdoor_temperature
      value_template: >-
          {% set indoorTemp = states.sensor.thermostat_temperature_temperature_6.state|float %}
          {% set outdoorTemp = states.sensor.outdoor_temperature.state| float %}
          {{ (outdoorTemp - indoorTemp)|round(1) }}
      unit_of_measurement: "°F"

  sensors:
    hvac_setpoint_plus2:
      friendly_name: "Setpoint plus 2"
      entity_id:
        - sensor.thermostat_temperature_temperature_6
        - sensor.hvac_setpoint
      value_template: >-
          {% set indoorTempsetpoint = states.sensor.hvac_setpoint.state| float %}
          {{ (indoorTempsetpoint  + 2)|round(1) }}
      unit_of_measurement: "°F"

  sensors:
    hvac_setpoint_minus3:
      friendly_name: "Setpoint minus 3"
      entity_id:
        - sensor.thermostat_temperature_temperature_6
        - sensor.hvac_setpoint
      value_template: >-
          {% set indoorTempsetpoint = states.sensor.hvac_setpoint.state| float %}
          {{ (indoorTempsetpoint  - 3)|round(1) }}
      unit_of_measurement: "°F"
      
      
- platform: history_stats
  name: Heating Today
  entity_id: sensor.hvac_activity
  state: 'heating'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

  name: HVAC Idle Today
  entity_id: sensor.hvac_activity
  state: 'idle'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'


  name: Cooling Today
  entity_id: sensor.hvac_activity
  state: 'cooling'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'
 
  name: Indoor Temp Delta Trend
  entity_id: sensor.indoor_temp_delta
  state: 
  type: time
  start: '{{ now().replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

  name: Outdoor Temp Delta Trend
  entity_id: sensor.outdoor_temp_delta
  state:
  type: time
  start: '{{ now().replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'
 
  type: time
  name: Lamp 3 Ontime Today
  entity_id: switch.den_lamp_3
  state: "on"
  start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
  end: "{{ now() }}"


What does your log say?

Because I’m not sure exactly when they quit working, it’s hard to find an event that leads me to it but I do see messages with a yellow icon beside each sensor saying idle.

please post a few of those error messages. Without any indication on why, we can’t start to figure it out. As you said most of those look fine but its possible something took out your include for the entire sensor file and NONE of them load… (In which case the sensor file itself is useless because they’ll all be good) We just dont have enough to go on without error logs. Feel free to pick out the completely obviously irrelevant stuff and redact secrets but - gotta have a log - please use the preformatted text option above when you post it

First, my apologies. I was looking at the logbook and not the log files. Here are some log file entires. The issues seem to be centered around my Ecobee thermostat related entities.


File "/usr/src/homeassistant/homeassistant/components/ecobee/weather.py", line 173, in forecast
forecast = _process_forecast(self.weather["forecasts"][day])
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
IndexError: list index out of range
2023-07-13 15:02:20.230 ERROR (MainThread) [homeassistant.helpers.event] Error while dispatching event for 74eb194c6f3e7062116fa2359edafc49 to <Job track device_registry_updated event ['74eb194c6f3e7062116fa2359edafc49'] HassJobType.Callback <bound method Entity._async_device_registry_updated of <entity weather.my_home_2=unknown>>>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 458, in _async_dispatch_device_id_event
hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 619, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1155, in _async_device_registry_updated
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 811, in _async_write_ha_state
attr.update(self.state_attributes or {})
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 747, in state_attributes
if self.forecast is not None:
^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/ecobee/weather.py", line 173, in forecast
forecast = _process_forecast(self.weather["forecasts"][day])
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
IndexError: list index out of range
2023-07-13 15:02:20.244 ERROR (MainThread) [homeassistant.helpers.event] Error while dispatching event for 74eb194c6f3e7062116fa2359edafc49 to <Job track device_registry_updated event ['74eb194c6f3e7062116fa2359edafc49'] HassJobType.Callback <bound method Entity._async_device_registry_updated of <entity weather.my_home_2=unknown>>>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 458, in _async_dispatch_device_id_event
hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 619, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1155, in _async_device_registry_updated

When I select an Ecobee specific error, it also shows the following:



Logger: homeassistant.helpers.event
Source: components/ecobee/weather.py:173
First occurred: 3:23:56 PM (1 occurrences)
Last logged: 3:23:56 PM
Error while dispatching event for 74eb194c6f3e7062116fa2359edafc49 to <Job track device_registry_updated event ['74eb194c6f3e7062116fa2359edafc49'] HassJobType.Callback <bound method Entity._async_device_registry_updated of <entity weather.my_home_2=unknown>>>

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 458, in _async_dispatch_device_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 619, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1155, in _async_device_registry_updated
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 811, in _async_write_ha_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 747, in state_attributes
    if self.forecast is not None:
       ^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/ecobee/weather.py", line 173, in forecast
    forecast = _process_forecast(self.weather["forecasts"][day])
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
IndexError: list index out of range

Something with your ecobee is not returning what it expects. It’s related to pulling some kind of weather forecast.

Considering template sensors become unavailable if the data they are sourced from become unavailable. I’d bet the sensors you derive from your ecobee are the ones not working?

Id start by figuring out what’s up with those sensors you were templating from around your climate section up top. I’d bet one or more are unavailable for one reason or another

They all show correctly when I query the state of the thermostat but the sensors derived from it are the problem. I even deleted it and reinstalled it with no change.

pop one of the value templates for one of the busted ones in the template editor and see what it complains about

check your entities , they seems to have _2 at the end, can be caused by, “duplicates” caused by faulty installation/loss of power(rediscovering the devices) or so

<entity weather.my_home_2=unknown>>>
1 Like

The _2 is because I replaced one thermostat with another and it assigned the same name, so that’s not new to the problem. I’ll attempt another value template and see what I get.

What, so are you saying that your ERROR’s has nothing to do with the “clear text” saying " WEATHER.my_home_2" = unknown ???

I created a new one on fan_mode and it made no difference. The thermostat is called My Home 2 and when I pull up climate.my_home_2, on the states tab it shows me everything about it. So Home Assist knows it called that but the template sensors are no longer pulling up.

- platform: template
  sensors:
    fan_mode:
    friendly_name: "Fan Mode"
    value_template: "{{ state_attr('climate.my_home_2', 'fan_mode') }}" 

Another bit of information: The template below will not work but, if I enter

"{{ states('climate.my_home_2')  }}" 

in the template tester, it pulls up ‘cool’.

- platform: template
  sensors:
    hvac_mode_setting:
      friendly_name: "Heating or Cooling Mode"
      value_template: "{{ states('climate.my_home_2')  }}"

none of these history stats sensors have a platform after the first one:

- platform: history_stats
  name: Heating Today
  entity_id: sensor.hvac_activity
  state: 'heating'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

  name: HVAC Idle Today
  entity_id: sensor.hvac_activity
  state: 'idle'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'


  name: Cooling Today
  entity_id: sensor.hvac_activity
  state: 'cooling'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'
 
  name: Indoor Temp Delta Trend
  entity_id: sensor.indoor_temp_delta
  state: 
  type: time
  start: '{{ now().replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

  name: Outdoor Temp Delta Trend
  entity_id: sensor.outdoor_temp_delta
  state:
  type: time
  start: '{{ now().replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'
 
  type: time
  name: Lamp 3 Ontime Today
  entity_id: switch.den_lamp_3
  state: "on"
  start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
  end: "{{ now() }}"

I believe it should be this:

- platform: history_stats
  name: Heating Today
  entity_id: sensor.hvac_activity
  state: 'heating'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

- platform: history_stats
  name: HVAC Idle Today
  entity_id: sensor.hvac_activity
  state: 'idle'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

- platform: history_stats
  name: Cooling Today
  entity_id: sensor.hvac_activity
  state: 'cooling'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'
 
- platform: history_stats
  name: Indoor Temp Delta Trend
  entity_id: sensor.indoor_temp_delta
  state: 
  type: time
  start: '{{ now().replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

- platform: history_stats
  name: Outdoor Temp Delta Trend
  entity_id: sensor.outdoor_temp_delta
  state:
  type: time
  start: '{{ now().replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'
 
- platform: history_stats
  type: time
  name: Lamp 3 Ontime Today
  entity_id: switch.den_lamp_3
  state: "on"
  start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
  end: "{{ now() }}"

and the later example of the new fan_mode sensor isn’t indented correctly.

you have in the code snippet:

- platform: template
  sensors:
    fan_mode:
    friendly_name: "Fan Mode"
    value_template: "{{ state_attr('climate.my_home_2', 'fan_mode') }}" 

should be:

- platform: template
  sensors:
    fan_mode:
      friendly_name: "Fan Mode"
      value_template: "{{ state_attr('climate.my_home_2', 'fan_mode') }}" 

at least that’s all I see at first glance from the code that you posted.

Thanks. I made those corrections but, unfortunately, no change in it recognizing the values.

I think I have mostly worked through this. The issue seems to be unicode values for degrees F that has worked flawlessly but, for some reason is flagging errors now.

Thanks to all who have offered help.

And I also just noticed that there are a couple of those history stats sensors that don’t have a “state:” defined