I would like to run an automation that triggers when weather.home is NOT sunny. Doesn’t seem like not_sunny works. Do I need then to add all weather conditions (other than sunny) as separate triggers?
Unfortunately you can’t specify not_state
in a trigger since the trigger fires upon state change. Using the following might be an option:
trigger:
platform: state
entity_id: weather.home
from: 'sunny'
This would trigger each time the weather changes from sunny to anything else. Or you could define a different trigger and use something like this in the conditions section:
condition:
condition: template
value_template: "{{ states('weather.home') != sunny }}"
This would fire your automation when the trigger happens, but only if the weather isn’t sunny.
Edit: I’m not familiar with the weather.home platform, so I’m just assuming that it reports a state of whatever the weather conditions are.
I think Dark Sky weather might be better for your needs. It has many sensors, and they report a ton of things. Cloudy is one, overcast another I think.
I have a automation that kicks off when rain is in my area.
Here are some of the sensors. You can have less or more depending on your config setup.
Thank you. I’ll give the template method a try.
Thanks for the recommendation. I do use Dark Sky on my Android, but the issue here is triggering when not sunny, and I don’t recall Dark Sky has such a sensor.
There’s clear, which then can change to rain, cloudy, etc, but I don’t think there is a sunny one in particular.
Here’s the conditions in the docs if you decide to give it a try.
I suppose I could use Dark Sky not clear setup as Tediore outlined.
How does this look:
- id: '1568215438285'
alias: Weather-Not Sunny
trigger:
- platform: template
value_template: '"{{ states(''weather.home'') != sunny }}"'
condition:
- condition: state
entity_id: sun.sun
state: above_horizon
action:
- condition: state
entity_id: light.living_room_shelf_lamp
state: 'on'
Don’t think that would work unfortunately. Now that I think about it, this might work:
trigger:
platform: template
value_template: >
{% if states('weather.home') != sunny %}
true
{% endif %}
I think this would evaluate each weather.home state change and return true
if it isn’t sunny, which would then fire the automation. Not sure though, I haven’t used templates as a trigger before, only as a condition.
I’ll give it a try; I’ll add a notify Action to visualize results.