Aller au contenu

jang

Membres confirmés
  • Compteur de contenus

    215
  • Inscription

  • Dernière visite

  • Jours gagnés

    45

Tout ce qui a été posté par jang

  1. http://www.lua.org/manual/5.3/manual.html#3.4.1 "With the exception of exponentiation and float division, the arithmetic operators work as follows: If both operands are integers, the operation is performed over integers and the result is an integer. Otherwise, if both operands are numbers or strings that can be converted to numbers (see §3.4.3), then they are converted to floats, the operation is performed following the usual rules for floating-point arithmetic (usually the IEEE 754 standard), and the result is a float. Exponentiation and float division (/) always convert their operands to floats and the result is always a float. Exponentiation uses the ISO C function pow, so that it works for non-integer exponents too."
  2. jang

    QA remote

    It works very well for me. Does it show up in the block scene editor? The "Central Scene ID" option? Remote.fqa
  3. jang

    QA remote

    This QA shows up in the block scene editor for me function QuickApp:onInit () self:debug ("Remote") local inf = api.get("/devices/"..self.id).interfaces for _,i in ipairs(inf) do if i=='zwaveCentralScene' then inf=nil; break end end if inf then inf[#inf+1]='zwaveCentralScene' self:addInterfaces(inf) end self:debug(json.encode(inf)) self: updateProperty ( "centralSceneSupport" , { {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 1 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 2 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 3 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 4 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 5 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 6 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 7 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 8 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 9 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 10 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 11 }, {keyAttributes = { "Pressed" , "Released" , "HeldDown" , "Pressed2" , "Pressed3" }, keyId = 12 }, }) end
  4. jang

    QA remote

    Have you set interfaces = { 'zwaveCentralScene' } ?
  5. jang

    UN petit coup de main SVP

    function dumpScene(id) local s,c,f = api.get("/scenes/"..id) c = json.decode(s.content) f = io.open("Scene_"..id.."_actions.lua","w"); f:write(c.actions); f:close() f = io.open("Scene_"..id.."_conditions.lua","w"); f:write(c.conditions); f:close() f = io.open("Scene_"..id..".lua","w"); f:write(json.encode(s)); f:close() end --- Download scene from HC3 dumpScene(13) --- Edit Scene_13_actions.lua ... --- Edit Scene_13_conditions.lua ... function restoreScene(id) local f,a,c,s f = io.open("Scene_"..id.."_actions.lua","r"); a=f:read("*all"); f:close() f = io.open("Scene_"..id.."_conditions.lua","r"); c=f:read("*all"); f:close() f = io.open("Scene_"..id..".lua","r"); s=f:read("*all"); f:close() s = json.decode(s) s.content=json.encode({conditions=c,actions=a}) api.put("/scenes/"..id,s) end --- ... then restore scene to HC3 restoreScene(13)
  6. Fair enough. I stand corrected, removeChildDevice() is called when children are deleted in the IU, so the onAction hook will work. You could also intercept calls to the method. function QuickApp:onInit() local orgRemoveChildDevice = self.removeChildDevice function self:removeChildDevice(id) self:debug("Child ",id," is about to be deleted") -- do other stuff orgRemoveChildDevice(self,id) end end
  7. Ok, I understand. Good luck :-)
  8. Is it a GEA syntax problem or api? If it's the api this is what I use in ER4 -- id to profile name function self:profileName(id) for _,p in ipairs(api.get("/profiles").profiles) do if p.id == id then return p.name end end end -- profile name to id function self:profileId(name) for _,p in ipairs(api.get("/profiles").profiles) do if p.name == name then return p.id end end end -- set active profile if id ~= nil, or return current active profile if id == nil function self:activeProfile(id) if id then if type(id)=='string' then id = self:profileName(id) end assert(id,"activeProfile(id) - no such id/name") return api.put("/profiles",{activeProfile=id}) and id end return api.get("/profiles").activeProfile end
  9. When a child is deleted (from Lua or UI) you get a 'DeviceRemovedEvent' in / refreshStates The QuickApp will also update the self.childDevices table. Why don't you store your extra info in the child table? self.childDevices [childID] .extraInfo = ... it's just the child instance I don't think r emoveChildDevice (...) is called by the QA if you delete the child in the UI.
  10. It should work. Be careful if chidId doesn't exist (just removed). HC3 logs a warning if ID doesn't exists. What are you doing with 'removeChildDevice' ?
  11. Yes, I can. ...but I have a Mac
  12. ... and then we want a restore functionality It should be possible to define a github hook to push production branches directly to the HC3.
  13. I use ZeroBrane studio for all my HC3 development with an emulator that simulates the HC3 environment -much easier and productive to code that way... Depends on programming language - you need to create a file and write the content to that file. Lua: local fqa = api.get ("/ quickApp / export /" .. deviceID) local f = io.open (fileName, "w +") assert (f, "Can't open file" ..fileName) f: write (fqa) f: close ()
  14. It returns the QA encoded as a .fqa - json forma (including all subfiles) From the HC3/emulator I do api.get("/quickApp/export/"..deviceID) to download QAs...
  15. Everything I (currently) know about QuickAppChildren ... https://forum.fibaro.com/topic/49113-hc3-quickapps-coding-tips-and-tricks/?do=findComment&comment=223530
  16. jang

    QA Réveil - conseils

    function QuickApp:test(x) self.x = x; self:debug("self.x is set to ",x) end is identical to function QuickApp.test(self,x) self.x = x; self:debug("self.x is set to ",x) end 'self' is inserted as the first variable of the function, before x when declared with ':' calling self:test(7) is identical to calling self.test(self,7) ...so when you call Object:test(7) it is the same as Object.test(Object,7) so 'self' will be bound to Object When you call Child:Func1() 'self' will be bound to Child, because the call is identical to Child.Func1(Child) It means that inside Func1 we have access to 'self', the object that called Func1 It's syntactic sugar for Lua...
  17. jang

    QA Réveil - conseils

    Shared code/modules are an interesting topic. It would be nice if the community could agree about a "module" format that made it easy to use each other's modules without polluting the Lua global namespace too much... https://forum.fibaro.com/topic/49113-hc3-quickapps-coding-tips-and-tricks/?do=findComment&comment=223070
  18. jang

    Instruction pour Adresse IP HC3

    function QuickApp:getHC3IPaddress(name) if self.IPaddress then return self.IPaddress else name = name or ".*" local networkdata = api.get("/proxy?url=http://localhost:11112/api/settings/network") for n,d in pairs(networkdata.networkConfig or {}) do if n:match(name) and d.enabled then self.IPaddress = d.ipConfig.ip; return self.IPaddress end end end end
  19. Running GEA 7.01 offline - easier to debug
  20. jang

    Interrompre le code LUA d'un QuickApp

    plugin.restart()
  21. jang

    getSourceTrigger

    sceneActivationEvent ? https://forum.fibaro.com/topic/49410-hc3-lua-sceneactivation/?do=findComment&comment=216519
  22. jang

    getSourceTrigger

    Isn't that a sceneActivation device? - not a centralSceneEvent device...
  23. ...but from another QA you have a table... It's the marshalling of arguments that is broken - try this function QuickApp:test(arg) self:debug("Argument ",tostring(arg)," is a ",type(arg)) end function QuickApp:onInit() fibaro.call(self.id,"test","0042") fibaro.call(self.id,"test","true") fibaro.call(self.id,"test",'{"a":9}') end I complained in February about it...
  24. self:deleteInterfaces({"light"}) or myQuickApp:deleteInterfaces({"light"})
  25. self:createChildDevice always add "quickAppChild" for you. Some types of device will also add their specific interfaces.
×
×
  • Créer...