If you want your automation to only run in the morning or evening, that won’t work the way you’ve written it.
Also remember that conditions are and by default so you’ll only really need to specify and and condition if you’ve specified an or condition first.
You have some weird single quotes. Make sure you use standard single quotes and avoid copying from web pages unless the code was correctly formatted.
Last but not least, watch your indentations. This is critical in yaml.
condition:
- condition: state
entity_id: 'device_tracker.al_iphone'
state: "home"
- condition: or
conditions:
- condition: and
conditions:
- condition: time
after: '09:00:00'
- condition: time
before: '12:00:00'
- condition: and
conditions:
- condition: time
after: '17:00:00'
- condition: time
before: '19:20:00'
Have you checked your indentations? That’s probably what’s wrong.
Just double checked with a couple of online yaml checkers and got no errors
In your original code there were several indentation issues for the whole condition: block
Looking for similar assistance. I have several fire tablets around the house that we use as HA dashboards and for live camera feeds. I have multiple cameras and I am trying to get this script/automation to work correctly so that if multiple sensors/cameras are triggered that my “Index” Camera feed pops up which shows all the cameras. I have the individual cameras working correctly at this time.
The time a camera sensor is triggered for is 10 seconds, I can increase this. However my goal would be if a camera is triggered inside of 3 minutes of each other to show the “Index” All Camera feed. I need help with the time formatting on this as well.
Does this look correct for what I am attempting to accomplish?
############################# Multi Sensor Triggered ########################
- alias: Multi Sensor Triggered
trigger:
platform: state
entity_id: binary_sensor.mqtt_front_door_motion
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.mqtt_gate_camera_motion
state: "on"
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.mqtt_car_garage_door_motion
state: "on"
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.mqtt_driveway_camera_motion
state: "on"
action:
- service: homeassistant.turn_on
entity_id: script.multisensorimage
- service: homeassistant.turn_on
entity_id: script.motion_cameras_alexa
- service: homeassistant.turn_on
entity_id: script.camerasmotionlr
- service: homeassistant.turn_on
entity_id: script.camerasmotionbr
- service: homeassistant.turn_on
entity_id: script.camerasmotionmini
id: d52c6fb9c7c046ab86e13cc99f184ff92
############################# Multi Sensor Triggered ######################## ##
Conditions are “and” by default so you don’t need the initial and block
For each or block you’d need to get your indentation right
What is the logic that you’re after?
Do you want your automaton to run when mqtt_front_door_motion turns on AND any of the binary sensors in he above condition block is on?
I have a multi camera system and I am after a solution where if more than one sensor is triggered within 30 seconds that a different feed that includes all of my cameras (Index) displays up on my tablets.
Currently I have it set where if one of the various cameras is triggered the live feed will display on all my home tablets for 3 minutes, 3 minutes without motion it will return the Home Assistant Dashboard. Actual examples below.
####Motion Front Door
- alias: FD Motionn
trigger:
platform: state
entity_id: binary_sensor.ring_front_door_motion
to: 'on'
action:
- service: homeassistant.turn_on
entity_id: script.fdimage
- service: homeassistant.turn_on
entity_id: script.motion_fd_alexa
- service: homeassistant.turn_on
entity_id: script.fdmotionlr
- service: homeassistant.turn_on
entity_id: script.fdmotionbr
- service: homeassistant.turn_on
entity_id: script.fdmotionmini
###Return to dashboard#####
- alias: All Camera Motion Off
trigger:
platform: state
entity_id: group.camera_sensors
to: 'off'
for:
minutes: 3
action:
- service: display.load_url
entity_id: group.all_fully
data:
url: http://192.168.87.xx:8123/lovelace/Tablet
I want to include this previous logic so if one camera sensor is set off that that individual display pops up, but if multiple sensors are triggered within 30 seconds to display a different URL to all my tablets.
It’s a little bit complex what you’re after
This what what I’d do:
Change the trigger to not be the group, but each camera:
trigger:
platform: state
entity_id: binary_sensor.ring_front_door_motion, binary_sensor.ring_back_door_motion, binary_sensor.ring_side_door_motion, etc
to: 'on'
For the life of me I can’t find the case/switch condition so for now I’d do something along those lines:
Please note this is totally untested, but hopefully sets you on the “right” path (right in quotes as I’m sure some bright spark will come up with something better).