Despite the new awesome energy panel, I believe people (like myself) will typically have a single power meter to add as a source. While this yield accurate readings for the total energy consumption of an installation, it might also be the case that users would like to measure individual consumptions around the house, where they will install individual meters (on power sockets, on light switches, PoE ports, etc).
These power meters usually display instant power consumption in watts, and I didn’t find a straightforward way of visualising the consumption of what they are measuring on a tumbling window of say a day/week/month, etc[1].
I’ve come up with a template that will generate the configuration entries necessary to create, per power meter:
1 - The Riemann sum for the sensor
2 - Three meters for the Rienmann sum sensor: one with a daily cycle, one with a weekly cycle, one with a monthly cycle
The goal is to produce a dashboard equivalent to the energy dashboard, but for each (or a set of) individual power sensors, rather than a single one for the entire house.
It could be useful/interesting/a kink to be able to spot that a given PoE port increases its consumption when someone is watching 4k content on netflix, or that the reason why there’s higher consumption on a rainy day is because more cups of tea are brewed.
To use this, simply paste the following snippet on the templating utility on dev tools:
{## Set your sensors here ##}
{% set base_sensors = {
"instant_consumption_sensors_in_w":
[
"sensor.kettle_socket",
"sensor.christmas_tree_socket",
"sensor.living_room_ap_poe_port",
"sensor.immersion_heater",
"sensor.bathroom_lights",
"sensor.bedroom_heater"
]
} %}
This section generates the sensor configurations for the integral calculation of each one of the instance power consumption sensors configured in the variable 'base_sensors'
Paste this in the "sensor:" section of your configuration.yaml
------------>cut from next line
{%- for base_sensor in base_sensors.instant_consumption_sensors_in_w %}
- platform: integration
source: {{ base_sensor }}
unique_id: {{ base_sensor.split(".")[1] }}_energy_spent
name: {{ base_sensor.split(".")[1].replace("_"," ").title() }} Energy Spent
unit_prefix: k
unit_time: h
method: left
{% endfor -%}
------------>cut until previous line
This section generates the daily, weekly and monthly meters for each of the integrations created above
Paste this in the into your "utility_meter" section of your configuration.yaml
------------>cut from next line
{%- for base_sensor in base_sensors.instant_consumption_sensors_in_w %}
#Meters for {{base_sensor}}
{{ base_sensor.split(".")[1] }}_daily_energy_spent:
unique_id: {{ base_sensor.split(".")[1] }}_daily_energy_spent
source: {{ base_sensor }}_energy_spent
name: {{ base_sensor.split(".")[1].replace("_"," ").title() }} Energy Spent Daily
cycle: daily
{{ base_sensor.split(".")[1] }}_weekly_energy_spent:
unique_id: {{ base_sensor.split(".")[1] }}_weekly_energy_spent
source: {{ base_sensor }}_energy_spent
name: {{ base_sensor.split(".")[1].replace("_"," ").title() }} Energy Spent Weekly
cycle: weekly
{{ base_sensor.split(".")[1] }}_monthly_energy_spent:
unique_id: {{ base_sensor.split(".")[1] }}_monthly_energy_spent
source: {{ base_sensor }}_energy_spent
name: {{ base_sensor.split(".")[1].replace("_"," ").title() }} Energy Spent Monthly
cycle: monthly
{% endfor -%}
------------>cut until previous line
On the result pane on the right, two segments of configuration will be generated. One for the integrals:
- platform: integration
source: sensor.kettle_socket
unique_id: kettle_socket_energy_spent
name: Kettle Socket Energy Spent
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.christmas_tree_socket
unique_id: christmas_tree_socket_energy_spent
name: Christmas Tree Socket Energy Spent
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.living_room_ap_poe_port
unique_id: living_room_ap_poe_port_energy_spent
name: Living Room Ap Poe Port Energy Spent
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.immersion_heater
unique_id: immersion_heater_energy_spent
name: Immersion Heater Energy Spent
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.bathroom_lights
unique_id: bathroom_lights_energy_spent
name: Bathroom Lights Energy Spent
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.bedroom_heater
unique_id: bedroom_heater_energy_spent
name: Bedroom Heater Energy Spent
unit_prefix: k
unit_time: h
method: left
And one for the meters:
#Meters for sensor.kettle_socket
kettle_socket_daily_energy_spent:
unique_id: kettle_socket_daily_energy_spent
source: sensor.kettle_socket_energy_spent
name: Kettle Socket Energy Spent Daily
cycle: daily
kettle_socket_weekly_energy_spent:
unique_id: kettle_socket_weekly_energy_spent
source: sensor.kettle_socket_energy_spent
name: Kettle Socket Energy Spent Weekly
cycle: weekly
kettle_socket_monthly_energy_spent:
unique_id: kettle_socket_monthly_energy_spent
source: sensor.kettle_socket_energy_spent
name: Kettle Socket Energy Spent Monthly
cycle: monthly
#Meters for sensor.christmas_tree_socket
christmas_tree_socket_daily_energy_spent:
unique_id: christmas_tree_socket_daily_energy_spent
source: sensor.christmas_tree_socket_energy_spent
name: Christmas Tree Socket Energy Spent Daily
cycle: daily
christmas_tree_socket_weekly_energy_spent:
unique_id: christmas_tree_socket_weekly_energy_spent
source: sensor.christmas_tree_socket_energy_spent
name: Christmas Tree Socket Energy Spent Weekly
cycle: weekly
christmas_tree_socket_monthly_energy_spent:
unique_id: christmas_tree_socket_monthly_energy_spent
source: sensor.christmas_tree_socket_energy_spent
name: Christmas Tree Socket Energy Spent Monthly
cycle: monthly
#Meters for sensor.living_room_ap_poe_port
living_room_ap_poe_port_daily_energy_spent:
unique_id: living_room_ap_poe_port_daily_energy_spent
source: sensor.living_room_ap_poe_port_energy_spent
name: Living Room Ap Poe Port Energy Spent Daily
cycle: daily
living_room_ap_poe_port_weekly_energy_spent:
unique_id: living_room_ap_poe_port_weekly_energy_spent
source: sensor.living_room_ap_poe_port_energy_spent
name: Living Room Ap Poe Port Energy Spent Weekly
cycle: weekly
living_room_ap_poe_port_monthly_energy_spent:
unique_id: living_room_ap_poe_port_monthly_energy_spent
source: sensor.living_room_ap_poe_port_energy_spent
name: Living Room Ap Poe Port Energy Spent Monthly
cycle: monthly
#Meters for sensor.immersion_heater
immersion_heater_daily_energy_spent:
unique_id: immersion_heater_daily_energy_spent
source: sensor.immersion_heater_energy_spent
name: Immersion Heater Energy Spent Daily
cycle: daily
immersion_heater_weekly_energy_spent:
unique_id: immersion_heater_weekly_energy_spent
source: sensor.immersion_heater_energy_spent
name: Immersion Heater Energy Spent Weekly
cycle: weekly
immersion_heater_monthly_energy_spent:
unique_id: immersion_heater_monthly_energy_spent
source: sensor.immersion_heater_energy_spent
name: Immersion Heater Energy Spent Monthly
cycle: monthly
#Meters for sensor.bathroom_lights
bathroom_lights_daily_energy_spent:
unique_id: bathroom_lights_daily_energy_spent
source: sensor.bathroom_lights_energy_spent
name: Bathroom Lights Energy Spent Daily
cycle: daily
bathroom_lights_weekly_energy_spent:
unique_id: bathroom_lights_weekly_energy_spent
source: sensor.bathroom_lights_energy_spent
name: Bathroom Lights Energy Spent Weekly
cycle: weekly
bathroom_lights_monthly_energy_spent:
unique_id: bathroom_lights_monthly_energy_spent
source: sensor.bathroom_lights_energy_spent
name: Bathroom Lights Energy Spent Monthly
cycle: monthly
#Meters for sensor.bedroom_heater
bedroom_heater_daily_energy_spent:
unique_id: bedroom_heater_daily_energy_spent
source: sensor.bedroom_heater_energy_spent
name: Bedroom Heater Energy Spent Daily
cycle: daily
bedroom_heater_weekly_energy_spent:
unique_id: bedroom_heater_weekly_energy_spent
source: sensor.bedroom_heater_energy_spent
name: Bedroom Heater Energy Spent Weekly
cycle: weekly
bedroom_heater_monthly_energy_spent:
unique_id: bedroom_heater_monthly_energy_spent
source: sensor.bedroom_heater_energy_spent
name: Bedroom Heater Energy Spent Monthly
cycle: monthly
After pasting the segments in the correct sections of the configuration.yaml
file (create them if they don’t exist), and restarting HA, a bunch of new sensors and meters will be created, than can be used freely on cards to display or plot the consumptions in the desired periods.
Not sure if this is useful for anyone else. If it is, let me know what you think. If it isn’t, at least now my template code is stored somewhere I won’t lose it.
[1] I can easily have overlooked some way of doing this, so if there is one, I’d love to use it instead of what I’m sharing here.