ebaauw / homebridge-zp

Homebridge plugin for Sonos ZonePlayer
Apache License 2.0
243 stars 20 forks source link

Sleep Timer #193

Open SirVival71 opened 2 years ago

SirVival71 commented 2 years ago

Issue

If I set a sleep timer by a scene e.g. to 900s and some minutes later (while the sleep timer is running) I set the sleep timer e.g. to 1200s by another scene, the sleep timer is not refreshed to the new value 1200s. The sleep timer still decrements further from the first run.

If I set a sleep timer to 900s and stop the music (the sleep timer is still running in the background) and then I set the sleep timer to 1200s, the sleep timer is refreshed to 1200s and starts its work as expected. This is a workaround for automation sequences. But it does not work in scenes.

ebaauw commented 2 years ago

Changing Default Duration in itself does nothing. The timer is only applied when setting On. This is how HomeKit works. Of course, Apple's Home app only supports Default Duration and Remaining Duration for Valve services, so it's a bit of a stretch to apply this to the Sonos service, see also #144. Home displays the remaining time on the tile for Valve services - I wanted to provide that for Sonos as well, that's why I expose the sleep timer using Default Duration and Remaining.

I suppose the issue you're facing is that Homebridge ZP wouldn't act on the On in the other scene, because the zone player is already playing.

Playing a bit with zp sleepTimer and the Sonos app: the zone player seems to handle the timer independently from whether it's playing or not. I can start the timer when the player is stopped, and the timer continues to run across mulitple Play and Stop/Pause commands. I think we need a separate Start Timer characteristic to reflect that logic.