1st, the initial post, as I said, was just to illustrate that the HA Gui is adding extra quotes when I add ‘’ or “” around the time, screwing it up. This is cut directly from the automation.yaml, except I didn’t include the first line, just an oversight. There is no hand coded elements. I was trying to show that no matter how I enter the time in the for field, it’s erroring. I did none, single and double in one automation just to show what it looks like in the automation.yaml.
2nd, the condition of the sun being down is because the lights shouldn’t be turned on during the day. I simply included the same condition for turning them off. If I turn them on during the day for some reason, I’d not want them to turn off in the automation. Just a time limiter for the automation.
As Olen suggested, I’m now using groups, which I’ll post below. Using groups seems to work better, but needs more testing of scenarios. What I’m looking to do is turn on the lights if it’s dark and I open a door. Some times I approach from the back yard and it’s dark, so also turn on the lights. Or, I leave through the door to take dogs out. If I’m out too long, the lights shut off, so turn them back on when I approach. Finally, shut off the lights when all the doors have been closed for 5 min AND when no motion has been detected for 5 min. I actually have a camera in the back yard, so I was hoping me moving around back there would keep the lights on. Again, I need more testing.
Here is the new automation.yaml for using groups for turning the lights on and off based on motion and doors.
- id: '1601330898887'
alias: TEST - Groups - On
description: ''
trigger:
- entity_id: group.back_deck_motion
from: 'off'
platform: state
to: 'on'
- entity_id: group.back_deck_doors
from: 'off'
platform: state
to: 'on'
condition: []
action:
- device_id: 386aaaa1642f4c229bf626189699fd87
domain: light
entity_id: light.ls_master_bedroom_patio
type: turn_on
mode: single
- id: '1601340142667'
alias: TEST - Group - Off
description: ''
trigger:
- entity_id: group.back_deck_motion
for: 00:02:00
from: 'on'
platform: state
to: 'off'
- entity_id: group.back_deck_doors
for: 00:02:00
from: 'on'
platform: state
to: 'off'
condition:
- condition: state
entity_id: group.back_deck_motion
state: 'off'
- condition: state
entity_id: group.back_deck_doors
state: 'off'
action:
- device_id: 386aaaa1642f4c229bf626189699fd87
domain: light
entity_id: light.ls_master_bedroom_patio
type: turn_off
mode: single
This seems to be working, but I’m still testing. Right now, I don’t have any quotes around the time, and I’m also not getting errors about the format. Odd, as what made me go down the quote track was the error saying I needed to follow the format.
I hope I’ve explained this well enough.
In WebCore, I’d simply say if:
IF door1 AND door2 AND door3 are ALL closed AND
motion1 AND motion2 AND motion3 have no motion THEN
turn off light
I can’t see directly how to do this in HA.