-
Compteur de contenus
206 -
Inscription
-
Dernière visite
-
Jours gagnés
41
jang a gagné pour la dernière fois le 18 mars
jang a eu le contenu le plus aimé !
Profile Information
-
Sexe :
Homme
-
Ville :
Home
-
Box
Home Center 2
-
Version
HC3
Visiteurs récents du profil
2 022 visualisations du profil
jang's Achievements
-
This only works if the device is a QA. QuickApp's have 'updateProperty' defined as an API. I would recommend api.post("/plugins/updateProperty", { deviceId = 20, propertyName = 'userDescription', value = 'FWPP1' })
-
jang a commencé à suivre Bug MAJ slider , QuestionS HC3 et LUA , HC3 & HC3L - 5.153.120 - BETA - 19/02/2024 et 5 autres
-
No there is no reason. Except maybe a wish to bring all functionality in under fibaro.* - but they can't remove setTimeout due to old QAs/Scenes. function fibaro.setTimeout(time,fun) return setTimeout(fun,time) end Like the rebranding of fibaro.* to hub.* - but also here, to be backward compatible with QAs/Scenes they can never remove fibaro.*... Another mystery is that Fibaro maintains 2 implementations for the fibaro.* functions. One for Scenes and one for QAs - and they are not always in sync... My thinking has been that it is 2 different consultant companies that do the Scene engine vs the QA framework... :-)
-
Have you tried it? Did it work for you?
-
What kind of animal is Conso Live (Enphase_MeterTotalConsumptionPower_Updated) that is expect to send an event/signal. Another QA? another zwave device? something else?
- 16 réponses
-
- déclencheur
- event
-
(et 1 en plus)
Étiqueté avec :
-
Problems: 1. You set 'value' but test 'state' 2. If you click 'off' -> 'on' quickly you may end up with 2 running loops... I think @laser meant something like this (but here we use the property instead of a local var) local function loop() if (hub.getValue(plugin.mainDeviceId,"value") == true) then print("Run Loop action") end -- loop setTimeout(loop,1000*loop_value_sec) -- secondes end loop() function QuickApp:turnOn() self:debug("binary switch turned on") self:updateProperty("value", true) end function QuickApp:turnOff() self:debug("binary switch turned off") self:updateProperty("value", false) end
-
Unfortunately not. I have QAs that don't work on the HC3L because I use os.time() a lot. os.time(), these days, returns a value dangerously close to what fits in 32 bits and when doing arithmetics with the value, calculating time, it sometimes overflow and create bad results on the HC3L... So, I recommend the HC3L only for block scenes... For dev platform I use https://forum.fibaro.com/topic/66394-visual-studio-code-vscode-for-quickapp-development/ Life is too short for trying to develop directly on the HC3/HC3L...
-
Are you running it on a HC3 Lite? Fibaro, in their wisdom to save space, compiled the Lua environment for the HC3L as 32bits... ...which cause all kinds of issues like these...
-
-
api.put("/rooms/239",{icon='User1002'})
-
local commands = { Opened = "https://airsend.cloud/device/xxxxx/command/4/?session=???", Closed = "https://airsend.cloud/device/xxxxx/command/5/?session=???", Stopped = "https://airsend.cloud/device/xxxxx/command/3/?session=???", } function QuickApp:command(cmd,state) assert(commands[cmd],"Bad command") local http = net.HTTPClient() http:request(commands[cmd], { success = function(response) if response.status == 200 then print('OK, réponse : '.. response.data) self:debug("base shutter "..cmd:lower()) self:updateProperty("state", state or cmd) else self:error("Erreur : status=" .. tostring(response.status)) end end, error = function(err) self:error("Erreur : " .. err) end, options = { method = 'GET' } }) end function QuickApp:open() sendCommand('Opened') end function QuickApp:close() sendCommand('Closed') end function QuickApp:stop() sendCommand('Stopped',"Unknown") end
-
The only problem is that hub.call can't return any value - to do this you need to add additional sorcery...
-
vider une propriété de type tableau dans l'API
jang a répondu à un(e) sujet de jjacques68 dans Support
Well, you have the tools, the rest is just some list manipulations... ;-) local days = { monday=0, tuesday=1, wednesday=2, thursday=3, friday=4, saturday=5, sunday=6 } local function map(list) local r ={} for _,e in ipairs(list) do assert(days[e],"Bad day:"..tostring(e)) r[e]=true end return r end local function flatten(list) local r ={} for e,_ in pairs(list) do assert(days[e],"Bad day:"..tostring(e)) r[#r+1]=e end table.sort(r,function(a,b) return days[a] <= days[b] end) return r end -- self:setSprinklerDays(4,{"monday",wednesday"}) -- will set scheduled days to monday and wednesday for sprinkler schedule 4 function QuickApp:setSprinklerDays(sprinkerId,list) return api.put("/panels/sprinklers/4" ,{ days = json.util.InitArray(flatten(map(list)))}) end -- self:addSprinklerDays(4,{"monday",wednesday"}) -- will add monday and wednesday to currently scheduled days for sprinkler schedule 4 function QuickApp:addSprinklerDays(sprinklerId,list) local days = map(api.get("/panels/sprinklers/"..sprinklerId).days or {}) for _,d in ipairs(list) do days[d]=true end return api.put("/panels/sprinklers/4" ,{ days = json.util.InitArray(flatten(days))}) end -- self:removeSprinklerDays(4,{"monday",wednesday"}) -- will remove monday and wednesday from currently scheduled days for sprinkler schedule 4 function QuickApp:removeSprinklerDays(sprinklerId,list) local days = map(api.get("/panels/sprinklers/"..sprinklerId).days or {}) for _,d in ipairs(list) do days[d]=nil end return api.put("/panels/sprinklers/4" ,{ days = json.util.InitArray(flatten(days))}) end function QuickApp : onInit () print(self:setSprinklerDays(4,{"monday","friday"})) print(self:addSprinklerDays(4,{"saturday"})) print(self:removeSprinklerDays(4,{"monday"})) end -
vider une propriété de type tableau dans l'API
jang a répondu à un(e) sujet de jjacques68 dans Support
Btw, this is the json encoder/decoder used in QAs https://github.com/harningt/luajson/ (Scenes use another implementation) -
vider une propriété de type tableau dans l'API
jang a répondu à un(e) sujet de jjacques68 dans Support
You could try local ListDay = json.util.InitArray({}) --<----- empty array MyPanel = api.get("/panels/sprinklers/11" ) res = api.put("/panels/sprinklers/11" , { days = ListDay }) The reason is that the json.encoder don't know if the Lua table {} should be encoded as an empty json key-value table "{}" or an empty json array "[]" The json.util.InitArray() function creates an object that the json.encoder always encodes as an array. Of course, the suggestion above only works if api.put uses the QAs built-in json.encode... -
Yes, it's really buggy. Try to add function QuickApp : OnReleased ( event ) self : updateView ( "slider" , "value" , "75" ) -- Any other value than 25... self : updateView ( "slider" , "value" , "25" ) end
- 12 réponses
-
- 1