Automation Based on Local Weather

Hey everyone,

Pretty new to HA and have been getting stuck trying to figure out how to set up a specific automation. Basically i’m looking to trigger some device actions and scripts at 7:00 AM if the outdoor temperature is over 70 degrees. Any help would be appreciated!

Hey Corey,

pretty straightforward:

Add an automation, choose “Time” as trigger.
Trigger: Time
Time: 07:00:00

Then, add a condition, so that the automation only executes the action when the condition is met:
Condition: Numeric state
Entity: (your temperature sensor)
Above: 70

Then add the actions.

If you don’t have a temperature sensor, you can get one pretty cheap, or you can use some cloud integration like (might already be active)
Since this gives you a weather object, you need to extract the temperature from the attributes.
Sounds harder than it is!
For your automation condition, choose the weather provider as the entity (like weather.home)
Again, use Above: 70
Now you need a value template to get the temperature out of the weather entity:
{{ state_attr('weather.home', 'temperature') }}

1 Like

What weather platform are you using? It think many of the weather platforms provide the temperature as an attribute of the main entity.

  - alias: "Example automation"
      platform: time
      at: '07:00'
      - condition: template
        value_template: "{{state_attr('weather.dark_sky','temperature') >70}}"
      - service: switch.turn_on
        entity_id: switch.exampleswtich

The above has a trigger every day at 7:00 a.m.

It then checks the condition to ensure the temperature is above 70. If its above it will continue to the action, if below it stops the automation.

The action then turns on a switch with entity_id switch.exampleswitch

You will need to adjust the above to work with your weather platform and the actual action you want to take place.

The dev tools are super helpful in looking at your entity IDs and the assoiated attributes. You can also test templates real time to ensure they work correctly and render the correct output. True = proceed with the action; False = stop on the output of a template in a condition.

The docs on automations are also worth a read.

Be aware that dark sky will shut down soon, so you might want to use something else :slight_smile:

Thanks for the quick reply! The value template part was where I was getting stuck. Let me know if this all looks right to you:

The only change I made to what you had was just updating the name of the weather entity.

Looks beautiful (other than the light theme :crazy_face:)
Yes, you needed to change the Entity, that’s right :slight_smile:

As for the actions; you already said you’re fairly new here (welcome again!), so a small heads up for the actions, because you wrote about a device action:
Some physical devices won’t show up as a device.
Instead, please take a look at
For example, use the service “light.turn_on” to turn on a lamp, you can add parameters like the brightness if the device supports it. Take a look at the Developer Tools -> Services for the available ones. Also you might want to bookmark Integrations, there is a lot of great information there about each integration :slight_smile:
Have fun!

I’ve got about 18 months (December 2021). I haven’t found a replacement yet with the data I want and reliability that darksky has.

Yeah, sad that it gets taken down, still worthy of note though, don’t think building a lot of stuff on sth. that has a set expiry date is the best solution.

Ha okay awesome.

I’ve actually been learning a lot over the past week or so and I’ve gotten a lot of stuff set up outside of automations. I set up the rest of that automation and tested it and everything is working. Thanks again for all the help!