So as the title says, I am trying to template my automation trigger to start when a particular device, or group of devices arrive at home - based on an input_select on my front end. This would eventually trigger my vaporizer to start when one or both of us come home - based on who filled the device and is feeling in the mood.
I have been playing with this for the last few days and can’t seem to get it to work. Any help would be greatly appreciated.
This is what I have so far for the automation trigger:
Yeah, that’s not going to work. A template trigger needs to evaluate to true/false.
It would be better to just trigger on all of the devices and have a condition check if they are all home.
- alias: "au_Arizer_Balloon_Fill"
trigger:
# Trigger on all devices
platform: state
entity_id:
- device_tracker.sdg_iphone
- device_tracker.gabs_droid
to: 'home'
condition:
# Now compare the devices home to those in the input select
condition: template
value_template: >
{% set v = state('input_select.vape_select') %}
{% set g = is_state('device_tracker.gabs_droid', 'home') %}
{% set s = is_state('device_tracker.sdg_iphone', 'home') %}
{% if v == 'Both' %} {{ g and s }}
{% elif v == 'Gab' %} {{ g }}
{% elif v == 'Stiofán' %} {{ s }}
{% else %} False
{% endif %}
action:
...
Hmmmmm, the 'input_select.vape_select' should define which one the automation seeks to detect - rather than who’s home or not. I’m still trying to wrap my head around the automation actually. Your code is a seriously good start for me though. I wouldn’t have come up with that in years.
It does that. But the trigger is what was messing you up.
this does the same thing whenever any phone comes home. It looks at the input select to see if the person(s) in the select are home.
But, as is, there is no redundancy checking. So if g is already home and the automation already ran, then you came home, it would run again because it’s only looking to see if Gab is home when the trigger happens.
I would just add another condition. Like, make sure the switch is off. If it’s already on, don’t do anything.