First of all I create a numeric sensor to give a value when the pump or ventilator is running:
#---------------------------------------------------------------------------------------------------------------------------------------Running hours prep
ventilator_game_room: # state switch to numeric value 1 = on, 0 = off
friendly_name: Ventilator Game Room
value_template: >-
{% if is_state("switch.sonoff_1000a012cb", "on" ) %}
1.0
{% else %}
0.0
{% endif %}
pool_pump: # state switch to numeric value 1 = on, 0 = off
friendly_name: Pool Pump
value_template: >-
{% if is_state("switch.sonoff_1000bee815", "on" ) %}
1.0
{% else %}
0.0
{% endif %}
I do the same to determine the power (just multiply by the Watts used. I don’t have an actual power measurement sensor, but I know what the Wattage is approx when running):
kw_ventilator_game_room: # state switch to numeric value 56.0 = on, 0 = off
friendly_name: kW Ventilator Game Room
unit_of_measurement: 'W'
unique_id: kw_vntltr_gm_rm
device_class: power
value_template: >-
{% if is_state("switch.sonoff_1000a012cb", "on" ) %}
56.0
{% else %}
0.0
{% endif %}
kw_pool_pump: # state switch to numeric value 1.4 = on, 0 = off
friendly_name: kW Pool Pump
unit_of_measurement: 'kW'
unique_id: kw_pl_pmp
device_class: power
value_template: >-
{% if is_state("switch.sonoff_1000bee815", "on" ) %}
1.400
{% else %}
0.0
{% endif %}
These sensors I use as source for a Riemann Intergration (I know it could be done as well by running hours * Watts, but I wanted to use the Riemann for the energy calculation):
- platform: integration
source: sensor.ventilator_game_room
name: Cum Running Hours Ventilator Game Room
method: left
unique_id: cm_rnng_hrs_vntltr
round: 1
- platform: integration
source: sensor.kw_ventilator_game_room
name: Cum kWh Ventilator Game Room
unit_prefix: k
method: left
unique_id: cm_kwh_vntltr
round: 3
- platform: integration
source: sensor.pool_pump
name: Cum Running Hours Pool Pump
method: left
unique_id: cm_rnng_hrs_pl_pmp
round: 1
- platform: integration
source: sensor.kw_pool_pump #1400W
name: Cum kWh Pool Pump
method: left
unique_id: cm_kwh_pl_pmp
round: 3
Those sensors I use in the utility meter integration both for running hours and Energy:
utility_meter:
# Running Hours
running_hours_pool_pump:
source: sensor.cum_running_hours_pool_pump
unique_id: rnng_hrs_pl_pmp
cycle: yearly
running_hours_ventilator_game_room:
source: sensor.cum_running_hours_ventilator_game_room
unique_id: rnng_hrs_vntltr_gm_rm
cycle: yearly
and kWh:
# Energy Consumption
util_kwh_cons_vntltr_hourly:
source: sensor.cum_kwh_ventilator_game_room
cycle: hourly
unique_id: cm_kwh_vntyltr_gm_rm_hr
util_kwh_cons_vntltr_daily:
source: sensor.cum_kwh_ventilator_game_room
cycle: daily
unique_id: cm_kwh_vntyltr_gm_rm_dy
util_kwh_cons_vntltr_monthly:
source: sensor.cum_kwh_ventilator_game_room
cycle: monthly
unique_id: cm_kwh_vntyltr_gm_rm_mnth
util_kwh_cons_vntltr_yearly:
source: sensor.cum_kwh_ventilator_game_room
cycle: yearly
unique_id: cm_kwh_vntyltr_gm_rm_yr
util_kwh_cons_pl_pmp_hourly:
source: sensor.cum_kwh_pool_pump
cycle: hourly
unique_id: cm_kwh_pl_pmp_hr
util_kwh_cons_pl_pmp_daily:
source: sensor.cum_kwh_pool_pump
cycle: daily
unique_id: cm_kwh_kwh_pl_pmp_dy
util_kwh_cons_pl_pmp_monthly:
source: sensor.cum_kwh_pool_pump
cycle: monthly
unique_id: cm_kwh_kwh_pl_pmp_mnth
util_kwh_cons_pl_pmp_yearly:
source: sensor.cum_kwh_pool_pump
cycle: yearly
unique_id: cm_kwh_kwh_pl_pmp_yr
Well the spooky thing is that the pool pump works as a charm but the ventilators consistently fails…
The attentive reader might have seen that the only difference between the two is the unit_prefix but I have tried it without as well with no result. If I check the values of the first sensors measuring the running state for both works fine ( returns 1.0 and 56W respectively 1.4 kWh )