I switched from energy supplier and opted for one tariff, my old situation was a day and night tariff.
My DSMR integration still shows the day and night tariff and also shows the consumption on these two sensors. Is this correct and if so, how can I link these 2 sensors into one sensor?
It would be nice if these two values could be added together and read as one consumption sensor.
The sensor sensor.power_consumption does not show any data.
Ok. Thanks. So it is easy to add those two sensors together. The problem is if we just add that new summed sensor to the energy dashboard it will read twice your energy consumption unless you remove the two existing sensors from the dashboard. And if you do that you will lose your existing energy history.
Two solutions:
Leave sensor _1 and _2 in the energy dashboard. Rename these sensors to: _1_new and _2_new on the integration device page. Create three new sensors. One that is the sum of _1_new and _2_new and two new sensors _1 and _2 that always read 0. Add the new summed sensor to the energy dashboard and leave the existing ones in place (that will read 0 from now on, but you can see the history).
Or
Remove sensors _1 and _2 from the energy dashboard. Create a summed sensor for _1 and _2, add that to the energy dashboard and start again with no history.
template:
- sensor:
- name: Total Energy From Grid
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.energy_consumption_tarif_1_new')|float(0) + states('sensor.energy_consumption_tarif_2_new')|float(0) }}"
avilability: "{{ has_value('sensor.energy_consumption_tarif_1_new') and has_value('sensor.energy_consumption_tarif_2_new') }}"
- trigger:
- platform: homeassistant
event: start
sensor:
- name: energy_consumption_tarif_1
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ 0 }}"
- name: energy_consumption_tarif_2
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ 0 }}"
Do a configuration check and if that passes restart home assistant.
Then go to Settings → Dashboards → Energy and add sensor.total_energy_from_grid to your grid sensors. Leave the existing sensors there. Do not delete anything.
From now on you should have only one grid sensor showing in the dashboard graph but in the history the two tariff sensors should still be there.
I made the changes, and the sensor “sensor.total_energy_from_grid” does not show up.
When i check the log file is says:
Invalid config for [template]: [avilability] is an invalid option for [template]. Check: template->sensor->0->avilability. (See /config/configuration.yaml, line 32).
OK didn’t see there was a typo in it
Ok the error is gone now.
But i don’t see any historical data anymore, when i change the old sensors to the *_new sensors the historical data is displayed
Is it possible to stick with the old names and only combine these two sensors to a third sensor named sensor.total_energy_from_grid ?
You should not change the names in the energy dashboard settings.
And no it is not possible to keep the old sensors as they are already adding their energy to the energy dashboard. If you also add their sum to the dashboard you would get twice the energy you actually used displayed.
EDIT:
In your Energy Dashboard you should have only these grid consumption sensors:
I did exactly as you have described I only adjusted the name in the entity ID fields.
sensor.energy_consumption_tarif_1 to sensor.energy_consumption_tarif_1_new
sensor.energy_consumption_tarif_2 to sensor.energy_consumption_tarif_2_new
I have not adjusted the names.
In the energy dashboard i only added the new sensor and left the old ones without changing anything.
No historical data is displayed.
Also the sensor sensor.total_energy_from_grid is not displaying any new data on the dashboard.
As a test I adjusted the sensors to the *_New in the energy dasboard and then the history is shown.
Then I put the backup back to get the old situation back.
Maybe it is not possible what i want and should i start with no old data.
What should the code look like to have no historical data and only combine the two sensors to single tariff? And start with a clean new dashboard from now on.
I decided to leave it as it is with normal and off-peak rates.
I think it’s too much hassle for something so simple, the option should just be selectable there.
What an amazingly interesting discussion @tom_l !
I’m in the exact same position as boulanger and was reading your instructions. That’s when a question came up:
After renamingsensor.energy_consumption_tarif_1 to sensor.energy_consumption_tarif_1_new, doesn’t all of it’s historical data move with that entity to its new name?
That would explain why Boulanger did not see the data in the energy dashboard until he changed it to the renamed ‘_new’ entities.
But… When showing the new ‘sum’ entity as well as the ‘_new’ entities the usage displayed would double.
It’s a shame that my ‘smartmeter’ still provides 2 tarifs even though I don’t have 2 tarifs.
I actually have 24 different tariffs per day, just to undercomplicate things