I am attempting to create a sensor that acts as a time accumulator for when my Mysa baseboard thermostats turn on - sadly despite the manufacturer tracking this they don’t make it available over the Homekit integration .
I found this topic that seems to offer a straightforward means of doing so.
What I did:
I create my own series of template sensors to go in sensors.yaml
according to the linked thread.
I also verified that value_template are pulling heating/none/idle for each thermostat.
Template sensors:
### Heating time tracking ###
# TODO: Integrate with utilitiy meter integration
# refs:
# https://community.home-assistant.io/t/sensor-for-how-long-was-heating-on-today/343701/2
# https://www.home-assistant.io/integrations/utility_meter/
# Upstairs Bedroom
- platform: template
sensors:
hvac_activity:
friendly_name: Upstairs Bedroom HVAC Activity
value_template: "{{ state_attr('climate.mysa_2087b4_thermostat', 'hvac_action') }}"
- platform: history_stats
name: Upstairs Bedroom Heating Time
entity_id: sensor.upstairs_bedroom_hvac_activity
state: 'heating'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
####################
# Dizz Office
- platform: template
sensors:
hvac_activity:
friendly_name: Dizz Office HVAC Activity
value_template: "{{ state_attr('climate.mysa_037b2c_thermostat', 'hvac_action') }}"
# template:
# - sensor:
# - name: Office HVAC Activity
# state: "{{ state_attr('climate.mysa_037b2c_thermostat', 'hvac_action') }}"
- platform: history_stats
name: Office Heating Time
entity_id: sensor.office_hvac_activity
state: 'heating'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
####################
# Living Room
- platform: template
sensors:
hvac_activity:
friendly_name: Living Room HVAC Activity
value_template: "{{ state_attr('climate.living_room', 'hvac_action') }}"
- platform: history_stats
name: Living Room Heating Time
entity_id: sensor.living_room_hvac_activity
state: 'heating'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
####################
Problem:
Only the top template works - as in it’s the only one that actually seems to be accumulating time. The other two while they exist as sensors are stuck at 0. I’ve let them run for 24 hours so they sound have accumulated something.
I cannot figure out why.
Additional Oddities:
-
The “new” template sensor syntax that is referenced in the thread just flat out does not work for me. It creates errors in the config file.
-
Despite having renamed all three thermostats to something friendlier it has only propagated to the living room thermostat for reasons I cannot determine.
If I inspect any of them in the Dev tools I can see that they have afriendly_name
set and yet theclimate.
entity only reflects that name for the living room thermostat.