07-18-2023 10:06 AM
I was looking for a way for a routine to have different set of actions based on if a condition is true or false. To be more specific, for a custom voice command I would prefer one set of action to occur before after sunset and before sunrise, whereas, after sunrise and before sunset, only a part of action set needs to be activated. I did a lot of searches and could not find a solution for this. The condition only controls if the actions need to happen or not, but does not assign an alternate action. Is there a way this can be done?
In the below example, I have scripted for night condition. But, as we can see, I would not need the lights to be on if it is day time, but have my TV and Home Theatre to turn on.
metadata:
name: Movie Mode
description: Adjust Home Devices for Watching Movie
automations:
starters:
- type: assistant.event.OkGoogle
eventData: query
is: Movie Mode
- type: assistant.event.OkGoogle
eventData: query
is: Movie Time
condition:
type: time.between
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
before: sunrise+15min
after: sunset-15min
weekdays:
- MON
- TUE
- WED
- THU
- FRI
- SAT
- SUN
actions:
- type: device.command.OnOff
on: true
devices: Dining Side Lights - Living Room
- type: time.delay
for: 3sec
- type: device.command.OnOff
on: false
devices: TV Side Lights - Living Room
- type: device.command.OnOff
on: true
devices: TV - Living Room
- type: device.command.OnOff
on: true
devices: Home Theatre - Living Room
- type: time.delay
# Adjust duration as needed. Supported units: sec, min, hour
for: 30sec
- type: device.command.BrightnessAbsolute
brightness: 10
devices:
- Dining Side Bulb 1 - Living Room
- Dining Side Bulb 2 - Living Room
- Dining Side Bulb 3 - Living Room
- type: time.delay
for: 3sec
- type: device.command.ColorAbsolute
color:
spectrumRGB: 00bfff
devices:
- Dining Side Bulb 1 - Living Room
- Dining Side Bulb 2 - Living Room
- Dining Side Bulb 3 - Living Room
07-19-2023 09:37 AM
That "condition: type: time.between" It doesn't work for me, I've tried it in several routines but it doesn't work. 😭
Does it work perfectly for you?
07-19-2023 10:06 AM
Hi there... Yes, it does seem to work ok. But, there are times (not so often) when the automation skips some actions or even fail to do anything at all. I have no idea why that happens or how it is resolved. I believe you situation must be something like this.
07-19-2023 12:11 PM
My routines with this condition don't work at all, I don't know if this bug my account is Brazilian.
07-19-2023 09:40 PM
Have you assigned home location in you home app? I have come across articles where it states that time based routines fail to work unless the location is assigned, which actually makes sense.
07-20-2023 04:44 AM
**bleep** it worked, my address was disabled so it wasn't working.. thanks for the help there, it was complicated not having this function in the routines.
07-20-2023 04:54 AM
That's great!!!