Just need some help with trying to tweak a template helper sensor I created to track status of my HVAC system based on ecobee status. The code I have current and seems to work fine is:
{% set attributes = state_attr('climate.my_ecobee_4', 'equipment_running') %}
{% if 'heatPump2' in attributes %}
Heat Pump Stage 2
{% elif 'heatPump' in attributes %}
Heat Pump
{% elif 'auxHeat1' in attributes %}
Furnace Stage 1
{% elif 'auxHeat2' in attributes %}
Furnace Stage 2
{% elif 'compCool1' in attributes %}
Cooling Stage 1
{% elif 'compCool2' in attributes %}
Cooling Stage 2
{% elif 'fan' in attributes %}
Fan
{% else %}
Idle
{% endif %}
What I was to add to it is to track when the heat pump goes on defrost cycle. Based monitoring my supply air temperature using a sensor, I can see a dip in temperature while the unit is running on defrost and ecobee is still calling for heat and then after cycle completes the temperature rises again. How can I track the defrost by looking for this pattern and adding it the template sensor above. Below picture shows in red the temperature dips when defrost is running:
I was thinking tracking negative steep temperature drop trend followed by steep rise while ecobee status is heating (on heat pump) would be the way to identify when defrost cycle is running but I donāt know how to capture that in my template sensor. Any help with this would be really appreciated.
Thanks for the code and hint regarding the template sensor. Trying to create a template sensor that captures the steep temperature drop followed by a quick rise within a 10 to 30 minute window of a defrost cycle but having a hard time with the parameters for it. Any advice on what parameters would be ideal for the template based on the graph above?
I think I figured out the trend parameters that seems to be working to relatively quickly indicate when defrost is running and off, thank you for the help with the script syntax, really appreciate it.
One last question but itās less urgent, what do I need to add to the script to change icon based on the returned state?
I tried adding the following code in config yaml but got errors:
template:
- sensor:
- name: HVAC Status
state: >
{% set attributes = state_attr('climate.my_ecobee_4', 'equipment_running') %}
{% set falling = is_state('binary_sensor.hvac_supply_trend', 'on') %}
{% if 'heatPump2' in attributes and falling %}
Defrost - Heat Pump Stage 2
{% elif 'heatPump2' in attributes %}
Heat Pump Stage 2
{% elif 'heatPump' in attributes and falling %}
Defrost - Heat Pump
{% elif 'heatPump' in attributes %}
Heat Pump
{% elif 'auxHeat1' in attributes %}
Furnace Stage 1
{% elif 'auxHeat2' in attributes %}
Furnace Stage 2
{% elif 'compCool1' in attributes %}
Cooling
{% elif 'compCool2' in attributes %}
Cooling Stage 2
{% elif 'fan' in attributes %}
Fan
{% else %}
Idle
{% endif %}
icon: >
{% if is_state('sensor.hvac_status', 'Defrost - Heat Pump') %}
mdi:snowflake-melt
{% elif is_state('sensor.hvac_status', 'Heat Pump')
mdi:heat-pump-outline
{% elif is_state('sensor.hvac_status', 'Furnace Stage 1')
mdi:fire
{% elif is_state('sensor.hvac_status', 'Furnace Stage 2')
mdi:fire
{% elif is_state('sensor.hvac_status', 'Cooling')
mdi:air-conditioner
{% elif is_state('sensor.hvac_status', 'Fan')
mdi:fan
{% else %}
mdi:hvac-off
{% endif %}
The error I get when I reload home assistant is:
Invalid config for ātemplateā at configuration.yaml, line 53: invalid template (TemplateSyntaxError: expected token āend of statement blockā, got āmdiā) for dictionary value āsensor->0->stateā, got "{% set attributes = state_attr(āclimate.my_ecobee_4ā, āequipment_runningā) %}\n {% set falling = is_state(ābinary_sensor.hvac_supply_trendā, āonā) %}\n {% if āheatPump2ā in attributes and falling %}\n Defrost - Heat Pump Stage 2\n {% elif āheatPump2ā in attributes %}\n Heat Pump Stage 2\n {% elif āheatPumpā in attributes and falling %}\n Defrost - Heat Pump\n {% elif āheatPumpā in attributes %}\n Heat Pump\n {% elif āauxHeat1ā in attributes %}\n Furnace Stage 1\n {% eliā¦
And Please take a look at your ālastā template ! , This is one other reason reason not to start NEW question in a Topic which are solved ! , we are filling the topic with bullocks
Well initial question was resolved so I had marked it as such based on your request above. I should have split the second question to another post. I appreciate your guidance, got it working with below:
template:
- sensor:
- name: HVAC Status
state: >
{% set attributes = state_attr('climate.my_ecobee_4', 'equipment_running') %}
{% set falling = is_state('binary_sensor.hvac_supply_trend', 'on') %}
{% if 'heatPump2' in attributes and falling %}
Defrost - Heat Pump Stage 2
{% elif 'heatPump2' in attributes %}
Heat Pump Stage 2
{% elif 'heatPump' in attributes and falling %}
Defrost - Heat Pump
{% elif 'heatPump' in attributes %}
Heat Pump
{% elif 'auxHeat1' in attributes %}
Furnace Stage 1
{% elif 'auxHeat2' in attributes %}
Furnace Stage 2
{% elif 'compCool1' in attributes %}
Cooling
{% elif 'compCool2' in attributes %}
Cooling Stage 2
{% elif 'fan' in attributes %}
Fan
{% else %}
Idle
{% endif %}
icon: >-
{% if is_state('sensor.hvac_status', 'Heat Pump')%} mdi:heat-pump-outline
{% elif is_state('sensor.hvac_status', 'Defrost - Heat Pump')%} mdi:snowflake-melt
{% elif is_state('sensor.hvac_status', 'Furnace Stage 1')%} mdi:fire
{% elif is_state('sensor.hvac_status', 'Furnace Stage 2')%} mdi:fire-circle
{% elif is_state('sensor.hvac_status', 'Cooling')%} mdi:air-conditioner
{% elif is_state('sensor.hvac_status', 'Fan')%} mdi:fan
{% else %} mdi:hvac-off {% endif %}