I have a sensor called sensor.total_energy_last_hour
that tells me how much total energy I used in the last hour (I also have sensors for yesterday, last week, and last month) that pulls data from my smart meter. Since the HVAC uses the most amount of energy but I currently have no way to monitor the hourly energy use I want to compare runtime of the HVAC cooling, HVAC fan and HVAC heating with total energy use. (I’ll add other devices later.)
I created sensor.hvac_action
so that I can tell when the HVAC is cooling, fan only, heating, or idle.
Due to a post here I am in the process of creating history stats sensors called Cooling On Today
, etc.
Then a sensor Cooling On Today Minutes
that converts it to minutes with {{ states('sensor.cooling_on_today') | float * 60 | round() }}
I plan on then creating a utility meter that tracks it at an hourly rate which will be called sensor.cooling_on_today_hourly
Then a sensor called that tracks the last hour called Cooling Last Hour
with {{ state_attr('sensor.cooling_on_today_hourly','last_period') | round (2) }}
Is there an easier way to do all of this or does this have to be this complicated? If I do all of this with all of my devices that I can track on
time for or kWh
then I will have a ton of sensors.
This is what I have so far for cooling. I’m still not sure that I should use all of those calculations to get the runtime of the HVAC in cooling mode.
sensor:
# based on https://community.home-assistant.io/t/hourly-history-stats/165022/6
- platform: history_stats
name: Heating On Today
entity_id: sensor.hvac_action
state: 'heating'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: history_stats
name: Cooling On Today
entity_id: sensor.hvac_action
state: 'cooling'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
template:
- sensor:
- name: Heating Minutes
unit_of_measurement: 'min'
state: "{{ states('sensor.heating_on_today') | float * 60 | round() }}"
- name: Cooling Minutes
unit_of_measurement: 'min'
state: "{{ states('sensor.cooling_on_today') | float * 60 | round() }}"
utility_meter:
#######Cooling Utility Meters#########
cooling_hourly:
source: sensor.cooling_minutes
cycle: hourly
cooling_daily:
source: sensor.cooling_minutes
cycle: daily
cooling_weekly:
source: sensor.cooling_minutes
cycle: weekly
cooling_monthly:
source: sensor.cooling_minutes
cycle: monthly
cooling_yearly:
source: sensor.cooling_minutes
cycle: yearly
template:
- sensor:
name: Cooling Minutes Last Hour
unit_of_measurement: 'min'
state: "{{ state_attr('sensor.cooling_hourly','last_period') }}"
name: Cooling Minutes Yesterday
unit_of_measurement: 'min'
state: "{{ state_attr('sensor.cooling_daily','last_period') }}"
name: Cooling Minutes Last Week
unit_of_measurement: 'min'
state: "{{ state_attr('sensor.cooling_weekly','last_period') }}"
name: Cooling Minutes Last Month
unit_of_measurement: 'min'
state: "{{ state_attr('sensor.cooling_monthly','last_period') }}"
name: Cooling Minutes This Year
unit_of_measurement: 'min'
state: "{{ states('sensor.cooling_yearly') }}"
name: Cooling Minutes Last Year
unit_of_measurement: 'min'
state: "{{ state_attr('sensor.cooling_yearly','last_period') }}"