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!



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


  • 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


  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start






Website URL





  1. I have some device connected to z-wave plugs that can measure the energy consumption (devolo (Metering Plug MT:2646) and aeon labs (aeotec ZW075 v2) plugs are used). Now I would like every month a report how many kWh each of the plugs counted so far. Best would be to get that report by email. Is something like this possible in the HC2 eg with LUA? Can anybody help me to get started: - how to get the combined kWh from the devices - how to send an email - how to run the script only once per month thanks
  2. Hi, I am trying to connect to a secure web server, with a self-signed SSL certificate, using the net.HTTPClient() library in a scene. When I connect to the web server using my web browser, I get a warning telling me that the certificate is not certified by a valid authority, as you may have already seen on such certificate. In my web browser, I just click on the button to continue anyway. Firefox even allows me to add the certificate to the list of approved certificates. Problem solved But on HC2, I can't figure how to bypass the warning Here is the LUA code i use : local URL = "https://subdomain.domain.com/path" local httpClient = net.HTTPClient() httpClient:request(URL, { success = function(response) if response.status == 200 then -- Code to execute if successfull else fibaro:debug("Error : status=" .. tostring(response.status)) end end, error = function(err) fibaro:debug('httpClient:request() : Error : ' .. err) end, options = { method = 'GET', checkCertificate = false, } }) As you can see,I tried to use the "checkCertificate = false" option, but I doesn't seem to have any effect. I always get the following message : "sslv3 alert handshake failure" [DEBUG] 21:05:41: httpClient:request() : Error : sslv3 alert handshake failure The checkCertificate option seems to exist, as I found it as a string in the compiled binaries into the HC2. I tried both true and false boolean values, which seems to be accepted by the LUA interpreter, but I doesn't affect result as I would normally expect; If I try another value, such as a number or a string, I get a LUA Cast error and the script immediately ends. This is a proof that the checkCertificate parameter is used, but apparently with no effect. Can anyone confirm this strange behavior ? To Fibaro developers, can you confirm this parameter is correctly implemented ?
  3. Hi, Specific Lua question I'm hoping a more experienced member can help with. I have a 3-way momentary switch connected to a universal binary sensor which controls my Hue lights via Logic/Lua. I would like to increment the brightness of the Hue lights when the button is held down, I'm comfortable with the Hue control I just don't know how to increment the value for brightness when the button is held. I've attached a screenshot of the scene that I need to add the functionality to, the brightness value is represented by question marks. Any help would be greatly appreciated. Ryan PS. If anyone would like to know how to trigger a Hue Scene or change the state of a Hue Group I'll post something up.
  4. Hi, I have a Home Energy monitor (HEM2) and have the clamp in the main live into my meter box to try and understand what the house is drawing power wise. I seem to be getting two power readings that are different with both changing over time but none seem fully accurate. One power reading seems accurate some times and the other power reading seems more accurate at other times if I look at what is running in the house at the time. I have only one clamp but the inclusion created 12 devices in in total 1471 (device id = 1471) 1471.0 & 1471.0.1, 1471.0.2 (device ID 1472, 1473, 1474) 1471.1 & 1471.1.1, 1471.1.2 (device ID 1475, 1476, 1477) 1471.2 & 1471.2.1, 1471.2.2 (device ID 1478, 1479, 1480) 1471.3 & 1471.3.1, 1471.3.2 (device ID 1481, 1482, 1483) I can get power readings on 1472 & 1475 1472 - api details (power = 895.79w) {"id":1472,"name":"House Energy 1","roomID":234,"type":"com.fibaro.energyMeter","baseType":"com.fibaro.meter","enabled":true,"visible":true,"isPlugin":false,"parentId":1471,"remoteGatewayId":0,"interfaces":["energy","power","zwave"],"properties":{"parameters":[{"id":3,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":5,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":6,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":7,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":9,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":10,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":11,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":101,"lastReportedValue":14,"lastSetValue":14,"size":4,"value":14},{"id":102,"lastReportedValue":590080,"lastSetValue":590080,"size":4,"value":590080},{"id":103,"lastReportedValue":2049,"lastSetValue":2049,"size":4,"value":2049},{"id":111,"lastReportedValue":-740793856,"lastSetValue":-740793856,"size":4,"value":-740793856},{"id":112,"lastReportedValue":120,"lastSetValue":120,"size":4,"value":120},{"id":113,"lastReportedValue":1800,"lastSetValue":1800,"size":4,"value":1800}],"zwaveCompany":"AEON Labs","zwaveInfo":"3,3,67","zwaveVersion":"1.19","pollingTimeSec":0,"configured":"true","dead":"false","deviceControlType":"0","deviceIcon":"102","emailNotificationID":"0","emailNotificationType":"0","endPointId":"0","energy":"1379.51","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"false","model":"","nodeId":"212","parametersTemplate":"317","power":"895.79","productInfo":"0,134,0,2,0,28,1,19","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","serialNumber":"","showEnergy":"true","smsNotificationID":"0","smsNotificationType":"0","unit":"kWh","useTemplate":"true","userDescription":"","value":"0.00"},"actions":{"reconfigure":0,"reset":0},"created":1480078127,"modified":1480078127,"sortOrder":406} 1475 - api details (power = 2.44 kw) {"id":1475,"name":"House Watts","roomID":234,"type":"com.fibaro.energyMeter","baseType":"com.fibaro.meter","enabled":true,"visible":true,"isPlugin":false,"parentId":1471,"remoteGatewayId":0,"interfaces":["energy","power","zwave"],"properties":{"parameters":[{"id":3,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":5,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":6,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":7,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":9,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":10,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":11,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":101,"lastReportedValue":14,"lastSetValue":14,"size":4,"value":14},{"id":102,"lastReportedValue":590080,"lastSetValue":590080,"size":4,"value":590080},{"id":103,"lastReportedValue":2049,"lastSetValue":2049,"size":4,"value":2049},{"id":111,"lastReportedValue":-740793856,"lastSetValue":-740793856,"size":4,"value":-740793856},{"id":112,"lastReportedValue":120,"lastSetValue":120,"size":4,"value":120},{"id":113,"lastReportedValue":1800,"lastSetValue":1800,"size":4,"value":1800}],"zwaveCompany":"AEON Labs","zwaveInfo":"3,3,67","zwaveVersion":"1.19","pollingTimeSec":0,"configured":"true","dead":"false","deviceControlType":"0","deviceIcon":"102","emailNotificationID":"0","emailNotificationType":"0","endPointId":"1","energy":"1379.51","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"TxtGreen","manufacturer":"","markAsDead":"false","model":"","nodeId":"212","parametersTemplate":"317","power":"2436.61","productInfo":"0,134,0,2,0,28,1,19","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","serialNumber":"","showEnergy":"true","smsNotificationID":"0","smsNotificationType":"0","unit":"W","useTemplate":"true","userDescription":"","value":"0.00"},"actions":{"reconfigure":0,"reset":0},"created":1480078127,"modified":1480078127,"sortOrder":409} The energy readings from both are the same Does anybody know which parameter I should be using thanks frank
  5. Hi all, How do I get te currently set temperature from a heating panel of a certain room to use in a scene? I'm trying to do the following. I have a scene looping to switch the boiler on and off depending on the current temperature in a room. For each room I have a heating panel and a danfoss value on each radiator. I use this value to readout the currently set temperature (which is done through the heating panel). This works very fine. However, in my living room i have floor heating without a danfoss value. I like to also program different temperatures using the heating panel but for that i need to get the set temperature from the panel instead of from the danfoss valve. How? Hope someone can help me out... Any help is much appreciated!
  6. Hi I'm having a little hard time for whatever reason on getting JSON string into local variables in a VD. The JSON string is: [{"sensorTemp": "23.68", "sensorHumidity": "25.50", "sensorPressure": "1014.22", "sensorBattery": "3145"}] my code for this: jsonTable = json.decode(response) fibaro:debug("response: " .. response) local temperature = jsonTable.sensorTemp local humidity = response.sensorHumidity local pressure = response.sensorPressure local battery = response.sensorBattery I have also tried printing the key value pairs but I never got anything into the debug window... Any pointers appreciated! Thanks, Timo L
  7. Hello, everybody! I stuck in a problem. I tried to setValue for few dimmers simultaneously with no luck. Initial: dimmer = {754, 441, 435, 747, 682, 481}; -- dimmer IDs on = {99, 99, 99, 99, 99, 99}; -- values for ON (accordingly) off = {0, 0, 0, 0, 0, 0}; -- values for OFF (accordingly) Then I make a loop to set all the values: for i = 1, #dimmer do fibaro:call(dimmer[i], "setValue", on[i]); end What could be simpler? But not as it seems... Usually, first few dimmers accept "setValue" command and successfully set up. But few last ones set up the desired level with a big lag (2-20 seconds) or even have no reaction at all. I thought it is because of z-wave network be overloaded within multiple commands were sent during a short period of time. I tried to make some pause between each fibaro:call for i = 1, #dimmer do fibaro:call(dimmer[i], "setValue", on[i]); fibaro:sleep(500); end But it has no effect also. I tried to make an acknowledgment mechanism: for i = 1, #dimmer do while tonumber(fibaro:getValue(dimmer[i], "value")) ~= on[i] do fibaro:debug("! SETVALUE ATTEMPT !"); fibaro:call(dimmer[i], "setValue", on[i]); fibaro:sleep(500); end end It helps - all dimmers eventually set up. But regarding debug screen, a number of attempts were needed for some dimmers to setValue. So time to setValue for all 6 dimmers varies from 3 to 20 seconds. So the question is there some method available for setting up multiple dimmers (or any other actors) with values. Something like this: fibaro:call({754, 441, 435, 747, 682, 481}, "setValue", {99, 99, 99, 99, 99, 99}); So it will be not a number of sequential commands but one "broadcast command" for example? Thanks for helping!
  8. I have written an enhancement scripts for boosting the heating in certain rooms based on presence. I already have a zwave boiler controller, and LC-13 radiators with a scripted running base heating scene.. The purpose of this is for certain rooms that meet the following criteria:- 1. Don't need to be heated to comfort level all the time in the heating panel 2. Presence is detected, and the user tends to be in the room for a good amount of time. 2 initial rooms for me are Study and Living Room I wrote it based on tabulated data, so I could just add additional information into the tables for inclusion, but my lua was "stretched" and there are a lot of loops in loops... it runs fine, but I wondered if anyone wanted to demonstrate how it SHOULD be written or if you want to use it, and you have radiator set points you would like to boost, feel free... heating_enhancement.txt
  9. Hi @T.Konopka We can change set or dynamically the icon for a virtual device using the following in lua fibaro:call(device, "setProperty", "currentIcon", 1960) Is there an equivalent command for a scene Thanks -f
  10. How to get user id who start scene or press button on device in app? I would like to send message about result only for him/her and not for everyone ... Thanks for any advice.
  11. Hi Does anybody know if it is possible to specify the icon for a scene or a VD within the la itself as opposed to the usual method Thanks -f
  12. Witam, może ktoś z was podpowiedzieć, gdzie określana jest wartość wielokrotności kliku Keyfob'a w kodzie LUA, ponieważ wartości po utworzeniu schematu blokowego nie działają poprawnie. Mianowicie problem mój polega na: -Chcę włączyć część oświetlenia jednym wciśnięciem przycisku pierwszego (kwadratu) na Keyfob'ie -Natomiast listwy LED chcę włączyć podwójnym wciśnięciem przycisku pierwszego (kwadratu) na Keyfob'ie Mimo skorzystania z schematu blokowego do utworzenia takiej sceny, wszystko reaguje na pojedyncze wciśnięcie przycisku (czyli zapala się oświetlenie i listwy led), mimo, że listwa led jest ustawiona tak, aby reagowała na 2 kliknięcia. Analogicznie jest w przypadku ustawienia, aby oświetlenie i listwy led się wyłączyły, ale tym razem na przycisku drugim (kółko). Mam jeszcze pytanie, czy jak ustawię, aby oświetlenie reagowało na jedno wciśnięcie, a listwy led na dwa wciśnięcia, to czy centralka/keyfob odróżni, że wcisnąłem dwa razy a nie raz, po to aby nie zapalać oświetlenia, a tylko listwy led na dwa wciśnięcia? Centralka - Home Center 2 Urządzenia: Keyfob, Double switch, RGBW Controller Pozdrawiam, Krzysztof
  13. Hi everyone, I'm having some issues with Lua code in a virtual device I am writing. I'm getting information on the status of my Bluespray irrigation controller. It has a basic API and reports if any of the zones are on watering. I want to just query the unit and then print out if any are detected as on. When I query bluespray controller and its not watering anything I get some JSON back which looks like this. { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ ], "timestr": "Sat Mar 11 2017 10:09:38 PM", "time": 1489241378000, "door": 0 }, "id": 528452 } When its IS watering I get the following. { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ { "on": 1489240754, "off": 1489241054, "run": 1489240754, "terminal": 3 } ], "timestr": "Sat Mar 11 2017 10:00:12 PM", "time": 1489240812000, "door": 0 }, "id": 218829 } To make it even more complex sometimes the system reports multiple zones operating. (This is normal and ok. I just need to pick up the first zone reported) { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ { "on": 1489241854, "off": 1489241974, "run": 1489241854, "terminal": 4 }, { "on": 1489241854, "off": 1489241974, "run": 1489241854, "terminal": 8 } ], "timestr": "Sat Mar 11 2017 10:17:38 PM", "time": 1489241858000, "door": 0 }, "id": 998161 } My issue is detecting if I get none, one or multiple active zones. If I have a valid zone then I then want to put the first zone number into the zoneterminal variable. If I don't have a valid zone I just want to put 0 into the zoneterminal variable. The problem is when I try something like the code below I get [ERROR] 22:11:22: line 56: attempt to index field '?' (a nil value) I cant figure out how to deal with LUA arrays correctly. (specifically detecting valid entries) The json.null operator does not seem to work the same way on array values. -- This script polls data from a local Bluespray Irrigation controller every 60 seconds and displays the status of the active zones -- Its configured for a speicific system but could easily be adapted to any bluespray controller. -- This script is written for Fibaro HC2 -- Script written by Brom ([email protected]) -- version 0.1 (10/3/17) function round(x, n) n = math.pow(10, n or 0) x = x * n if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end return x / n end fdata = {} zonename_1 = "Front Lawn" zonename_2 = "Road Lawn" zonename_3 = "Front Garden" zonename_4 = "Back Lawn Left" zonename_7 = "Back Lawn Right" zonename_5 = "Back Garden Left" zonename_6 = "Back Garden Right" fdata.selfId = fibaro:getSelfId() fdata.selfIp = fibaro:get(fdata.selfId, "IPAddress"); -- Perform the grab from the irrigation controller. local irrigationcontroller= Net.FHttp(fdata.selfIp); response,status,errorCode = irrigationcontroller:GET("/api/status") -- Basic debugging fibaro:debug(response) -- Check the respose from the controller is valid and Pull out the details from the JSON response. if (tonumber(status)==200 and tonumber(errorCode)==0) then local irrigation = json.decode(response) -- If any of the responses are null then make them 0 if irrigation.result.time == json.null then polltime = 0 else polltime = irrigation.result.time end -- this bit does not work !!!! zoneterminal = irrigation.result.active_zones[1].terminal zoneon = irrigation.result.active_zones[1].on zoneoff = irrigation.result.active_zones[1].off zonerun = irrigation.result.active_zones[1].run -- Basic Debugging fibaro:debug("polltime: "..polltime) fibaro:debug("zoneterminal: "..zoneterminal) fibaro:debug("zoneon: "..zoneon) fibaro:debug("zoneoff: "..zoneoff) fibaro:debug("zonerun: "..zonerun) timeleft = (zoneoff - zonerun) / 2 / 60 fibaro:debug("timeleft: "..timeleft) -- Output to the device. if zoneterminal == 0 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," OFF ") end if zoneterminal == 1 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_1) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 2 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_2) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 3 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_3) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 4 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_4) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 5 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_5) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 6 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_6) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 7 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_7) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 0 or zoneterminal == 1 or zoneterminal == 2 or zoneterminal == 3 or zoneterminal == 4 or zoneterminal == 5 or zoneterminal == 6 or zoneterminal == 7 then fibaro:debug("Valid Zone") else fibaro:call(fdata.selfId, "setProperty", "ui.watering.value","Error") end else fibaro:debug("error Irrigation Controller: "..errorCode) end -- sleep for 1 min fibaro:sleep(10000) -- fibaro:sleep(60000) Any help appreciated. ps Code for the output is really extra long. Looking to understand how I can manipulate the variable name / number I am outputting to reduce the number of if statements. Once I get this figured out I plan to also add in buttons to perform manual runs. Brom
  14. I'd like to see an optional parameter added that will disable triggering scenes when setting a global variable in LUA. The HTTP API has this functionality albeit in reverse (default to false) Something along the lines of: fibaro:setGlobal( varName, value [, invokeScenes] ) Where: varName: The name of the global variable value: The new value of the global variable invokeScenes: Boolean, default true
  15. Hi Wondering why we don't have resizable txt boxes in the LUA scripting page ? It's not often I code in LUA in HC2, but when I do .. gee it's annoying Thanks, al.
  16. Hi Fibaro users Many of us are experiencing a very strange bug since a long time that kill our scenes. This bug appear without any reasons after several hours/days without any problems, it's a major issue that give us the feeling that the Fibaro box is not reliable. Just to give you my example of yesterday evening 19:41:06 : [DEBUG] 07:07:03: Module Parents (128) pressButton to 1 [DEBUG] 07:07:03: Module Espace Famille (123) pressButton to 1 [DEBUG] 07:07:03: Date : 2017/03/07 07:07:03 [DEBUG] 19:41:06: line 35: unexpected character @ character: 1 0:1 [�] line: [DEBUG] 19:41:06: � [DEBUG] 19:41:19: Redémarrage auto du script Réveil Matin (106): 2017/03/07 19:41:19 [DEBUG] 07:00:00: Réveil matin enclenché [DEBUG] 07:00:09: Ouverture volets matin phase 1 [DEBUG] 07:00:15: Module Parents (128) pressButton to 2 I saw several subjects in this forum with the same problem but without any clear answer to the problem, for examples : https://forum.fibaro.com/index.php?/topic/22964-script-terminated-garbage-in-log-script-error-line-incorrect/#comment-100942 https://forum.fibaro.com/index.php?/topic/22658-scene-keeps-quitting-on-error/#comment-99007 https://forum.fibaro.com/index.php?/topic/23955-vdscene-weather-status-v10b-netatmo-weather-station-rain-wind/#comment-108439 https://forum.fibaro.com/index.php?/topic/22801-issue-in-scene-after-update-to-41/#comment-99865 As you can see in the sample, i'm using (like many of us) another scene to check that the main scene is still active or not, and if not, to restart it. In french forums, users have done a specific virtual device to check scenes and vd. It seems it's a Lua bug that can be solved only by Fibaro. Could someone in Fibaro check that point to finally solve it one time for all? PS : Sorry for my english...
  17. Hi, I have external lights. I use geolocation with ifttt. When I arrive near my house my lights turn on automatically. But it must light up when it is dark. At sunset. I created one variable : I created 3 scenes. First scene : --[[ %% autostart %% properties %% weather %% events %% globals --]] local sourceTrigger = fibaro:getSourceTrigger(); function tempFunc() local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( ( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == fibaro:getValue(1, "sunsetHour")) ) ) then fibaro:setGlobal("ext", "1"); end setTimeout(tempFunc, 60*1000) end if (sourceTrigger["type"] == "autostart") then tempFunc() else local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( startSource["type"] == "other" ) then fibaro:setGlobal("ext", "1"); end end My first scene Sets my variable to 1 when the sun goes down My second scene sets my variable to 0 when the sun rises. --[[ %% autostart %% properties %% weather %% events %% globals --]] local sourceTrigger = fibaro:getSourceTrigger(); function tempFunc() local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( ( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == fibaro:getValue(1, "sunriseHour")) ) ) then fibaro:setGlobal("ext", "0"); end setTimeout(tempFunc, 60*1000) end if (sourceTrigger["type"] == "autostart") then tempFunc() else local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( startSource["type"] == "other" ) then fibaro:setGlobal("ext", "0"); end end And My third scene that executes the lighting of my lights when ext = 1 and that the sun goes down. --[[ %% properties %% weather %% events %% globals ext --]] local startSource = fibaro:getSourceTrigger(); if ( ( tonumber(fibaro:getGlobalValue("ext")) == tonumber("1") ) or startSource["type"] == "other" ) then fibaro:call(32, "turnOn"); end I have a problem, It makes day or night my scene of lighting my lights work all the time. I don't understand. One idea ? if you can help me please. Thx.
  18. hi guys, is there a way to expand the tiny lua editor window? I find it very hard to code in there. thanks for any hints. kro
  19. Hi, I have two functions in a scene that I call one after the other function1 - create global variable if it doesn't exist (through the api) function2 - write some data to the global variable the second function will fail as the 'create variable' hasn't been completed by the time I try to write to it. I can add a delay or a check that the 'variable is not nill' (ie it exists) in function2 but it still fails to execute correctly I think I recall seeing that a http request in a scene will not always run in the order of the scene ? is this correct or something else here at play. If so has anybody found a way within a single scene to create a variable on the fly and then save data to it successfully. As a last resort I was thinking about having the scene run once to create the table, call a second instance of itself and kill the first instance. I'm not sure if this would even work but it seemed like a very inefficient workaround even if possible I have seen many virtual device examples of creating a variable on the fly and saving data to it but none from a scene Thanks -f @jompa68, @petergebruers, @Sankotronic
  20. Hi, I've been looking to find a way to mimic a dawn awakening using a RGB strip driven by a fibaro RGB module @petergebruers provided some RBG / HSL translation and I've been working on the colour sequence that is stored in an array It's essentially burnt orange -> yellow -> blue'ish -> almost white There area few of the transitions I am not 100% happy with but I was looking for a few people to test what I have done to date and see if I am on the right path The scene has a sleep of 1 second but in reality I'd probably have it close to 10 or 15 which would give an overall start to finish time of -10 minutes to aid a gradual wakeup Comment out line 7 if you don't use a HomeTable Line 61 contains the reference to the RGB strip, amend as required. @andyp - You expressed an interest in this before All feedback welcome - Feel free to tweak the colors or just pass back comments Thanks -f -- DAWN SIMULATOR USING AN RGB STRIP -- THANKS TO petergebruers FOR THE BULK OF THE CODE -- BETA --[[ %% properties %% events %% globals --]] local jT = json.decode(fibaro:getGlobalValue("HomeTable")) --Hue_2_RGB( v1, v2, vH ) function Hue_2_RGB(v1, v2, vH) if ( vH < 0 ) then vH = vH + 1 end if ( vH > 1 ) then vH = vH - 1 end if ( ( 6 * vH ) < 1 ) then return ( v1 + ( v2 - v1 ) * 6 * vH ) end if ( ( 2 * vH ) < 1 )then return ( v2 ) end if ( ( 3 * vH ) < 2 ) then return ( v1 + ( v2 - v1 ) * ( ( 2 / 3 ) - vH ) * 6 ) end return ( v1 ) end function RGB(H,S,L) if s==0 then return L*255,L*255,L*255 end local var_2 if ( L < 0.5 ) then var_2 = L * ( 1 + S ) else var_2 = ( L + S ) - ( S * L ) end local var_1 = 2 * L - var_2 return 255 * Hue_2_RGB( var_1, var_2, H + ( 1 / 3 ) ) , 255 * Hue_2_RGB( var_1, var_2, H ), 255 * Hue_2_RGB( var_1, var_2, H - ( 1 / 3 ) ) end local R,G,B=RGB(120,0.5,0.5) fibaro:debug("R "..R.." G "..G.." B "..B) R,G,B=RGB(120,0,0.5) fibaro:debug("R "..R.." G "..G.." B "..B) local dawnHSL={ {0,0,0}, -- turn off. {0.03,0.67,0.012}, {0.04,0.68,0.013}, {0.06,0.69,0.014}, {0.08,0.70,0.015}, {0.09,0.71,0.016}, {0.10,0.73,0.017}, {0.12,0.75,0.018}, {0.13,0.77,0.019}, {0.15,0.79,0.020}, {0.19,0.83,0.022}, {0.20,0.84,0.023}, {0.21,0.86,0.024}, {0.22,0.87,0.023}, {0.23,0.89,0.026}, {0.25,0.91,0.028}, {0.41,0.90,0.033}, {0.41,0.88,0.034}, {0.41,0.86,0.035}, {0.42,0.85,0.036}, {0.43,0.83,0.037}, {0.44,0.81,0.038}, {0.44,0.79,0.038}, {0.44,0.78,0.040}, {0.45,0.77,0.041}, {0.45,0.75,0.042}, {0.44,0.73,0.043}, {0.46,0.72,0.044}, {0.46,0.70,0.045}, {0.47,0.69,0.046}, {0.47,0.67,0.047}, {0.48,0.66,0.048}, {0.49,0.63,0.049}, {0.50,0.61,0.050}, {0.51,0.58,0.051}, {0.52,0.56,0.052}, {0.53,0.53,0.053}, {0.54,0.51,0.054}, {0.55,0.48,0.055}, {0.56,0.46,0.056}, {0.58,0.44,0.057}, {0.59,0.42,0.058}, {0.59,0.39,0.059}, {0.59,0.37,0.060}, {0.60,0.35,0.061}, {0.60,0.32,0.062}, {0.60,0.28,0.063}, {0.60,0.24,0.064}, {0.61,0.22,0.065}, {0.61,0.20,0.066}, {0.61,0.18,0.067}, {0.61,0.16,0.068}, {0.61,0.15,0.069}, {0.61,0.14,0.070}, {0.61,0.13,0.071}, {0.61,0.12,0.072}, {0.60,0.11,0.073}, {0.60,0.10,0.074}, {0.60,0.09,0.075}, {0.60,0.08,0.076}, {0.60,0.07,0.077}, {0.60,0.05,0.078}, {0.60,0.05,0.079}, {0.60,0.05,0.080}, {0.60,0.05,0.082}, {0.60,0.04,0.083}, {0.60,0.03,0.084}, {0.60,0.02,0.085}, {0.60,0.01,0.086}, {0.60,0.02,0.087}, {0.60,0.01,0.088}, } fibaro:debug(string.format("R G B ")) for k,v in pairs(dawnHSL) do local R,G,B=RGB(v[1],v[2],v[3]) fibaro:debug(string.format("%05.1f %05.1f %05.1f",R,G,B)) fibaro:call(jT.master_bedroom.LEDLight, "setColor",math.floor(R+0.5), math.floor(G+0.5), math.floor(B+0.5), "0") fibaro:sleep(1000) end
  21. Hi! I am working on my first VD and I want to change the text of a button during runtime. fibaro:call(SelfId, "setProperty", "ui.Button21.Label", "new text") fibaro:call(SelfId, "setProperty", "ui.Button21.value", "new text") None of the calls on top is working, I am a little bit frustrated Change a slider value or a text of a label is working fine Any help is welcome ...
  22. Hi, Changing this post a little to generate some discussion around good morning sequences and what people are currently or planning to do. I'm hoping to get some ideas myself and may also help some people just starting this journey.. I'll start - This is my good morning sequence and it's triggered on weekdays at 6:40 and 8:00 on weekends by a scheduler derived from @Sankotronic Main Scene code. Music control is with the sonos-htt-api and TTS is AWS Polly. I have some sleep steps that I removed to allow some actions to finish before others start or just to provide seperation. Group 4 music zones upstairs using sonos api presets, select zones, radio station and play at zero vol Change radio station if station not available Set home mode (This may be redundant) Set sleepstate to Awake mode Switch ON Satelite Box Raise vol in master bedroom slowly to preset level Raise music vol in landing room slowly to preset level Raise music vol in kids1 room room slowly to preset level Raise music vol in kids2 room room slowly to preset level Set alarm to UNSET TTS Morning Greeting (weather, temp etc) - Master Bedroom Switch main bathroom mirror light on for kids TTS Morning Greeting (weather, etc)- kids1 room TTS Morning Greeting (weather, etc)- kids2 room Wait for motion trigger in kitchen and switch on kitchen spotlights Slowly raise the other lights to preset levels Slowly raise the kitchen, hall and playroom music to preset levels What else are other people doing ? Thanks -f
  23. Hi, I have some Merten/Schneider Eletric radio push button "switches" I would like to use as trigger for turning on and off lights in a room but I do not know what code I would need to use for this to work. The push button in question is Schneider Eletric WDE002903/ Merten MTN5051-0000. Has anyone used this kind og buttons in their Fibaro HC2 system and/or is able to give input on what code is needed to use this as a trigger? Thanks for all help, Kristoffer Merten MTN5051-0000.pdf
  24. Hi, I have been working to automate more of my morning routine and wanted to share what I have to date Questions, ideas, comments, refinements welcome -f --[[ %% properties %% events %% globals --]] local jT = json.decode(fibaro:getGlobalValue("HomeTable")) if (fibaro:countScenes()>2) then fibaro:abort() end fibaro:call(jT.vd.SonosPresets, "pressButton",2) -- Group zones, select radio and play at zero vol fibaro:sleep(5000) -- sleep 5 seconds for preset to complete fibaro:call(jT.vd.SonosPresets, "pressButton",16) -- Change radio station if station not available fibaro:sleep(5000) -- sleep 5 seconds for channel selection fibaro:setGlobal( "House_Mode", "HOME") -- set home mode (This may be redundant) fibaro:setGlobal(sleepState, sleepStateMapping.Awake) -- Set sleepstate to Awake fibaro:call(jT.vd.MediaSourcePresets, "pressButton",3) -- Switch ON Sat Box fibaro:call(jT.vd.SonosPresets, "pressButton",13) -- raise vol in master bedroom slowly fibaro:sleep(3000) -- sleep 30 seconds fibaro:call(jT.vd.SonosPresets, "pressButton",14) -- raise vol in landing room slowly fibaro:sleep(3000) -- sleep 30 seconds fibaro:call(jT.vd.SonosPresets, "pressButton",11) -- raise vol in twins room slowly fibaro:call(jT.vd.SonosPresets, "pressButton",12) -- raise vol in franks room slowly fibaro:sleep(30000) -- sleep 30 seconds fibaro:call(jT.vd.AlarmManagement, "pressButton",16) -- Set alarm to UNSET fibaro:sleep(5000) -- sleep 5 seconds fibaro:call(jT.vd.SonosTTS, "pressButton",14) -- Morning Greeting (weather, temp etc) - Master Bed fibaro:call(jT.bathroom.MirrorLight, "turnOn") -- main bathroom mirror light on fibaro:sleep(30000) -- sleep 30 seconds fibaro:call(jT.vd.SonosTTS, "pressButton",15) -- Morning Greeting (weather, etc)- Twins Room fibaro:sleep(20000) -- Sleep for 20 seconds to let greeting finish fibaro:call(jT.vd.SonosTTS, "pressButton",16) -- Morning Greeting (weatherm, etc)- Franks Room fibaro:sleep(900000) -- sleep 15 mins fibaro:call(jT.vd.LightsPresets, "pressButton",21) -- Kitchen Morning Lights scene
  25. Hoping someone can shed some light on this... Trying to send a HTTPS GET request to an AWS API Gateway endpoint. Here's the Lua code (obviously I've removed any privileged information for the purposes of posting here): httpClient = net.HTTPClient(); httpClient:request ( 'https://**********.execute-api.eu-west-1.amazonaws.com/****/***********', { options = { method = "GET", headers = { ['x-api-key'] = '*****************************' } }, success = function (response) fibaro:debug (response.data) end, error = function (err) fibaro:debug ("Error:" .. err) end }) I get an 'Error:Transport endpoint is already connected' message in the debug window. That's not a response from the API (no requests get logged on the AWS side, so the HC2 isn't getting as far as making the request at all.) If I try making a HTTPS request to another URL (like Google for example) it works with no issue. Also I know the API endpoint works, because I can call it from CURL and it does exactly what I expect. It's just from a scene. Seems like others have had the same issue, specifically with AWS API Gateway. Anyone know how to get this to work? Cheers, Dan
  • Create New...