Add calculated energy sensor for Home Assistant Energy dashboard - #21
Add calculated energy sensor for Home Assistant Energy dashboard#2111chri wants to merge 1 commit into
Conversation
|
A new integration on a good way. Until last week I used the REST-Entities for reading the AC-Thor9s values in a 30 second interval. For EMS the 5 second intervall is great. But using the Boost mode, the integration lost the connection to the AC-Thor9 for one or two cycles. Maybe there is still a time problem. HomeAssistant Core 26.7.2 |
Add calculated energy sensor for Home Assistant Energy dashboard
Problem
The integration only exposes a power sensor (W) for my-PV heating devices.
To use the Home Assistant Energy dashboard, users had to manually create a Riemann Sum Integral helper to convert W → kWh.
Solution
Add a built-in
Energysensor that accumulates kWh from the device's power readings using time-delta integration on each coordinator update (every 5s). The sensor is directly compatible with the HA Energy dashboard.Details
sensor.<device>_energywithdevice_class: energy,state_class: total_increasing,unit: kWh, 3 decimal precisionfor each device type:
powerpower_ac9power_actpower_elwa2power_gridRestoreEntityto restore accumulatedenergy on HA restart
to prevent spikes after prolonged disconnections
strings.jsonanden.jsonFiles changed
sensor.py: AddedPOWER_KEYSconstant, energy sensor creationlogic in
async_setup_entry, andMyPVEnergySensorclassstrings.json: Added entity translation for energy sensortranslations/en.json: Added entity translation for energy sensorTests
I rebased my MR to My-PV HA integration, Version 0.0.1rc6 and tested locally with AC•THOR 9s
AC•THOR 9s can now be visualized in Energy Dashboard
