Roof Heat Strip Automation help

HA rookie here again.

Q1: I’m working on an automation that turns roof heat strips on between 10 and 40 degrees F, and off when the temperature is outside that range. I’m using an input_boolean (snow on roof) to enable and disable the automation as a condition. I want to be able to change the boolean state to turn on and off the automation. I have this working, but if the current temperature is inside the range - between 10 and 40 degrees, the automation doesn’t appear to trigger until I go outside the range and come back. What I want - when the boolean gets turned on I want that automation to trigger and act if the temperature is already inside the range of the trigger. Is there a way to do that?

Q2: Since I’ll probably have more than one automation that uses these below and above temperature set points, I’d like to make them input_number values and use them in the automations. I’m using the automation GUI to create them and am not clear on how to replace my current values of 10 and 40 with input_number.roof_heat_strip_min_temperature and input_number.roof_heat_strip_max_temperature? I would love to see some examples.

You didn’t share any of the automations you’ve got, which makes it rather hard to help :wink:

  1. Have the automation triggered by the boolean turning on, and a condition check of the temperature range
  2. That would be a template trigger not a numeric state trigger

Sorry, here’s the yaml the GUI created. (Is there a better way to get the yaml from the GUI?) I’ve been testing so the temp set points are higher.

I think my problem is assuming that when the temperature changes, and it’s within the above/below limits, this automation should receive and event. I don’t think that’s happening and I can understand why things might work that way.

Another way I think I might be able to do it - an automation that receives an event every time the temperature changes, and use conditions to check to see if the temperature is within a range to act.

I also don’t want to hard-code the above/below limits and want to use numeric helpers instead.

- id: '1591832642397'
  alias: Roof Strips On
  description: ''
  trigger:
  - above: 70
    below: 80
    device_id: 0c3b908409494df28f8ea4ea9438116c
    domain: sensor
    entity_id: sensor.garage_outdoor_temperature
    platform: device
    type: value
  condition:
  - condition: state
    entity_id: input_boolean.snow_on_roof
    state: 'on'
  action:
  - device_id: ee841be4c3a54b39830970b88564edd5
    domain: switch
    entity_id: switch.jasco_products_28169_plug_in_one_outlet_smart_switch_switch
    type: turn_on

Maybe I need a time_pattern trigger for this? Every 5 minutes check the temperature value. If within limits and snow and roof then turn on strips.

Simple:

- id: '1591832642397'
  alias: Roof Strips On
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.snow_on_roof
    to: 'on'
  - platform: template
    value_template: >-
      {{ states('input_number.roof_heat_strip_min_temperature')|int < states('sensor.garage_outdoor_temperature')|int < states('input_number.roof_heat_strip_max_temperature')|int }}
  condition:
  - condition: state
    entity_id: input_boolean.snow_on_roof
    state: 'on'
  - condition: template
    value_template: >-
      {{ states('input_number.roof_heat_strip_min_temperature')|int < states('sensor.garage_outdoor_temperature')|int < states('input_number.roof_heat_strip_max_temperature')|int }}
  action:
  - device_id: ee841be4c3a54b39830970b88564edd5
    domain: switch
    entity_id: switch.jasco_products_28169_plug_in_one_outlet_smart_switch_switch
    type: turn_on

Trigger when either:

  • Boolean turns on
  • Temperature is between the values in the input_numbers

Conditions require that both:

  • Boolean is on
  • Temperature is between the values in the input_numbers
1 Like

Or even:

- id: '1591832642397'
  alias: Roof Strips On
  description: ''
  trigger:
  - platform: template
    value_template: >
      {% set min_temp = states('input_number.roof_heat_strip_min_temperature')|float %}
      {% set max_temp = states('input_number.roof_heat_strip_max_temperature')|float %}
      {% set temp = states('sensor.garage_outdoor_temperature')|float %}
      {{ min_temp <= temp <= max_temp and
         is_state('input_boolean.snow_on_roof', 'on') }}
  action:
  - device_id: ee841be4c3a54b39830970b88564edd5
    domain: switch
    entity_id: switch.jasco_products_28169_plug_in_one_outlet_smart_switch_switch
    type: turn_on
1 Like

Wow! I tried both those solutions and they both worked great! My biggest stumbling block was trying to figure out how to correctly enter the value_templates via the GUI automation editor.

Thanks for this - really helped!