Good Afternoon, I am playing with the automation in my home assistant, I want to have it that if both mine and my wife;s phones are out of the house the music stops. I have it working that if her phone is gone and mine leaves it shuts off the music. Just did this by using a trigger on my phone and a condition that her’s is gone. Is that the best way to do this? Also that means I then have to build a second one right for the opposite scenario? It seems triggers are essentially or statements and conditions are and statements. is that right?
You can create template sensor which counts how many people are currently in home and then setup trigger on state change from anything to 0. Such sensor can be usefull for many other automation soon (-:
Home assistant pages have some documentation on it, you can also test live templates on running home assistant. I’ll check later in my another installation, where I’m using such template sensors.
- platform: template
sensors:
in:
value_template: '{{states.device_tracker|map(attribute="attributes")|sum("in")}}'
friendly_name: in the building
unit_of_measurement: human
But I have locally enchanced device_tracker with boolean in attribute, http://your-hass/dev-state shows for device_tracker.sokolowski:
You could also put both phones into a group. The group will be home as long as at least 1 member/phone is home and only away when both phones are away.
Sounds like a good fit for your problem.
Thank you will look into both, having some issues with the whole detection now, had to reset my router and now my log says it cant find the devices. Changed all the ips in the yaml as well.
Thanks everyone group did exactly what I needed. The other suggestions were pretty cool as well so will habe to remember them as I start getting more into this.