(Har iofs inte letat efter liknande lösning heller så det kanske finns massor redan)
Här är då en enkel scen som innehåller inställningarna:
Code: Select all
--[[
%% autostart
--]]
local doDebug = true
local settingVariable = "set_IDs"
local settings = {
room_Badrum = 4,
dev_Torktumlare = 11,
vd_TorktumlareStatus = 52,
room_Koket = 5,
dev_RorelseKoket = 77,
dev_TempKoket = 78,
dev_LjusKoket = 79,
dev_FuktKoket = 79,
vd_Kaffelampa = 48,
scene_Kaffelampa = 28,
setting_KaffelampaMinuWithoutMotion = 20,
setting_KaffelampaDimOn = 90,
setting_KaffelampaDimOff = 30,
}
-- =============================================================================
fibaro:setGlobal(settingVariable, json.encode(settings))
-- =============================================================================
if doDebug == false then fibaro:abort() end
msgDebugVar = function (info, key, value)
fibaro:debug(info .. ": <span style='color: Gray'>" .. tostring(key) .. "</span> = <span style='color: Yellow'>" .. tostring(value) .. "</span>")
end
for key,value in pairs(settings) do
msgDebugVar("Saving", key,value)
end
fibaro:debug("JSON: " .. json.encode(settings))
fibaro:debug("Debug enabled, testing to read from " .. settingVariable)
local var = tostring( fibaro:getGlobalValue(settingVariable) )
fibaro:debug("JSON: " .. var)
local get = json.decode(var)
for key,value in pairs(get) do
msgDebugVar("Decoded", key,value)
end
-- =============================================================================
Code: Select all
local mySettings = json.decode( tostring( fibaro:getGlobalValue("set_IDs") ) )
doStuff( mySettings["dev_RorelseKoket"] )