Hive Heating History Sensor

I am trying to setup a History Sensor so that I can monitor how long the heating is on for over the day.

I have added the following but I only seem to get data when state is set to “heat” - However this is just gives a value of 24 hours so assume must be the default state. Does anyone know what the state should be set to to monitor when the heating is on?

History

sensor:

  • platform: history_stats
    name: Heating On Today
    entity_id: climate.receiver_1
    state: ‘On’
    type: time
    start: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    end: ‘{{ now() }}’
  • platform: history_stats
    name: Heating On Yesterday
    entity_id: climate.receiver_1
    state: ‘On’
    type: time
    end: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    duration:
    hours: 24

At first sight you are monitoring the ‘On’ state. Perhaps you could try replacing it with lowercase ‘on’?

I’m not sure climate controls have a simple on and off. If you go to developer tools you can find all the states and sensors for the climate entity.

Here is an example of all the values from my Ecobee. My “State” is just heat because I am in heat mode. I would have to build a template sensor for equipment running or something to decipher my climate sensor. I did this with my aux heat so I can track and alert when aux heat is running.

hvac_modes:
  - heat_cool
  - heat
  - cool
  - 'off'
min_temp: 45
max_temp: 95
fan_modes:
  - auto
  - 'on'
preset_modes:
  - Sleep
  - Fireplace
  - Home
  - Away
current_temperature: 70
temperature: 70
target_temp_high: null
target_temp_low: null
current_humidity: 40
fan_mode: auto
hvac_action: idle
preset_mode: Sleep
aux_heat: 'off'
fan: 'off'
climate_mode: Sleep
equipment_running: ''
fan_min_on_time: 20
friendly_name: Thermostat
supported_features: 91```

Thanks I checked via Developer tools when heating was on and can see hvac_action was set to ‘heating’

So have amended the config to:

sensor:

  • platform: history_stats
    name: Heating On Today
    entity_id: climate.receiver_1
    hvac_action: ‘heating’
    type: time
    start: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    end: ‘{{ now() }}’
  • platform: history_stats
    name: Heating On Yesterday
    entity_id: climate.receiver_1
    hvac_action: ‘heating’
    type: time
    end: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    duration:
    hours: 24

But get following error:

Invalid config for [sensor.history_stats]: [hvac_action] is an invalid option for [sensor.history_stats]. Check: sensor.history_stats->hvac_action. (See ?, line ?).
Invalid config for [sensor.history_stats]: [hvac_action] is an invalid option for [sensor.history_stats]. Check: sensor.history_stats->hvac_action. (See ?, line ?).

Took a bit of time but got it working. Just need to work out how I can automate emailing of the history graphs now…

binary_sensor:

  • platform: template
    sensors:
    heating_on:
    friendly_name: “Heating On”
    value_template: >-
    {%- if is_state_attr(‘climate.receiver_1’, ‘hvac_action’, ‘heating’) %}
    on
    {%- endif %}

Example configuration.yaml entry

hive:
username: xxxxxxxxxxxxx
password: xxxxxxxxxxxxx
# History
sensor:

  • platform: history_stats
    name: Heating On Today
    entity_id: binary_sensor.heating_on
    state: ‘on’
    type: time
    start: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    end: ‘{{ now() }}’
  • platform: history_stats
    name: Heating On Yesterday
    entity_id: binary_sensor.heating_on
    state: ‘on’
    type: time
    end: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    duration:
    hours: 24
  • platform: history_stats
    name: Heating On This Week
    entity_id: binary_sensor.heating_on
    state: ‘on’
    type: time
    start: ‘{{ as_timestamp( now().replace(hour=0, minute=0, second=0) ) - now().weekday() * 86400 }}’
    end: ‘{{ now() }}’