In our household, almost everything (but unfortunately not everyone ) is controlled by voice command. Some of us also tend to play our music at a higher volume during certain times of the day. Within our Sonos network, this can occasionally result in surprises if someone commands a speaker to start playing their favorite station, unaware that the previous user had the speaker blasting. In addition, some of our Sonos speakers are Alexa-enabled (or alternately, sometime later this year, Google Assistant-enabled) and issuing a voice command to a speaker that was stopped while playing at a higher volume can result in the speaker shouting back at you. The consequences of this can be particularly unpleasant if it happens late at night or early in the morning.
This piston will automatically adjust the level of any speaker to a preset level after it has been inactive for a pre-defined period of time. The user can set different preset levels for daytime and nighttime (and define the hours for each) by modifying the preference variables. The piston will NOT make adjustments to any active speakers at the onset of ‘daytime’ or ‘nighttime’ until they have been inactive for the user-defined period of time.
To accommodate grouped speakers, which adjust volume relative to the group ‘coordinator,’ the piston first sets all inactive speakers to zero before setting them to the desired presets, thus ensuring that the levels all match.
As a general note, where Sonos speakers have been paired for stereo, only the left speaker of the pair should be defined in the device variable.