For my energy setup I have connected a “P1 Smart Gateway” to my smart meter using MQTT. All devices pop up and are readable in MQTT explorer.
However some could not be added to the energy dashboard as the “entity not available” or “statistics not defined” so I decided to put them as a template sensor in my configuration.yaml. That worked (code at the end of my post), however they seemed not to do what I wantred them to do, so deleted the template sesors from configuration.yaml, removed greyed out sensors in HA. However, the energy dashboard is still presenting them as an option in the list of devices to add to the dash. How can I remove those ghost sensors?
There is no place else these sensors are being used (no yaml, no automation), nor do I see them in my developer tools → entities.
Ans yes, I waited for a day or 2 (caching) and restarted repeatedly my installation before posting this question
Pic:
Part of the configuration.yaml
# TEMPLATE SENSOREN
template:
- sensor:
- name: "VerbruikP1P2"
unique_id: "verbruikp1p2"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
state: >
{{ states ('sensor.dsmr_reading_electricity_delivered_1') | float(0) | round(2)
+ states ('sensor.dsmr_reading_electricity_delivered_2') | float(0) | round(2)}}
- sensor:
- name: "VerbruikTotaal"
unique_id: "verbruiktotaal"
unit_of_measurement: "kWh"
device_class: energy
# last_reset: '1970-01-01T00:00:00+00:00'
state_class: measurement
state: >
{{ states ('sensor.dsmr_reading_electricity_currently_delivered') | float(0) | round(2)}}
- sensor:
- name: "RetourP1P2"
unique_id: "retourp1p2"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
state: >
{{ states ('sensor.dsmr_reading_electricity_returned_1') | float(0) | round(2)
+ states ('sensor.dsmr_reading_electricity_returned_2') | float(0) | round(2)}}
- sensor:
- name: "RetourTotaal"
unique_id: "retourtotaal"
unit_of_measurement: "kWh"
device_class: energy
# last_reset: '1970-01-01T00:00:00+00:00'
state_class: measurement
state: >
{{ states ('sensor.dsmr_reading_electricity_currently_returned') | float(0) | round(2)}}
- sensor:
- name: "Verbruik totaal energy"
unit_of_measurement: 'kWh'
state: >
{{ (states("sensor.dsmr_reading_electricity_currently_delivered") | float) | round(2) }}
device_class: energy
state_class: measurement
attributes:
last_reset: '1970-01-01T00:00:00+00:00'