Hi all, I have a HC2 and I am trying to connect my KeyFob to my Sonos Playbar to set the volume. I already have it working but now I am finetuning and cannot get to the end. I have programmed my "+" and "-" button on the KeyFob so that they set the volume up and down. But I want to have it more sophisticated. My goal is when I push "+" the volume goes up by 1 on every click. And goes down by 1 when clicking the "-" button. But I need some help with this.
Does someone here know how I can create the correct LUA code for this??
Here below the current situation in the scene for the KeyFob:
--[[
%% properties
%% events
263 CentralSceneEvent
%% globals
--]]
local sa = fibaro:getSourceTrigger()["event"]["data"]
--fibaro:debug(json.encode(sa))
if ((sa['keyId'] == 1) and (sa['keyAttribute'] == 'Pressed'))
then
fibaro:debug('key1')
end
if ((sa['keyId'] == 1) and (sa['keyAttribute'] == 'Pressed2'))
then
fibaro:debug('key1 double')
end
if ((sa['keyId'] == 1) and (sa['keyAttribute'] == 'Pressed3'))
then
fibaro:debug('key1 triple')
end
if ((sa['keyId'] == 1) and (sa['keyAttribute'] == 'HeldDown'))
then
fibaro:debug('key1 held')
end
if ((sa['keyId'] == 1) and (sa['keyAttribute'] == 'Released'))
then
fibaro:debug('key1 release')
end
if ((sa['keyId'] == 2) and (sa['keyAttribute'] == 'Pressed'))
then
--fibaro:debug('key2')
fibaro:call(348, "setMute", "1")
end
if ((sa['keyId'] == 2) and (sa['keyAttribute'] == 'Pressed2'))
then
--fibaro:debug('key2 double')
fibaro:call(348, "setMute", "0")
end
if ((sa['keyId'] == 2) and (sa['keyAttribute'] == 'Pressed3'))
then
fibaro:debug('key2 triple')
end
if ((sa['keyId'] == 2) and (sa['keyAttribute'] == 'HeldDown'))
then
fibaro:debug('key2 held')
end
if ((sa['keyId'] == 2) and (sa['keyAttribute'] == 'Released'))
then
fibaro:debug('key2 release')
end
if ((sa['keyId'] == 3) and (sa['keyAttribute'] == 'Pressed'))
then
fibaro:debug('key3')
end
if ((sa['keyId'] == 3) and (sa['keyAttribute'] == 'Pressed2'))
then
fibaro:debug('key3 double')
end
if ((sa['keyId'] == 3) and (sa['keyAttribute'] == 'Pressed3'))
then
fibaro:debug('key3 triple')
end
if ((sa['keyId'] == 3) and (sa['keyAttribute'] == 'HeldDown'))
then
fibaro:debug('key3 held')
end
if ((sa['keyId'] == 3) and (sa['keyAttribute'] == 'Released'))
then
fibaro:debug('key3 release')
end
if ((sa['keyId'] == 4) and (sa['keyAttribute'] == 'Pressed'))
then
fibaro:debug('key4')
end
if ((sa['keyId'] == 4) and (sa['keyAttribute'] == 'Pressed2'))
then
fibaro:debug('key4 double')
end
if ((sa['keyId'] == 4) and (sa['keyAttribute'] == 'Pressed3'))
then
fibaro:debug('key4 triple')
end
if ((sa['keyId'] == 4) and (sa['keyAttribute'] == 'HeldDown'))
then
fibaro:debug('key4 held')
end
if ((sa['keyId'] == 4) and (sa['keyAttribute'] == 'Released'))
then
fibaro:debug('key4 release')
end
if ((sa['keyId'] == 5) and (sa['keyAttribute'] == 'Pressed'))
then
--fibaro:debug('key5')
fibaro:call(348, "setVolume", "10")
end
if ((sa['keyId'] == 5) and (sa['keyAttribute'] == 'Pressed2'))
then
--fibaro:debug('key5 double')
fibaro:call(348, "setVolume", "5")
end
if ((sa['keyId'] == 5) and (sa['keyAttribute'] == 'Pressed3'))
then
fibaro:debug('key5 triple')
end
if ((sa['keyId'] == 5) and (sa['keyAttribute'] == 'HeldDown'))
then
fibaro:debug('key5 held')
end
if ((sa['keyId'] == 5) and (sa['keyAttribute'] == 'Released'))
then
fibaro:debug('key5 release')
end
if ((sa['keyId'] == 6) and (sa['keyAttribute'] == 'Pressed'))
then
--fibaro:debug('key6')
fibaro:call(348, "currentVolume", "12")
end
if ((sa['keyId'] == 6) and (sa['keyAttribute'] == 'Pressed2'))
then
--fibaro:debug('key6 double')
fibaro:call(348, "setVolume", "15")
end
if ((sa['keyId'] == 6) and (sa['keyAttribute'] == 'Pressed3'))
then
--fibaro:debug('key6 triple')
fibaro:call(348, "setVolume", "17")
end
if ((sa['keyId'] == 6) and (sa['keyAttribute'] == 'HeldDown'))
then
fibaro:debug('key6 held')
end
if ((sa['keyId'] == 6) and (sa['keyAttribute'] == 'Released'))
then
fibaro:debug('key6 release')
end