Yes, that really doesn’t make much sense!
With a combination of my own sensors, automations and scripts + value template for the cards, I now have the option of starting a counter from 0 and increasing it by 1 every second until the watt power number goes back to 0. Then the counter is reset to 0.
In addition, a daily, monthly, weekly and yearly counter counts with +1.
In the card, I then use a value template to calculate the current counter status in euros based on the number of watts of the plug.
The next step would then be to save the value when the device powered off into a variable or helper and add each new value, giving me the cost for the day, week, month and year.
Ultimately, it is interesting to see how, for example, the fan heater drives up this huge number 0.000000138888889 and very quickly arrives at the first cents. Of course I could still round here, but the effect that arises when you see how fast the number moves does something in your head. Get a feel for how fast you burn money.
And that’s what it was really about for me. Truly real-time to see a number that increases rapidly, although one or the other device could also remain switched off.
For those who might want to recreate the second measurement, here are the Yaml codes - its really Basic for seconds calculation:
AUTOMATION FOR START
alias: Counter - Energy Wlan Switch 3 START
description: ""
trigger:
- type: power
platform: device
device_id: 59f42927cbf8b5b485e0fd1e9b060331
entity_id: sensor.wlan_steckdose_heizlufter_strommesser_power
domain: sensor
above: 5
condition: []
action:
- if:
- condition: numeric_state
entity_id: counter.energy_wohnzimmer_switch3_second_timer
above: -1
below: 1
then:
- service: script.counter_energy_wlan_switch_3_seconds_start
data: {}
mode: single
AUTOMATION FOR RESET
alias: Counter - Energy Wlan Switch 3 RESET
description: ""
trigger:
- type: power
platform: device
device_id: 59f42927cbf8b5b485e0fd1e9b060331
entity_id: sensor.wlan_steckdose_heizlufter_strommesser_power
domain: sensor
below: 5
condition: []
action:
- service: script.turn_off
data: {}
target:
entity_id: script.counter_energy_wlan_switch_3_seconds_start
- wait_for_trigger: []
timeout:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- if:
- condition: numeric_state
entity_id: counter.energy_wohnzimmer_switch3_second_timer
above: 0
then:
- service: counter.reset
data: {}
target:
entity_id:
- counter.energy_wohnzimmer_switch3_second_timer
mode: single
SCRIPT FOR START & COUNTING
alias: Counter - Energy Wlan Switch 3 - Seconds Start
sequence:
- repeat:
until:
- type: is_power
condition: device
device_id: 59f42927cbf8b5b485e0fd1e9b060331
entity_id: sensor.wlan_steckdose_heizlufter_strommesser_power
domain: sensor
above: -1
below: 0.1
sequence:
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: counter.increment
data: {}
target:
entity_id:
- counter.energy_wohnzimmer_switch3_second_timer
- counter.energy_wohnzimmer_switch3_week_timer
- counter.energy_wohnzimmer_switch3_day_timer
- counter.energy_wohnzimmer_switch3_month_timer
- counter.energy_wohnzimmer_switch3_year_timer
mode: single
CONFIG > COUNTER
counter:
energy_wohnzimmer_switch3_second_timer:
name: Energy Wohnzimmer Switch 3 Sekunden Timer
initial: 0
step: 1
energy_wohnzimmer_switch3_day_timer:
name: Energy Wohnzimmer Switch 3 Tages Timer
initial: 0
step: 1
energy_wohnzimmer_switch3_week_timer:
name: Energy Wohnzimmer Switch 3 Wochen Timer
initial: 0
step: 1
energy_wohnzimmer_switch3_month_timer:
name: Energy Wohnzimmer Switch 3 Monat Timer
initial: 0
step: 1
energy_wohnzimmer_switch3_year_timer:
name: Energy Wohnzimmer Switch 3 Year Timer
initial: 0
step: 1
CARD YAML:
type: entities
entities:
- type: custom:template-entity-row
icon: mdi:download
name: Consumption euros per second
state: >-
{{ (states('counter.energy_wohnzimmer_switch3_second_timer') |
multiply(0.000000138888889) *
states("sensor.wlan_steckdose_heizlufter_strommesser_power") | float)}}
Euro
- entity: counter.energy_wohnzimmer_switch3_second_timer
name: Device running (Seconds)
- entity: counter.energy_wohnzimmer_switch3_day_timer
name: Device running (Seconds / Day)
- entity: counter.energy_wohnzimmer_switch3_week_timer
name: Device running (Seconds / Week)
- entity: counter.energy_wohnzimmer_switch3_month_timer
name: Device running (Seconds / Month)
- entity: counter.energy_wohnzimmer_switch3_year_timer
name: Device running (Seconds / Year)
One thing is for sure, I tried! And I think that’s what Home Assistant is all about, trying to implement things. Nevertheless, it makes little sense when I consider what is still missing here for the individual daily, weekly, monthly, annual calculations and then the data also has to be saved.
AND the worst part is that it was all for a single plug. I now have 20-50 of them all over the house afterwards… Hallelujah
So I’ll stop my plan here after many hours of testing and tinkering.
Unfortunately, the procedure via Powercalc and/or Rieman sum integration always brings me to a point… It doesn’t work exactly.
I looked at the data in the app and the values differ so much from those in Home Assistant. Sometimes that is several kWh too much or too little. And by that I don’t mean this known problem of x10 or x100 if you don’t have “Left” selected.
An exact measurement is apparently not possible and therefore pointless if at the end of the year with daily deviations of several kWhs on 365 days later completely different sums come out.
One idea is certainly to build a Shelly 3EM in the electrical boxes at the end. Then you can at least keep an eye on the total consumption of the whole house. But it is still a pity that there is no simpler and more accurate way for individual devices / rooms.
I would also like to say a big thank you to everyone who helped here! A great active community that Home Assistant has built here! Thank you very much