#Hi all, I have been trying to get some

1 messages · Page 1 of 1 (latest)

atomic flint
#

I thought something like this would work but I am getting errors about device attribute sate, I need to figure out what states the device cn be in I guess:

alias: Humidity and Temperature Control for Heater
description: Control heater based on humidity and temperature conditions
trigger:
  - platform: state
    entity_id: switch.outlet_grow_light_switch
condition:
  - condition: template
    value_template: >
      {% if trigger.to_state.state == 'on' %}
        {{ states('sensor.lower_environment_humidity_sensor') | float > 60 and states('sensor.upper_environment_temperature_sensor') | float < 80 }}
      {% elif trigger.to_state.state == 'off' %}
        {{ states('sensor.lower_environment_humidity_sensor') | float > 50 and states('sensor.upper_environment_temperature_sensor') | float < 70 }}
      {% endif %}
action:
  - service_template: >
      {% if trigger.to_state.state == 'on' %}
        switch.turn_on
      {% elif trigger.to_state.state == 'off' %}
        switch.turn_off
      {% endif %}
    entity_id: switch.outlet_heater_switch
sleek spruce
#

You’ll also want to reconsider the logic in the automation. Currently it will only trigger when the switch changes state, and it will decide what to do based on the temperature at that moment. If you want to prevent temperatures from getting too hot or too cold, you need to add additional triggers for when that happens. Numeric state triggers would be appropriate.

#

My final suggestion is to use the logic blocks available in automations rather than stuffing everything into a single, difficult to follow and difficult to debug template condition. I would use a choose action, and you can list separate conditions for the first option, with the action being to turn on the switch. Then you can have the second choose option have a bunch more conditions with the action being to turn the switch off.

atomic flint
#

@sleek spruce thanks