Hello all,
I’m pleased to use Home assistant and I want to support this project as much as I use it.
I have been using automations on Hass.io but I discovered that under “conditions”, the “and” or “or” do not work properly. I tried many different options in order to find what could I be doing wrong but I wasn’t.
I want to use to mobile phones to be the condition (home or away) to notify if a door is open. If I’m at home I do not want to know if the door is open, only when I’m not at home.
Is there anyone with the same issue as me? If yes, did you found a solution?
- id: 'GGGGGGG'
alias: Notify garage door open
description:
trigger:
- type: opened
platform: device
device_id: UUUUUUU
entity_id: binary_sensor.window_door_sensor
domain: binary_sensor
condition:
- condition: or
conditions:
- condition: device
device_id: XXXXXXX
domain: device_tracker
entity_id: device_tracker.user1
type: is_not_home
- condition: device
device_id: YYYYYYY
domain: device_tracker
entity_id: device_tracker.User2
type: is_not_home
action:
- service: notify.notify
data:
message: Garage door is open and you are not there! Check cameras and close
the door.
- service: camera.record
data:
service: camera.record
data:
entity_id: camera.mjpeg_camera
filename: /media/my_stream.mp4
duration: 30
entity_id: camera.mjpeg_camera
mode: single
Could you please edit your post so that the pasted automation configuration is formatted correctly. See point 11 here: Help us help you. We should then be able to see what needs to be chaged.
Also just for your reference, it has not been called Hassio for over a year.
Now I can see, that you created a single OR condition and an additional condition which is not part of the OR sequence and therefore “AND’ed” with the result of the OR condition.
OR in other words: You need to indent the second condition to the same level, as the child of the OR condition, like this.
I see… It make sense. I just don’t know why the indent is wrong because I made the automation directly on Home Assistant and not on the YAML.
Let me try to correct the YAML and not using the browser version.
It’s easy to do that in the GUI… the different levels are a struggle. Made the same mistake myself… (after you edit the yaml check the GUI… I often use the GUI and then check the yaml)
by using the example from DavidFW1960, I realized that the GUI is puting two more spaces on the indent of the “or” and that is the reason why I couldn’t use the GUI for the “OR”. David, without your example I wouldn’t understand . By building the automation on the GUI and then going into the YAML to correct the indent then I manage to make it to work!!! Thank you all for the help!!
This means that the GUI is putting more spaces on the indent and this was driving me crazy! Can this be fixed on the next update?
The issue is you added the second condition in the wrong place on the GUI… it’s not the software doing it it’s you and as I said it’s easily done. (It wasn’t my example BTW but thanks)
A big thank you also to m0wlheld Christoph Dahlen. Only with your example I could see the right indent…
You are all the best!
I will keep trying to make more automations now that I know the right indent.