Manually defined sensors - need an advise, as experience a ghosts in the system

I have created multiple sensors in the template section, and after multiple edits of the templates file i have started experiencing the ghost sensors.
I guess either i am doing something wrong or missing something completely - and need your advice

the situation

in /config/configuration.yaml file:

template: !include templates.yaml

in the “/config/templates.yaml” file (current state, system has been rebooted afterwards)

#- sensor: 
#    - name: "Kitchen Thermostat - Target Temperature - BB"
#      unit_of_measurement: "°C"
#      state: "{{ state_attr('climate.kitchen_thermostat_aqara', 'temperature' )}}"
#      icon: mdi:thermometer
#      unique_id: kitchen_thermostat_target_temperature_bb
#- sensor: 
#    - name: "Kitchen Thermostat - Target Temperature - BB"
#      unit_of_measurement: "°C"
#      state: "{{ state_attr('climate.kitchen_thermostat_aqara', 'temperature' )}}"
#      icon: mdi:thermometer
#      unique_id: kitchen_thermostat_target_temperature_5
- sensor:
    - name: "Kitchen Thermostat - Target Temperature"
      unit_of_measurement: "°C"
      state: "{{ state_attr('climate.kitchen_thermostat_aqara', 'temperature' )}}"
      icon: mdi:thermometer
      unique_id: kitchen_thermostat_target_temperature
- sensor:
    - name: "Kitchen XXX Thermostat - Target Temperature"
      unit_of_measurement: "°C"
      state: "{{ state_attr('climate.kitchen_thermostat_aqara', 'temperature' )}}"
      icon: mdi:thermometer
      unique_id: kitchen_xxx_thermostat_target_temperature

even after a complete reboot the “old” configuration, sensor from the template remains in the system.
it stays with the status “unavailable”, but it is there.
see the screenshot:

and newly “redefined” / “edited” value is missing.
what is also a bot astonishing - the “unique_id” field seems to have no impact on defined sensor name, but the field name does have an impact.

Note: System is based on ORDOID-N2, 64 GB eMMC, started from the dedicated to this platform image

Question
Hot to “reset” the system that “old” sensors are purged from it and new ones are active and visible?

Find it under integrations > entities. Then select it and delete it.

1 Like

Thanks, these ghosts are gone, this helped.
But the new ones are not loaded, even after the system is reloaded.
any idea where to check?

You don’t need the 2nd - sensor:

Go to developer tools > yaml > reload template sensors (it’s near the bottom of the page).

1 Like

Thank you! This helped.

What I have missed to see that the name of the “old” sensor entity ID we there, even “new” ones were appearing, the old one was hanging there, and when I was trying to “recreate” it was sticking to the old entity ID.


It was a copy paste error in the initial template file, resulted in the entity being “always” there, and as the name was completely different, it was overlooked.

The solution was following:

  • all entries in the template which have something to do with this template / sensors needed to be reloaded / commented out.
  • reload YAML configuration (Development Tools > YAML)
  • delete false entries in the entity place (Settings > Devices & Services > Entities)
  • edit the template.yaml file by adding / returning required sensors
  • reload YAML configuration (Development Tools > YAML)

then all was “fixed”

Thanks once again.