I have a Sonos:AMP in my bathroom which I was not using that much because when I go into the bath or shower my phone often isn’t around to turn on the music.
So, It seemed handy to turn on the music (the existing playlist) with a triple click of my bathroom light switch. This is how I reached this goal:
I installed the Sonos Plugin and I added my bathroom Sonos device
I downloaded and added the Sonos Virtual Device from Krikroff: http://www.fibarouk.co.uk/resources/VirtualDevices/SonosPlayer-0.0.8.zip
Add a variable in the Variables Panel. I used this tutorial on Youtube: https://www.youtube.com/watch?v=ps9jNiJ_JeU
As I am still using Dimmer 1 (FGD-211), I turned on the Scene Activation functionality by putting parameter 41 on 1 in the advanced tab of my bathroom dimmer. If you use Dimmer 2 (FGD-212) you’ll have to put parameter 28 on 1 (no experience, so not sure).
After that I build 3 scenes:
First of all a scene to put on the Sonos on a specific volume level (where as 311 and 312 are the ID’s of the Sonos Plugin and Virtual Device):
--[[
%% properties
%% events
%% globals
--]]
-- Set volume of the Sonos plugin
fibaro:call(311, "setVolume", "40")
-- Press button 7 (play) of the Sonos Virtual Device
fibaro:call(312, "pressButton", "7")
Second a scene to stop the Sonos player again:
--[[
%% properties
%% events
%% globals
--]]
-- Press button 9 (stop) of the Sonos Virtual Device
fibaro:call(312, "pressButton", “9")
Third, a scene to activate the scenes on a triple click:
--[[
%% properties
12 sceneActivation
%% globals
--]]
local id= 12; -- Change this to your dimmer ID
if (tonumber(fibaro:getValue(id, "sceneActivation"))==15) and
(tonumber(fibaro:getValue(id,"value"))==0) then
fibaro:debug("3click activated, Sonos bathroom ON");
fibaro:setGlobal("Sleep", "1") -- Change this to your sleep variable(if you have one)
fibaro:startScene(278); -- or start a second scene
end
if (tonumber(fibaro:getValue(id, "sceneActivation"))==15) and
(tonumber(fibaro:getValue(id,"value"))>0) then
fibaro:debug("3click activated, Sonos bathroom OFF");
fibaro:setGlobal("Sleep", "1") -- Change this to your sleep variable(if you have one)
fibaro:startScene(279); -- or start a second scene
end
12 is the dimmer ID of the bathroom, 278 the ID of the scene to turn on Sonos and 279 to turn off Sonos. 15 corresponds with triple click.
There is one issue I didn’t foresee (because I copied scene 3): scene 3 looks if dimmer 12 is on (>0) or off (=0) to decide whether to turn on or off the Sonos. This should obviously be: look whether the music is on or off to decide if it has to be turned on or off.
Somebody any suggestions to solve this? Any other suggestions to develop this solution further are welcome as well.
Thanks in advance.
Wesselvvvb