I have many devices, each able to measure energy ( kWh ) and power ( kW ).
I would like to have a card that will show graph about power consumed by the whole house.
As well has a energy history.
Is there a way to get new entities automatically added ?
No way to get a wildcard in entity_id or similar ? Or may be a way to group them first and then use the template you suggested ?
I suppose it is possible by adapting something like this template that gets all lights that are off and creates a list of entity ids.
{% set domain = 'light' %}
{% set state = 'off' %}
{{ states[domain] | selectattr('state','eq', state) | map(attribute='entity_id') | list | join(', ') }}
Set the domain to ‘sensor’, and match on the unit of measurement (kWh) . Though this may be an issue as your template sensor will have the same unit and it will add itself. The easiest solution to that would be to subtly change the unit of the template sensor (e.g. KWh is different to kWh).
Then join the matches into a string of additions.
I suspect you would have to monitor a time sensor to force the template to update every minute, otherwise you may end up having to list all the sensors the template has to monitor for changes anyway - negating the usefulness of the template.
Either way it’s beyond my templating skill. @123, @pnbruckner or @petro may have some input.
You can’t just combine kW and kWh. They 2 totally different meanings. Gotta take all your kW sensors and turn them into kWh sensors by using the integration sensor.
You can’t just combine kW and kWh. They 2 totally different meanings. Gotta take all your kW sensors and turn them into kWh sensors by using the integration sensor.
I don’t want to sum those 2 entities; the result should be 2 different values one for KWh and one for KW.
My issue is to make the addition of consistent sensors in a wisely manner.
@chemelli: I started to use your code (thanks for posting) and it seems that the template sensors get reset to 0 and then back to their group value. This in turn leads to the dailiy utility_meter to increase by that amount.
i didn´t get it work. i want to sum the total energy for all my shelly devices. i tried with your codes but i don´t know how you managed it. can you help?
what is the entity_id: sensor.time in your script?
when i insert your code in configuration.yaml i got the error for line: entity_id: sensor.time
String does not match the pattern of “DEPRECATED^”.yaml-schema: http://schemas.home-assistant.io/
I’m struggling with random resets of the total energy consumption. I’m also using the native integration of Shelly. Would you mind sharing the adaptions you made to your initial GitHub script to make it work with the native shelly integration?
nevermind i found way to solve these random resets of shellys way to provide total energy usage to home assistant.
For future reference: You can use the riemann sum integral to calculate the total energy usage based on the current energy usage. This is a little bit less accurate than the values directly reported by shelly (around 0.5% due to the reporting rate of current power usage) but still better than getting wrong information. You can then wrap the total energy usage provided by the riemann sum integral with the utility meter integration. This delivers top results for me so far.
In contrast to directly reading the total energy usage from shelly devices, this is also more error proof. When rebooting home assistant, home assistant tends to set the last reading of a shelly device to 0. When home assistant then gets the new total energy usage value from shelly, home assistant calculates the difference and that’s why these huge total energy usage numbers exist. Using the riemann sum integral solves these because having 0 current power usage doesn’t affect the calculation. The only problem is, if you have devices that do not report energy usage in real time or at least very frequently. The riemann integrations also fails on downtimes. But usually home assistant and shelly devices that offer power readings are online around the clock