I have set up a number of energy monitoring sensors for various devices in the house - aircons, washing machine (from a zwave energy socket) etc. I do not have a whole house energy monitoring device, so adding these together is the closest I can get to seeing our power usage. The sensors show data in kWh, but I can only get a running total, which started some time ago.
Can anyone tell me how I can turn these into daily / monthly data to make them more user friendly ?
What I have at the moment is as follows:
# Calculate Total Air Con Energy Consumption
template:
- sensor:
name: "Total Air Con Energy Consumption"
unit_of_measurement: "kWh"
state: >
{% set kitchen = states('sensor.kitchen_air_conditioner_energy') | float %}
{% set dirtykitchen = states('sensor.dirty_kitchen_air_conditioner_energy') | float %}
{% set masterbedroom = states('sensor.master_bedroom_air_conditioner_energy') | float %}
{% set aldriansroom = states('sensor.aldrians_room_air_conditioner_energy') | float %}
{% set alexsroom = states('sensor.alexs_room_air_conditioner_energy') | float %}
{% set jacksroom = states('sensor.jacks_room_air_conditioner_energy') | float %}
{% set sabrinasroom = states('sensor.sabrinas_room_air_conditioner_energy') | float %}
{% set helpersroom = states('sensor.helpers_room_air_conditioner_energy') | float %}
{% set diningroom = states('sensor.dining_room_air_conditioner_energy') | float %}
{% set gym = states('sensor.gym_and_spa_air_conditioner_energy') | float %}
{% set cinema = states('sensor.home_theatre_air_conditioner_energy') | float %}
{% set mastercloset = states('sensor.master_closet_air_conditioner_energy') | float %}
{{ (kitchen + dirtykitchen + masterbedroom + aldriansroom + alexsroom + jacksroom + sabrinasroom + helpersroom + diningroom + gym + cinema + mastercloset) | round(1, default=0) }}
- sensor:
name: "Total Measurable Energy"
unit_of_measurement: "kWh"
state: >
{% set aircon = states('sensor.total_air_con_energy_consumption') | float %}
{% set kitchenfridge = states('sensor.kitchen_fridge_energy') | float %}
{% set dirtykitchenfridge = states('sensor.dirty_kitchen_fridge_energy') | float %}
{% set tumbledryer = states('sensor.tumble_dryer_energy') | float %}
{% set breadmaker = states('sensor.kitchen_breadmaker_energy') | float %}
{{ (aircon + kitchenfridge + dirtykitchenfridge + tumbledryer + breadmaker) | round(1, default=0) }}
Please note I am still learning as I go with HA, without any real IT knowledge
Thank you
Sorry a bit more info and another question.
Here is an example of one of the sensors:
state_class: total_increasing
unit_of_measurement: kWh
device_class: energy
friendly_name: Dirty Kitchen air conditioner energy
Not sure what I did but some have a state class of total_increasing and some just total. Can I just change the state class for all to be consistent (assuming I can find where to do this). A couple of the zwave sensors are causing a problem - not sure yet whether it is the fact that they have no unique id or something else
Have a look at the utility meter helper. You can feed it your energy sensor total, and define any reset cycle you want.
Note however you should include an availability template in your template sensor, otherwise you will see strange readings if one of your source sensors goes unavailable.
Calculate Total Air Con Energy Consumption
template:
- sensor:
name: "Total Air Con Energy Consumption"
unit_of_measurement: "kWh"
state: >
{% set kitchen = states('sensor.kitchen_air_conditioner_energy') | float %}
{% set dirtykitchen = states('sensor.dirty_kitchen_air_conditioner_energy') | float %}
{% set masterbedroom = states('sensor.master_bedroom_air_conditioner_energy') | float %}
{% set aldriansroom = states('sensor.aldrians_room_air_conditioner_energy') | float %}
{% set alexsroom = states('sensor.alexs_room_air_conditioner_energy') | float %}
{% set jacksroom = states('sensor.jacks_room_air_conditioner_energy') | float %}
{% set sabrinasroom = states('sensor.sabrinas_room_air_conditioner_energy') | float %}
{% set helpersroom = states('sensor.helpers_room_air_conditioner_energy') | float %}
{% set diningroom = states('sensor.dining_room_air_conditioner_energy') | float %}
{% set gym = states('sensor.gym_and_spa_air_conditioner_energy') | float %}
{% set cinema = states('sensor.home_theatre_air_conditioner_energy') | float %}
{% set mastercloset = states('sensor.master_closet_air_conditioner_energy') | float %}
{{ (kitchen + dirtykitchen + masterbedroom + aldriansroom + alexsroom + jacksroom + sabrinasroom + helpersroom + diningroom + gym + cinema + mastercloset) | round(1, default=0) }}
availability: >
{{ has_value('sensor.kitchen_air_conditioner_energy') and
has_value('sensor.dirty_kitchen_air_conditioner_energy') and
has_value('sensor.master_bedroom_air_conditioner_energy') and
has_value('sensor.aldrians_room_air_conditioner_energy') and
has_value('sensor.alexs_room_air_conditioner_energy') and
has_value('sensor.jacks_room_air_conditioner_energy') and
has_value('sensor.sabrinas_room_air_conditioner_energy') and
has_value('sensor.helpers_room_air_conditioner_energy') and
has_value('sensor.dining_room_air_conditioner_energy') and
has_value('sensor.gym_and_spa_air_conditioner_energy') and
has_value('sensor.home_theatre_air_conditioner_energy') and
has_value('sensor.master_closet_air_conditioner_energy') }}
Thank you Tom
Finally got back to this.
One (?) remaining problem is a bit odd.
I now have 9 Tuya based energy monitoring plugs, and have used the Tuya integration to bring them into HA (that may have been obvious from the previous post)
The problem is that for some, this works fine, but for a few, there is no device class - or at least it does not show up in the developer tools, and the Energy page says they have an “unexpected” device class.
I don’t think I did anything different when I set these up, although I could be wrong about that.
Is there a “fix” for the device class - and this may not be helped by the fact that the sensors do not have a unique id?
Thank you Tom
Still not quite there.
4 of the Tuya entities energy is still showing as unknown, and the total measurable energy is unavailable.
I am not able to add 3 of the entities to the energy dashboard (individual devices) - they just don’t show up as available devices to be added (strangely one was added, but gives 2 error messages:
statistics not defined
and
entity unavailable
Not sure what I can do to get those devices added, but honestly they are not a huge issue, as they currently often have nothing connected so consumption is tiny. So for now, I have removed them.
What I cannot figure out is why my total measurable energy remains unavailable. I assume I have made an error somewhere in the code, but cannot find it.
All the sensors (including the total air con) within the calculation appear to correctly record kWh (or at least they are recording something - it is just the total measurable which is unavailable.
Can you see where I am still going wrong?
template:
- sensor:
name: "Total Air Con Energy Consumption"
unit_of_measurement: "kWh"
state: >
{% set kitchen = states('sensor.kitchen_air_conditioner_energy') | float %}
{% set dirtykitchen = states('sensor.dirty_kitchen_air_conditioner_energy') | float %}
{% set masterbedroom = states('sensor.master_bedroom_air_conditioner_energy') | float %}
{% set aldriansroom = states('sensor.aldrians_room_air_conditioner_energy') | float %}
{% set alexsroom = states('sensor.alexs_room_air_conditioner_energy') | float %}
{% set jacksroom = states('sensor.jacks_room_air_conditioner_energy') | float %}
{% set sabrinasroom = states('sensor.sabrinas_room_air_conditioner_energy') | float %}
{% set helpersroom = states('sensor.helpers_room_air_conditioner_energy') | float %}
{% set diningroom = states('sensor.dining_room_air_conditioner_energy') | float %}
{% set gym = states('sensor.gym_and_spa_air_conditioner_energy') | float %}
{% set cinema = states('sensor.home_theatre_air_conditioner_energy') | float %}
{% set mastercloset = states('sensor.master_closet_air_conditioner_energy') | float %}
{{ (kitchen + dirtykitchen + masterbedroom + aldriansroom + alexsroom + jacksroom + sabrinasroom + helpersroom + diningroom + gym + cinema + mastercloset) | round(1, default=0) }}
availability: >
{{ has_value('sensor.kitchen_air_conditioner_energy') and
has_value('sensor.dirty_kitchen_air_conditioner_energy') and
has_value('sensor.master_bedroom_air_conditioner_energy') and
has_value('sensor.aldrians_room_air_conditioner_energy') and
has_value('sensor.alexs_room_air_conditioner_energy') and
has_value('sensor.jacks_room_air_conditioner_energy') and
has_value('sensor.sabrinas_room_air_conditioner_energy') and
has_value('sensor.helpers_room_air_conditioner_energy') and
has_value('sensor.dining_room_air_conditioner_energy') and
has_value('sensor.gym_and_spa_air_conditioner_energy') and
has_value('sensor.home_theatre_air_conditioner_energy') and
has_value('sensor.master_closet_air_conditioner_energy') }}
- sensor:
name: "Total Measurable Energy"
unit_of_measurement: "kWh"
state: >
{% set aircon = states('sensor.total_air_con_energy_consumption') | float %}
{% set kitchenfridge = states('sensor.kitchen_fridge_energy') | float %}
{% set dirtykitchenfridge = states('sensor.dirty_kitchen_fridge_energy') | float %}
{% set tumbledryer = states('sensor.tumble_dryer_energy') | float %}
{% set breadmaker = states('sensor.kitchen_breadmaker_energy') | float %}
{% set washingmachine = states('sensor.washing_machine_energy') | float %}
{{ (aircon + kitchenfridge + dirtykitchenfridge + tumbledryer + washingmachine + breadmaker) | round(1, default=0) }}
availability: >
{{ has_value('sensor.total_air_con_energy_consumption') and
has_value('sensor.kitchen_fridge_energy') and
has_value('sensor.dirty_kitchen_fridge_energy') and
has_value('sensor.kitchen_breadmaker_energy') and
has_value('sensor.washing_machine_energy') and
has_value('sensor.tumble_dryer_energy') }}