I have just acquired an extra Sonos Play1 and would like to have a simple automation to turn it on/off.
I have a Xiaomi motion sensor in the bathroom where the Sonos Play1 is.
Simply want to have the Sonos Play on detecting motion (someone in the bathroom) and Pause when there is no motion for 2 minutes (no-one in bathroom any more).
This will be my first automation with Home Assistant and just wondering if anyone has something similar or if they know the simplest way of doing it with automations.
OK Got it working to turn the Sonos on with the following in case anyone wants to know a fairly simple way of turning your Sonos music on with a Xiaomi sensor, just trying to work out how to get it to stop when there is no presence for 1-2 minutes or so.
Talking to myself here but maybe will help someone whos just starting with automations who wants to do the same thing.
I looked around here and have now got it fully working, my Sonos plays music whilst people are in the bathroom and then 2 minutes after no motion is detected the music stops.
Congrats on figuring out your first automation by your self.
It would be really helpful for other new starters if you could format your code as per the blue box at the top of this page. That way people can read your code better as formatting is critical to yaml.
OK I will go back and change it, it’s not quite working correctly though - the music only comes on for 2 minutes, rather than 2 minutes from when motion was last detected.