Fibaro KeyFob LUA-Code

--[[
%% properties
%% events
614 CentralSceneEvent
%% globals
--]]

function call_action1()
end

function call_action2()
end

function call_action3()
end

function call_action4()
end

function call_action5()
end

function call_action6()
end

Debug = function ( color, message )
  fibaro:debug(string.format('<%s style="color:%s;">%s', "span", color, message, "span"))
end

fibaro:debug('Fibaro KeyFob - Szene gestartet...')

Debug( 'green', '- siio.de - Dein Smart Home Blog -')

local swipe_source = fibaro:getSourceTrigger()["event"]["data"] --Obtain data about the event
--fibaro:debug("Key " .. swipe_source["keyId"] .. " Attr " .. swipe_source["keyAttribute"])

if (swipe_source["keyId"] == 1 and swipe_source["keyAttribute"] == 'Pressed') then
  fibaro:debug('Taste 1 gedrückt')
  call_action1()
elseif (swipe_source["keyId"] == 2 and swipe_source["keyAttribute"] == 'Pressed') then
  fibaro:debug('Taste 2 gedrückt')
  call_action2()
elseif (swipe_source["keyId"] == 3 and swipe_source["keyAttribute"] == 'Pressed') then
  fibaro:debug('Taste 3 gedrückt')
  call_action3()
elseif (swipe_source["keyId"] == 4 and swipe_source["keyAttribute"] == 'Pressed') then
  fibaro:debug('Taste 4 gedrückt')
  call_action4()
elseif (swipe_source["keyId"] == 5 and swipe_source["keyAttribute"] == 'Pressed') then
  fibaro:debug('Taste 5 gedrückt')
  call_action5()
elseif (swipe_source["keyId"] == 6 and swipe_source["keyAttribute"] == 'Pressed') then
  fibaro:debug('Taste 6 gedrückt')
  call_action6()
end

function um ein Termostat auszulesen und mit den + & - Tasten zu erhöhen oder abzusenken:

Erhöhen:

local thermoID = 10

function call_action5()
 local temp_wish = tonumber(fibaro:getValue(thermoID, "value"))
 temp_wish = temp_wish + 1
 fibaro:call(thermoID, "setTargetLevel", temp_wish)
 fibaro:call(thermoID, "setTime", tonumber(os.time()) + 120*60)
 fibaro:debug('Wert auf ' ..temp_wish.. '° gesetzt.')
end

Absenken:

function call_action6()
 local temp_wish = tonumber(fibaro:getValue(thermoID, "value"))
 temp_wish = temp_wish - 1
 fibaro:call(thermoID, "setTargetLevel", temp_wish)
 fibaro:call(thermoID, "setTime", tonumber(os.time()) + 120*60)
 fibaro:debug('Wert auf ' ..temp_wish.. '° gesetzt.')
end