In my morning script, I would like the below automation to be turned off if at least one of us is home. I cited the individual trackers and a group I’ve created…not sure which would be usable in this. How may I piece this together?
- service: automation.turn_off
entity_id: automation.office_motion
{% if is_state ("device_tracker.life360_scott", "home") %}
{% if is_state ("device_tracker.life360_2", "home") %}
GROUP:
people_family:
name: Family
entities:
- device_tracker.life360_scott
- device_tracker.life360_2
I’d be inclined to use conditions in the automation to not perform the action rather than turning the automation off. Are you intending to re-enable the automation every day? Conditions are much better…
Why would you find conditions better? No concern about whether it’s on our not? The extra processing is not worth worrying about?
Edit: My problem adding conditions is have a Sleep script that is manually activated. This means I would probably need to use a variable, but have had difficulty in understanding the process.
Okay, though I would need to use a variable and I have not had success in integrating them. Here’s what I need…
I manually execute both a sleep script and a wake script. I would need the automation contingent upon which script was executed and the only thing I can see would be setting a variable within each of those scripts, then set a condition for the variable. I cannot figure out how to do this.
Scott I think we’re having a hard time following what you’re trying to do here. You’ve thrown a couple of things out there that don’t seem to be related to your first question. If you were clearer about what you are trying to do you’ll probably get the answer you’re looking for.
Can you explain in english (not code) exactly what you’re trying to accomplish?
My original Q was answered, though the idea of using conditions was mentioned. I’ll try to explain again what I’m trying to do…
I would like my Office Motion Automation to only run when a) everyone is away from home, and/or b) during bedtime.
I have a script called Sleep that is manually executed at bedtime. This is accomplished via NFC tag/Tasker/HA script. I also manually execute a script called wake every morning.
Tom helped with Everyone Away, however, the only way I see getting this to work with conditions for bedtime is to use a variable.
Personally I’d use an input_select to control a Home / Night / Away mode state.
When everyone is gone, change the input select to Away
When someone comes home change it to Home.
In your wake script change it to Home
In your sleep script change it to Night.
Then in your office motion automation the only thing have to do is use the following condition which will only let your automation run in Away mode. You also don’t have to worry about turning the automation on or off.
condition:
- condition: state
entity_id: input_select.house_mode
state: 'Away'
Once you get more things going you’ll probably also find other uses for that input_select.
ADDED TO AUTOMATION:
- service: input_select.select_option
data:
entity_id: input_select.home
option: Home
ADDED TO WAKE SCRIPT:
- condition: state
entity_id: group.people_family
state: 'home'
- service: input_select.select_option
data:
entity_id: input_select.sleep
option: Wake
Couple questions about this…
a) Do input_selection(s) survive HA reboots?
b) how do I test for input_selection in HA? I cannot find anything in Dev Tools or the logbook.
Edit: I use this condition set in my Office Motion Automation:
condition:
condition: or
conditions:
- condition: state
entity_id: input_select.home
state: 'Away'
- condition: state
entity_id: input_select.sleep
state: 'Sleep'