I extract my solar panel data from a rest interface (enphase envoy-s). Then I take that rest data and split it into different sensors using a template:
Reload Template Entities and it should appear in the dashboard.
NOTE
Customizations not only lets you modify an entity’s existing information, it also lets you add new, custom information, such as custom attributes (that would be rejected if you included them as part of the entity’s configuration).
@123, could you tell if it still should work that way? Because it is not for me - I also tried adding a total_consumption attribute using your method. Still no success
Hi, I’ve been trying to create an entity to be used in energy dashboard, and apparently I’m following the rules and hints here above, but the entity doesn’t appear, even though I can see properly its value.
The sensor is reading, via rest, the value of exported energy.
This is the code:
- platform: rest
resource: http://192.168.1.165/metern/programs/programtotal.php
name: solar totali immissioni day
value_template: '{{ value_json.Dailycounter4 }}'
unit_of_measurement: KWh
state_class: measurement
device_class: energy
unique_id: "immissioni_oggi"
Same here guys, could really use some hints. My template sensor definition looks like this (which lives in a separate file for my templates called mytemplates.yaml):
- unique_id: grid_import
name: Grid Import
unit_of_measurement: kWh
state: >
{% set production = states('sensor.growatt_total_energy_lifetime') | float(0) %}
{% set consumption = states('sensor.growatt_local_load_total') | float(0) %}
{% set import = consumption - production | float(0) %}
{{ (import) | round(3) }}
device_class: energy
state_class: total_increasing
icon: mdi:flash
Because I couldn’t select the sensor.grid_import in my energy dashboard (as grid input, duh), I added the following in my configuration.yaml, but still no cigar:
homeassistant:
customize:
sensor.grid_import:
device_class: energy
state_class: total_increasing
last_reset: '1970-01-01T00:00:00+00:00'
Then I thought maybe the sensors I use in my template should also be marked as ‘energy’ (which shouldn’t be the case, right) so I added their definition here anyway, these are defined in an ESPHome yaml file:
EDIT: I added the sensor manually to the energy file in /config/.storage/energy and rebooted my device. That does seem to work (at least I see the data in my dashboard now), however I still can’t select that sensor from the dropdown in the UI (Settings → Dashboards → Energy) So for me at least right now I have a working setup
EDIT2: ignore that, the grid import shows up in the energy dashboard, but it remains at 0kWh, so it doesn’t work after all.
Small update, under ‘Developer Tools → Statistics’ I was able to find an issue with my template sensor, it stated that the unit changed from kW to kWh (which was likely a copy-paste error when I first created the sensor). I clicked ‘fix it’ and chose to delete all previous data. After this, I was able to select my template sensor in the Energy dashboard settings. I’ll update you if I see actual data coming in.
PS: a warning icon or something would be nice in the dropdown instead of just not showing the sensor