Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
Search the Community
Showing results for tags 'concatenate'.
-
attempt to concatenate local 'wakeUpTime' (a nil value)
Rik74 posted a question in Scenes and Interface
Hi there, i have a Problem with an old scene. Since one of the last updates, i get this error: [DEBUG] 21:56:06: --------------------START-------------------------------- [DEBUG] 21:56:06: --------- Danfoss WakeUp powered by mkshb.de [DEBUG] 21:56:06: ----------------------------------------------------------- [DEBUG] 21:56:06: Trigger durch manuelles Starten [DEBUG] 21:56:07: -------------- Calculate and Set WakeUpTime ------------- [DEBUG] 21:56:07: Zieltemperatur: 17 [DEBUG] 21:56:07: Aussentemperatur: 20.5 [DEBUG] 21:56:07: Es ist Sommer verwende entsprechende Werte [DEBUG] 21:56:07: 2019-06-17 21:56:07.791861 [ fatal] Unknown exception: /opt/fibaro/scenes/27.lua:147: attempt to concatenate local 'wakeUpTime' (a nil value) Here is the code: --[[ %% autostart %% properties %% globals PresentState SleepState --]] ----------------------------------------------- -- mkshb.de - Danfoss WakeUpTime ----------------------------------------------- --[[ Change wakeUp Intervall for Danfoss Trigger: globale Variablen TimeOfDay, PresentState, SleepState Quelle: https://www.mkshb.de/wakeup-intervall-per-lua-anpassen/ --]] --------------------------------------------------- --------- Schleifenschutz ------------------------- if (fibaro:countScenes()>2) then fibaro:debug('Kill the second scene!'); fibaro:abort(); end -- Konfiguration ----------------------------------------------- --Allgemein local advdebug = true local scheduler = true local runMinute = 5 --Temperaturen -- local outdoorTemp = {208,'Temperature'} -- Aussentemperatur von Yahoo-Wetter local outdoorTemp = {3,'Temperature'} -- Aussentemperatur von YR-Weather local indoorTemp = {153,'targetLevel'} -- Zielzemperatur vom Thermostat Wohnzimmer Kr1 -- Zeiten local basisSeconds = 100 local minSeconds = 90 local winterMonth = {1,2,3,10,11,12} -- Intervallkonfiguration local presentVar = 'PresentState' local presentHomeVar = {'Home','900','calc'} local presentAwayVar = {'Away','900','900'} local presentHolidayVar = {'Holiday','1800','1800'} local version = 'v1.1.1' --------- Farbiges Debug -------------------------- --------------------------------------------------- debug = function ( color, message ) if (advdebug) then fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); end end --------- Function round -------------------------- --------------------------------------------------- function round(num, numDecimalPlaces) return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) end --------------------------------------------------- ------------- Funktion checkSeason ---------------- function checkSeason(tab, val) for index, value in ipairs (tab) do if value == val then return true end end return false end --------- Function calculateTime ------------------ --------------------------------------------------- function calculateTime(trigger, Outdoor, Indoor) debug('blue','-------------- Calculate and Set WakeUpTime -------------') -- Ermittlung der aktuellen Temperaturen indoorTempValue = fibaro:getValue(indoorTemp[1], indoorTemp[2]) outdoorTempValue = fibaro:getValue(outdoorTemp[1], outdoorTemp[2]) --Debug Ausgabe debug('green','Zieltemperatur: '..indoorTempValue) debug('green','Aussentemperatur: '..outdoorTempValue) --Berechnung wakeUpTime wakeUpTimeCalc = round(basisSeconds + (indoorTempValue * outdoorTempValue),0) if wakeUpTimeCalc < basisSeconds then wakeUpTimeCalc = minSeconds else wakeUpTimeCalc = wakeUpTimeCalc end --Bestimmung Sommer / Winter if checkSeason(winterMonth, tonumber(os.date('%m'))) then debug('green','Es ist Winter verwende entsprechende Werte') season = 3 else debug('green','Es ist Sommer verwende entsprechende Werte') season = 2 end -- WakeUp nach PresentState setzen if fibaro:getGlobal(presentVar) == presentHomeVar[1] then if presentHomeVar[season] ~= "calc" then return presentHomeVar[season] else return wakeUpTimeCalc end elseif fibaro:getGlobal(presentVar) == presentAwayVar[1] then if presentAwayVar[season] ~= "calc" then return presentAwayVar[season] else return wakeUpTimeCalc end elseif fibaro:getGlobal(presentVar) == presentHolidayVar[1] then if presentHolidayVar[season] ~= "calc" then return presentHolidayVar[season] else return wakeUpTimeCalc end end end --------- Function findDanfoss -------------------- --------------------------------------------------- function findDanfoss() allDevices = api.get('/devices') danfossDevices = {} for i=1, #allDevices do if allDevices[i].type == "com.fibaro.thermostatDanfoss" and allDevices[i].baseType == "com.fibaro.hvac" and allDevices[i].properties.zwaveCompany == "Danfoss" then table.insert(danfossDevices, allDevices[i].id) end end return danfossDevices end --------- Function changeWakeup ------------------- --------------------------------------------------- function changeWakeup(trigger, deviceIDs, wakeUpTime) for i=1, #deviceIDs do device = api.get('/devices/' .. deviceIDs[i]) jsontextParent = '{"id":'..device.parentId..',"parentId":1,"properties":{"wakeUpTime":'..wakeUpTime..'}}' jsontextParent = json.decode(jsontextParent) api.put('/devices/' .. device.parentId, jsontextParent) debug('green','wakeUpTime für ' .. device.name ..' (ID:'..device.id..') auf ' .. wakeUpTime .. ' Sekunden geändert') end end --------------------------------------------------- ------------- Timer Function ---------------------- function timerFunction() minutes = os.date("%M") if tonumber(minutes) % runMinute == 0 then debug('green','Trigger durch Scheduler') changeWakeup('Autostart', findDanfoss(), calculateTime('Autostart',outdoorTemp,indoorTemp)) end setTimeout(timerFunction, 60*1000) end --------------------------------------------------- ------------- START ----------------------------- debug('green','--------------------START--------------------------------') debug('green','--------- Danfoss WakeUp powered by mkshb.de') debug('green','-----------------------------------------------------------') sourceTrigger = fibaro:getSourceTrigger() if sourceTrigger["type"] == "autostart" then if scheduler then debug('yellow','Scheduler gestartet.') timerFunction() else debug('red','Scheduler ist deaktiviert. Start durch globale Variablen') end elseif sourceTrigger["type"] == "global" then debug('green','Trigger durch globale Variable: '..sourceTrigger["name"]) changeWakeup(sourceTrigger["name"], findDanfoss(), calculateTime(sourceTrigger["name"],outdoorTemp,indoorTemp)) elseif sourceTrigger["type"] == "other" then -- Manuell gestartet debug('green','Trigger durch manuelles Starten') changeWakeup('Other', findDanfoss(), calculateTime('Other',outdoorTemp,indoorTemp)) end Is there anybody who can help me? Thanks a Lot! regards Rik
