How to automate based on weather temperature forecast?

I am trying to set up a Roof Heater and would like my switch to turn on If it is below 32 and anything but sunny and turn off if it’s above 32.

If above 32 - Turn off
If below 32 and not sunny - Turn on

Is anyone able to help?

What are the entity_ids of your sensors that report outdoor temperature and weather condition?

Sorry, I’m new I wasn’t planning on using a sensor. I currny have the weather on the HA by using a add on “weather forecast from met.no”. Was thinking there is something built in like that

I am using this to check if it’s neccessarry to switch on the heater at home:

alias: "Energie: Heizung sinnvoll?"
description: ""
trigger:
  - platform: time
    at: "19:15:00"
condition:
  - condition: state
    entity_id: group.persons
    state: home
  - condition: state
    entity_id: input_boolean.nightmode
    state: "off"
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.netatmo_telemann_telatmo_temperature
        below: 19
      - condition:
          - condition: template
            value_template: "{{ state_attr('weather.homer','forecast')[1].templow <= 0 }}"
    then:
      - service: telegram_bot.send_message
        data:
          message: >-
            Es gibt morgen Frost
            ({{states.weather.homer.attributes.forecast.1.templow}}°C) und das
            Wohnzimmer ist unter 19 Grad. Vielleicht ist die Zeit gekommen die
            Heizung zu bemühen.
mode: single

the crucial part you are looking for is this:

- condition:
          - condition: template
            value_template: "{{ state_attr('weather.homer','forecast')[1].templow <= 0 }}"

Modified to match your requirements (actual temperature):

- condition:
          - condition: template
            value_template: "{{ states.weather.homer.attributes.temperature }}"

You just need to replace your host name. Just look for your weather entity like weather...

it works, but it’s not shown in the UI (just works in yaml mode), because templates are somehow not accepted in theconditions.

I hope it helps

1 Like