Jump to content

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 'LUA'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • FIBARO Community
    • FIBARO Portal and Forum policy
    • FIBARO
    • Say hello!
    • Off-topics
  • FIBARO Update
    • FIBARO System Update
    • FIBARO Mobile Update
  • FIBARO Community Support
    • Scenes and Interface
    • FIBARO Products
    • FIBARO Mobile
    • FIBARO HomeKit
    • FIBARO Assistant Integrations
    • Other Devices / Third-party devices
    • Tutorials and Guides
    • Home Automation
    • Suggestions
  • FIBARO Społeczność
    • FIBARO
    • Przywitaj się!
    • Off-topic
  • FIBARO Aktualizacja
    • FIBARO System Aktualizacja
    • FIBARO Mobile Aktualizacja
  • FIBARO Wsparcie Społeczności
    • Sceny i Interfejs
    • FIBARO Urządzenia
    • FIBARO Mobilnie
    • FIBARO HomeKit
    • Integracja z Amazon Alexa i Google Home
    • Urządzenia Firm Trzecich
    • Poradniki
    • Automatyka Domowa
    • Sugestie

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

  1. Hi guys, is there a lua command to soft reconfigure a device. I'm trying to write a script to test the IR code sets of a remotec zxt-120 v1.6 aircon controller, but given a soft reconfigure is required after every code set change, it would be easier with a lua script
  2. Hi, I am leveraging a bridge to interact with my sonos systems The command to invoke is simple.... http://192.168.1.89:5005/Bed5_Office/SAY/Hi but if I want to have more than one word i need to separate them with a %20 in the url ..like http://192.168.1.89:5005/Bed5_Office/SAY/Hi%20there Now if I drop the following url into a browser (note space between 'hi' and 'there') http://192.168.1.89:5005/Bed5_Office/SAY/Hi there It works !!!... ..but if i use it in a scene it doesn't I had this working from a scene before so I asked the developer of the sonos bridge and he said .. the last part is the important bit.....so my question is how can I get the http request in the scene to invoke the url so I don't have to add the %20 as spaces I tried a number of options but can only seem to find a way to encode headers or data but not the url I am 99% sure I had this working but in a recent overzealous clean up of my code I must have deleted the sample code that worked for me. Could anybody help ? Thanks -Frank
  3. Hi I am trying to create a script that will be triggered when another scene such as 'kids to bed' is run. I want to capture the id of the scene 'kids to bed' This is what I have so far but no luck --[[ %% autostart %% properties 490 sceneActivation %% events %% globals --]] local startSource = fibaro:getSourceTrigger() local ScID = startSource['deviceID'] local ScType = startSource['type'] fibaro:debug(ScType) fibaro:debug(ScID) so.. when scene 490 is run I want the above scene to run and whne this happens I want to be able to display the scene id ( in my example above it would be 490) Ultimately I am looking to create a scene which will trigger when any of my other scenes are run and I'll then email the date/time and scene id so i can see across my whole system what is running and when. I have a few scenes that don't seem to be running when they should be and I am looking to narrow it down. Thanks -Frank
  4. Is there an easy way to get the value of the main sensors for a room? Other than looping through all devices, checking their type, and checking their room or using the REST API? Hoping for a simple "Fibaro provided" method like fibaro:getValue(roomID, "lux") ID's aren't globally unique so I'm guessing functionality like this isn't going to work without a new specific method... Is querying http://localhost/api/rooms/roomID the easiest for the time being?
  5. Is there a way to determine whether a virtual device slider was changed by physically moving the slider or whether it was updated with LUA? This is for a now playing progress bar. In the slider's LUA script I want to ignore when the slider was updated by the main loop LUA code. fibaro:getSourceTrigger() sadly doesn't work for virtual devices. UPDATE: Issue resolved. Use fibaro:call(id, "setProperty", "ui.Slider1.value", position) to change the value and position of a slider without running the code in the slider. The slider on the web interface may not move without refreshing the page when this is called but it does work.
  6. Hi, Does anybody know if it is possible to run a scene to and extract a 'result from there scene via the API An example might be to check which sensors are triggered or zones are open/closed and just return open ones. I'm pretty sure I could run the scene and update a global variable and then just use the API to read the value of the global variable but I was wondering if there was a way to do it with just the scene Thanks -F
  7. Dear forum, As a newbie to LUA (although I have past experiences with C#, not extensive, again as a newbie) I'm interested in what other languages I also need to learn alongside LUA in order to be able to use / learn LUA. Are there any others I need to / should learn as well as LUA?
  8. hi all i have created a basic website that is basically a database of LUA code. Some is simple stuff and others a bit more complex. All of it i have tried to put into alphabetical order. At the moment it contains mostly the code i have used and there is a contact me page so that other members can send me code and i can add to this library. Also on there is a section for Virtual Devices, with download links and links back to the thread on this forum. im hoping that this should make finding LUA code easier and also the VD downloads a bit more accessible. thanks the link is: http://www.yorkshireautomation.co.uk/lua
  9. Hi folks, I'm looking for some help or some directing. I've searched the forum but can't find what I'm looking for even though it has to be there and tried before. I am trying to create a scene to read and adjust my heating system through the API The steps would be - login over http passing username and password. (this would activate a session) - read back the authentication code to use in next step - issue a post to the API to read or adjust the heating (over http) any help or pointing me to other forum posts would be appreciated Thanks Frank Edit: I've attached a wireshark trace export of the transaction requesting a 1 deg decrease. I blanked out some email addresses and site specific information for privacy. This is essentially what I am trying to replicate through a scene if it's possible. ws trace export.txt
  10. what is Devices polling time interval and how can i calculate it the best value?
  11. Hi every one! I am research Lua language in fibaro.But i met a problem i don't understand.I often see --[ [%% property --]]. (%%) what is this mean ?
  12. Hi, I had problems with a block scene on my HC2, so I let the system convert it to a Lua scene and worked from that. Now, the scene itself works (which was a problem before) both from manual activation in the app and from activation of a wall controller (device 54), but the timers do not work. Any ideas on why? And also - what is "%%events" in the generated header? I have not seen a description of this anywhere. --[[%% autostart %% properties 54 sceneActivation %% events %% globals --]] local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( -- Weekdays at 6:25 ( ((currentDate.wday >= 2 and currentDate.wday <= 6) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "06:25") ) -- Weekends at 7:00 or ( ((currentDate.wday == 1 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "07:00") ) or -- 30 minutes before sunset ( (os.date("%H:%M", os.time()+30*60) == fibaro:getValue(1, "sunsetHour")) ) or ( tonumber(fibaro:getValue(54, "sceneActivation")) == 20 ) or (startSource["type"] == "other") ) then fibaro:call(43, "turnOn"); fibaro:call(21, "setValue", "78"); fibaro:call(58, "turnOn"); fibaro:call(24, "setValue", "60"); end
  13. Hi, I have come across what I think is a limit to the number of words that the TTS engine can speak. The following scene lua will work --[[ %% properties %% events %% globals --]] -- Configuration - Device IDs local bid = 28 local sid = 1203 local params = { message = "the big furry cat sat on the mat", duration = 'auto', -- Duration: "auto", xx seconds language = "en-gb", -- Language: see http://www.voicerss.org/api/documentation.aspx to get your language code volume = 45, } local _f = fibaro local _x ={root="x_sonos_object",load=function(b)local c=_f:getGlobalValue(b.root)if string.len(c)>0 then local d=json.decode(c)if d and type(d)=="table"then return d else fibaro:debug("Unable to process data, check variable")end else fibaro:debug("No data found!")end end,set=function(b,e,d)local f=b:load()if f[e]then for g,h in pairs(d)do f[e][g]=h end else f[e]=d end;_f:setGlobal(b.root,json.encode(f))end,get=function(b,e)local f=b:load()if f and type(f)=="table"then for g,h in pairs(f)do if tostring(g)==tostring(e or"")then return h end end end;return nil end} -- Make a request to the remote to process params object instantly _x:set(tostring(sid), { tts = params }) _f:call(sid, "pressButton", bid) but if I replace the message line with a longer message it doesn't work. (no error is given) message = "the big furry cat sat on the mat and the dog sat on the floor", I think the limit seems to be around 46 characters (or perhaps its a time limit, ~2 seconds of speaking??) 'Guest' in the following post indicated that they had announcements that were much longer that 50 chars that were working fine with the 1.0.0 beta http://forum.fibaro.com/index.php?/topic/20662-sonos-remote-v100-beta/page-3 Is this a known issue or is there a fix out there... Thanks -F
  14. Hi, Looking for some input into the logic for a scene before I begin to code.... Background - I am looking to determine occupancy both upstairs and downstairs in my house. A lack of occupancy in either floor would then trigger lights/music/etc to be switched off. Lack of occupancy on both floors would assume no house occupancy (with some other checks ) and this can be used to auto-set our house alarm. No movement detected for 30 mins assume no occupancy. I am using my standard alarm PIR's as I can see status of those in my HC2 approach...for first floor... assume no occupancy (uo_occup = "no") 1) PIR trigger in landing starts scene 2) sets up_occup variable to 'yes' 3) start counter 4) recheck every 15 seconds - if PIR =yes then reset counter - if PIR = no then increment counter 5) if counter reaches 120 ( this is 30 mins at one check per 15 seconds) then set up_occupancy = 'no' 6) Scene stops Next breach starts the scene again Some peripheral checks to cover corner cases..... If Alarm = partsetA then up occupancy = yes and hence house occupancy = yes If Alarm = Fullset then house occupancy is no If back or front door is opened then down_occupancy = yes Do people think this would work or are they other approaches ? Thanks -F
  15. Hi, I'm new to Lua and I have read what I could find within the forum discussions. I'm trying to master the basics before I move on and wanted to check from one of the experts that my simple scene is structured as it should be. I have a HC2 and am running the latest FW 4.070 My scene below sets a global variable 'TOD_LightMode' to night, dusk or day depending on the light level from an outside sensor. It runs the scene and then sleeps for 15 mins and repeats. It seems to work okay and I have checked the global variable is available to other scenes and I have used it to trigger other activity. The few questions I have and hopefully somebody can provide advice... 1) do I have all the variables declared correctly ? (I have seen some included in the header in some examples but am not sure what to include there) 2) Is my autostart code correct ? 3) I have a lot of scenes in mind that would be "waiting" scenes. Many people use the while true do or while (someglobalvariable == "somevalue") method. Is there a limitation as to how many of these types of scenes can be running at the same time before it starts to use all the CPU/mem resources ? 4) Is there a simple error checking or logging method that I could/should be using with my scripts. 5) Any other suggestions that would be better practice or make my code more efficient Any help or suggestions very welcome ? Thanks -F Code as follows... --[[ %% autostart %% properties %% globals TOD_LightMode --]] -- Master Scene -- checks the light level to determine if it is night, dusk or day and set a global variable TOD_LightMode -- v1 Frank Smith local sourceTrigger = fibaro:getSourceTrigger(); local startSource = fibaro:getSourceTrigger(); local OutsideLuxSensor = 217 --outside sensor ID for light level if (sourceTrigger["type"] == "autostart") then while true do -- create an infinite loop if tonumber(fibaro:getValue(OutsideLuxSensor, "value")) == 0 then fibaro:setGlobal("TOD_LightMode", "night"); elseif tonumber(fibaro:getValue(OutsideLuxSensor, "value")) > 0 and tonumber(fibaro:getValue(OutsideLuxSensor, "value")) < 50 then fibaro:setGlobal("TOD_LightMode", "dusk"); else fibaro:setGlobal("TOD_LightMode", "day"); end; fibaro:sleep(15*60*1000) end else end
  16. Hi, I have a Thermo-Floor / Heatit Multireg thermostat controlling my floor heating. I was disappointed that it does not support power usage. So I wonder if it would be possible to somehow add to the device with LUA or a separate virtual device that accumulates wattage for the time it was active? I have not done very much LUA coding to know if this would be possible. Is it any point at pursuing this at all? An alternative would be to use an external actuator associated with the thermostat that supports power usage. But it would be more expensive and I'm not sure there is room in the wall box. Regards Stian
  17. Hi, I am new to Fibaro and I own \, for now, just an HCL plus several devices. I would like to create a Virtual device that toggles a predefined Variable. I have tried this: The code behind each button is, for now, just this: The idea is to to activate heating accordingly: This is the scene to turn Heater On This to turn it OFF Obviously it does NOT work.... What Have I done wrong? I cannot export my Virtual Device, is this doable with an HCL? Can I embed LUA coding in a Virtual Device within an HCL? Additional DREAM: can I change the Icon on my VD according to the Button pressed? Is DEBUGGING possible with an HCL? HOW? Many thanks in advance. Roberto
  18. Hi all I am trying to create a scene that changes the setpoint temperature of my Nest thermostat to 10 degrees after windows have been opened. I want the setpoint temperature to be set back to its previous setting once windows are shut. The first part is easy as I have used IFTTT with a Maker channel. But it doesn't look like it's possible to set it back to previous setting through IFTTT. I have the Nest plugin installed which works fine and when I create a new LUA scene, the only action event is 'SetMode' and looks as follows: fibaro:call(9, "setMode", "") Unfortunately there is not too much information available on this so any help would be much appreciated.
  19. Hi, I’m new to LUA and actually newer did the programing, except the pascal on high school J. However I like to learn the new staff, best way for me is learning by doing. I developed many block scenes and converted them into LUA to understand the way it works, but still have some questions I believe if answered, other users will find useful as well. This topic should be for explanation how LUA works. First question what is tempfunc() for and how to use it?
  20. Mayby a stupid question but I cannot find the ID of notifications. I want to send via LUA. I managed to find out de DeviceID via HC2 Toolkit but cannot find the number of notification. syntax of used call: fibaro:call(<ID>, "sendDefinedPushNotification", "<NotificationID>") Many thanks in advance
  21. Hello! I would like to know which char/fontset is used for displaying text in a virtual device? Some of the symbols I use are displayed properly some are not, especially in the android application: local grafik = "▄■▀■▄____▄▄▄▄■▀" mobile APP: webapplication: Is it also possible to change the color of the text? The string.format code does not work... fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); Thank's for help
  22. Im trying to control my foscam IP camera (PTZ and other) over the http commands. From any regular browser its a pice of cake. I would like to create virtual device where each button will represent specific command for camera control. I succeeded to create a scene with LUA to execute the commands: --[[ %% properties %% globals --]] local httpClient = net.HTTPClient(); httpClient:request('http://192.168.1.51:88/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Vchod&usr=AAA&pwd=BBB') However when I use the same code in VD with LUA, it doesn't work. I would like to avoid creating 10 scenes and call the scenes from VD, I would like to execute the code directly from VD. Is it possible? Thanx for any advice.
  23. I'm trying to find a clue on how to group two or more sonos speakers into a combined zone. (eg: kitchen and living room playing the same tracks). Searching the forum doesn't help me so far. Does anyone have any lua-code or code for a button in a virtual device to combine two players to 1 zone? or perhaps a link to en example?
  24. HI, Been wrestling with this for some time now so time to ask for help I'm trying to control my Yamaha Amp, no problem switching input sorces, scenes, on/off etc but when it comes to setting (and later reading) the volume I simply can't get it to work. I'm using a virtual device with a slider. In the LUA-code for the slider I've wrote the script below. When I change the slider the scripts works one in five times, the rest nothing happens. As far as I can tell it reads the slider value OK, the command sent is correct etc. To me it feels like I need to send some end command to the Yamaha but can't figure out how to do it. Any help or feedback is appreciated. Here is the script: local IPYamaha = "192.168.1.67" local pYamaha local cmdYamaha local YamahaValue YamahaValue = 8 * tonumber(_sliderValue_) YamahaValue = YamahaValue - 800 fibaro:log(tostring(YamahaValue)) cmdYamaha = '<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>' .. tostring(YamahaValue) .. '</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>' pYamaha = Net.FHttp(IPYamaha,80) response ,status, errorCode = pYamaha:POST('/YamahaRemoteControl/ctrl', cmdYamaha) fibaro:sleep(1000) if errorCode == 0 then fibaro:log('status'..status) else fibaro:log("error") end
  25. Hi I have a problem to understand why my lua-code not working as i expected. See first this (properly working) test-lua-scene and the debug-result: --[[ %% properties %% globals --]] globalmessage = " " -- function funcSections() local typename = "Sections" fibaro:debug(globalmessage .. typename) end; function funcRooms() local typename = "Rooms" fibaro:debug(globalmessage .. typename) end; function funcDevices() local typename = "Devices" fibaro:debug(globalmessage .. typename) end; -- fibaro:debug("before call function funcDevices--------------------") globalmessage = "Now call function funcDevices: " funcDevices(); -- fibaro:debug("before call function funcSections-------------------") globalmessage = "Now call function funcSections: " funcSections(); -- fibaro:debug("before call function funcRooms----------------------") globalmessage = "Now call function funcRooms: " funcRooms(); As expected first was the function "funcDevices" performed. Second the function "funcSections". And then at last the function "funcRooms". And now for my scene, which does not work as expected (code and result): --[[ %% properties %% globals --]] globalmessage = " " doneanswer = " " selHelpDRS = "{" Dm, Rm, Sm = 0, 0, 0; function funcDevices() local typename = "Devices" fibaro:debug(globalmessage .. typename) local http = net.HTTPClient() local urlIPP = 'http://127.0.0.1:11111' local urlAPI = '/api/devices' http:request(urlIPP..urlAPI, { options = { method = 'GET' }, success = function(jsonraw) local jssonrawlen = string.len(jsonraw.data) local jsontab = json.decode(jsonraw.data) local i1 = 0 local i1m = 0 selHelpDRS = selHelpDRS .. 'D:{' for k,v in pairs(jsontab) do i1m = i1m + 1 end for i1 = 1, i1m do local id = tonumber(jsontab[i1].id) local roomID = tonumber(jsontab[i1].roomID) local saveLogs = tostring(jsontab[i1].properties.saveLogs) or nil if ( roomID > 0 ) then if ( saveLogs == "true" ) then Dm = Dm + 1 if Dm > 1 then selHelpDRS = selHelpDRS .. ',' end selHelpDRS = selHelpDRS .. Dm ..':'.. jsontab[i1].id end end end selHelpDRS = selHelpDRS .. '}' fibaro:debug("selHelpDRS=" .. selHelpDRS) fibaro:setGlobal("selHelpDRS", selHelpDRS) end, error = function(errorcode) fibaro:debug("error=" .. errorcode) end}) http = nil doneanswer = "yes" end; function funcRooms() local typename = "Rooms" fibaro:debug(globalmessage .. typename) local http = net.HTTPClient() local urlIPP = 'http://127.0.0.1:11111' local urlAPI = '/api/rooms' http:request(urlIPP..urlAPI, { options = { method = 'GET' }, success = function(jsonraw2) local jssonraw2len = string.len(jsonraw2.data) local jsontab = json.decode(jsonraw2.data) local i1 = 0 local i1m = 0 selHelpDRS = selHelpDRS .. ',R:{' for k,v in pairs(jsontab) do i1m = i1m + 1 end for i1 = 1, i1m do local id = tonumber(jsontab[i1].id) if ( id > 0 ) then Rm = Rm + 1 if Rm > 1 then selHelpDRS = selHelpDRS .. ',' end selHelpDRS = selHelpDRS .. Rm ..':'.. jsontab[i1].id end end selHelpDRS = selHelpDRS .. '}' fibaro:debug("selHelpDRS=" .. selHelpDRS) fibaro:setGlobal("selHelpDRS", selHelpDRS) end, error = function(errorcode) fibaro:debug("error=" .. errorcode) end}) http = nil doneanswer = "yes" end; function funcSections() local typename = "Sections" fibaro:debug(globalmessage .. typename) local http = net.HTTPClient() local urlIPP = 'http://127.0.0.1:11111' local urlAPI = '/api/sections' http:request(urlIPP..urlAPI, { options = { method = 'GET' }, success = function(jsonraw3) local jssonraw3len = string.len(jsonraw3.data) local jsontab = json.decode(jsonraw3.data) local i1 = 0 local i1m = 0 selHelpDRS = selHelpDRS .. ',S:{' for k,v in pairs(jsontab) do i1m = i1m + 1 end for i1 = 1, i1m do local id = tonumber(jsontab[i1].id) if ( id > 0 ) then Sm = Sm + 1 if Sm > 1 then selHelpDRS = selHelpDRS .. ',' end selHelpDRS = selHelpDRS .. Sm ..':'.. jsontab[i1].id end end selHelpDRS = selHelpDRS .. '}' fibaro:debug("selHelpDRS=" .. selHelpDRS) fibaro:setGlobal("selHelpDRS", selHelpDRS) end, error = function(errorcode) fibaro:debug("error=" .. errorcode) end}) http = nil doneanswer = "yes" end; -- fibaro:debug("before call function funcDevices--------------------") globalmessage = "Now call function funcDevices: " doneanswer = "no" funcDevices() repeat fibaro:sleep(100) until doneanswer == "yes" ; -- fibaro:debug("before call function funcRooms----------------------") globalmessage = "Now call function funcRooms: " doneanswer = "no" funcRooms() repeat fibaro:sleep(100) until doneanswer == "yes" ; -- fibaro:debug("before call function funcSections-------------------") globalmessage = "Now call function funcSections: " doneanswer = "no" funcSections() repeat fibaro:sleep(100) until doneanswer == "yes" ; See the order of statements in the program. I would expected, first the function "funcDevices" was performed. Then, the second function "funcRooms" is performed. And last the function "funcSections". [DEBUG] 12:20:50: before call function funcDevices-------------------- In principle, the program is working properly. But the wrong order in run the functions de facto can not be explained to me: Order of call's: D R S = direction de facto: S R D Order of call's: R S D = direction de facto: S R D Order of call's: R D S = direction de facto: R S D Order of call's: S R D = direction de facto: S R D Here's someone who can tell me why my desired order is not complied with by the Fibaro-LUA-system? What should I do to make it work the way I want it?
×
×
  • Create New...