Hello, all.
HASS automation logic looks like this: Trigger-Conditions-Action.
Is it possible to do Trigger-Action1-Conditions-Action2 (if conditions are met)?
Thanks!
Hello, all.
HASS automation logic looks like this: Trigger-Conditions-Action.
Is it possible to do Trigger-Action1-Conditions-Action2 (if conditions are met)?
Thanks!
Can you give a bit more details? What is it you’re looking to do. I’m a little confused. I think I kind of know what you’re asking but would be better to be sure before answering wrong. haha
Sure. I have a motion sensor. I would like it to broadcast a voice message via TTS every time it is triggered. I would also like to turn on a light if it is after sunset and before sunrise.
I’m thinking I need a service_template incorporating if/else statements, but I’m still trying to find out how to set the sun conditions in the template. In an automation I do it like this:
condition:
condition or:
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
I don’t know how to do this in a template. Before and After sunset do not seem to be attributes exposed by the sun component.
you can add conditions to the action sections of automations:
alias: foo
trigger:
- platform: state
entity_id: sensor.motion
to: 'on'
action:
- service: tts.google_say
data:
message: "Movement"
- condition or:
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
- service: light.turn_on
entity_id: light.my_night_light
Perfect! Thank you.