Hi
I’m trying to make an automation that sets the temperature to 21 degrees and turns on the lights.
BUT I wanted to add the condition ‘if sun has set’.
if I comment the ‘condition’ part out, it works. with, it doesn’t. (I would have supposed the ‘conditional’ part needs to be ‘indented’ but as it seems, if the condition fails the execution just stops?
What am I doing wrong?
- alias: Patrick gets home
trigger:
platform: state
entity_id: device_tracker.74d9cfd344074c4895ec693991a27d21
from: 'not_home'
to: 'home'
action:
- service: climate.set_temperature
data:
entity_id: climate.thermostat
temperature: 21
- condition:
condition: sun
after: sunset
- service: homeassistant.turn_on
entity_id:
- light.wohnzimmer
Thank you for your suggestion. But, if I’m not totally wrong, that does NOT do what I wanted.
I want to turn up the heating, regardless of the state of the sun, BUT only switch on the lights when after sunset. Would it be better to just make two independant automations? Is that possible without problems?
Hm, I copied that from an examples page (see: Conditions - Home Assistant ‘sun condition’) But I was pretty sure I even tried it without condition: condition because I found it redundant, too. But as it seems I made another mistake then.
Thank you!
Oh, I’ve looked there, as well. Did look quite similar to the condition: condition: sun example, doesn’t it?
To be honest I don’t like the syntax of the config file of homeassisant at all. It’s not very intuitive - and Indention is fine, but it shouldn’t be part of the logic. But well, another problem solved, thank’s again.
I think the hair that’s being split is that after:sunset is an event (not a state). Something that works as a trigger (with event, not after) and only tests true for that moment. If you go to your states dev tool, you’ll see that sun.sun has states of “below_horizon” and “above_horizon”.
“After” is the way that time-based triggers are expressed. I’m not sure why “after” was chosen over “at”, but that’s consistent with other time-based triggers.