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. This is not a question but a small contribution, if anyone should be interested. The task was this: How can I control indoor ventilation to avoid temperature/humidity combinations that risk growth of mold or mildew? The first trick was to find a simple formula for this risk zone. I used a calculator in www.dpcalc.org which indicates risk/no risk for a given temp/hum combination. Testing this for realistic values for normal indoor or basement use, I found this simple linear correlation would work: Humidity limit (%) = 91.2 - 1.184 * temp For temp>22 the limit is set constant at 65 %. Temperature is in degrees C. Example: If the temperature is 10 C, the relative humidity should stay below 79.4% to avoid the risk of mold growth. Assuming you have one or several ventilation fans, and one or several temperature/humidity measurements, you can use this to start the fans when the humidity level exceeds the limit. Alternatively, you can increase the set point for a relevant heater, to increase temperature and reduce relative humidity in the room. A push warning to the owner could also be included. I have chosen to only start the ventilation fans, and I include a small LUA script to achieve this. My temperature/humidity measurements are from two Aeotec Multi6 units, but any such sensor may be used. Feel free to implement any part of this script to suit your purpose. Please share here if you use these ideas in other ways or have related ideas yourself. Moldfan_demo.lua
  2. Hi everyone, is there any way how to obtain (access) information from HC2 heating schedules in LUA scripts? I need to work with information about what temperature and when it is going to be set in some particular rooms. I can workaround this by making heating schedules sort of static and completely overpass heating panel in HC2, but that would be a bit contra productive, right? Thanks Edit: BTW my first post here, so please be gentle
  3. Several posts on this forum recommend including a check in LUA scenes to ensure that only one instance of the scene is currently running. The recommended code is similar to this: if fibaro:countScenes() > 1 then scenes = fibaro:countScenes() fibaro:debug(os.date("%d %b").." Scenes active "..scenes) fibaro:abort(); end The main panel for each scene, however, includes a parameter controlling max. running instances: Why is it necessary to include the extra code, if this parameter already limits the scene to one active instance? Is it only to get the explicit warning from the fibaro:debug() command?
  4. Witam Mam prośbę, czy mógłby mi ktoś rzucić okiem na kod pętli głównej urządzenia wirtualnego? Mianowicie chodzi o to, że urządzenie działa poprawnie, służy do sterowania klimakonwektorem, jednak nie wyświetla mi stanu poszczególnych elementów na etykietach. Co zrobiłem źle w kodzie pętli głównej? klima_salon_2(1).vfib
  5. I have created different scenes in the block scene editor. These are all working except for the one that should do the following: 1. When I arm the alarm, the door sensor is armed. 2. When I open the door it should give me 10 seconds before the alarm goes off. 3. If I disarm the alarm, therefore disarm the door sensor within 10 seconds the alarm should not go off. This all works fine with a minor detail: if I shut the door within 10 seconds the alarm does not go off, while it should go off unless I have disarmed the alarm. I have tried the following block scene: First I tried stating at the device that if it's armed and breached it should trigger and I put a 10 second delay at the end. That did not work. Then I tried the above method checking if the door is device is triggered while armed and breached AND if after 10 seconds the device is NOT disarmed. By the way I also tried the statement if after 10 seconds it IS armed. Both with the same result: If I close the door quickly enough, I'm inside and the alarm is not triggered. Then I thought that maybe it just does not work that well within the block scenes. So I transfered it to LUA (automatic method by Fibaro). The LUA code I get, looks horrendous though. I'm not a developer, but this does not look as very well written code to me. --[[ %% properties 200 value 200 armed %% weather %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if(startSource["type"] == "other") then fibaro:call(49, "turnOn"); fibaro:call(104, "turnOn"); fibaro:startScene(12); fibaro:call(203, "sendDefinedPushNotification", "4"); fibaro:call(207, "sendDefinedPushNotification", "4"); setTimeout(function() fibaro:call(49, "turnOff"); fibaro:call(104, "turnOff"); end, 900000) else if (( (tonumber(fibaro:getValue(200, "value")) > 0 and tonumber(fibaro:getValue(200, "armed")) > 0) ) and ( tonumber(fibaro:getValue(200, "armed")) ~= 0 )) then local delayedCheck0 = false; if ( (tonumber(fibaro:getValue(200, "value")) > 0 and tonumber(fibaro:getValue(200, "armed")) > 0) ) then delayedCheck0 = true; end setTimeout(function() local delayedCheck1 = false; local tempDeviceState1, deviceLastModification1 = fibaro:get(200, "value"); if (( tonumber(fibaro:getValue(200, "armed")) ~= 0 ) and (os.time() - deviceLastModification1) >= 10) then delayedCheck1 = true; end local startSource = fibaro:getSourceTrigger(); if ( ( delayedCheck0 == true and delayedCheck1 == true ) or startSource["type"] == "other" ) then fibaro:call(49, "turnOn"); fibaro:call(104, "turnOn"); fibaro:startScene(12); fibaro:call(203, "sendDefinedPushNotification", "4"); fibaro:call(207, "sendDefinedPushNotification", "4"); setTimeout(function() fibaro:call(49, "turnOff"); fibaro:call(104, "turnOff"); end, 900000) end end, 10000) end end So here I am, with the big question to you out there: is there anyone who has this working and what code do you have?
  6. Hi All! Is there a way to automatic create labels in VD with LUA? I want to add, or delete labels in VD depending on results of my code. For example if i have a VD displaying humidity sensor values and i add a new sensor the code should add a new label to display its value. Any ideas? Thanks in advance.
  7. Hi I have this function function getHueLight(id) local hueIP = 'xxx.xxx.xxx.xxx' local huePort = '80' local hueKey = '--------------------------------' local requestUrl = "http://"..hueIP..":"..huePort.."/api/"..hueKey.."/lights/"..id; local httpClient = net.HTTPClient(); httpClient:request(requestUrl, { options = { headers={}, method='GET' }, success = function (response) fibaro: debug (response. data) end, error = function (err) fibaro: debug ("Error:" .. err) end }); end and i want to assign output of this to variable i've tried somthing like this local var = getHueLight(id) but it's get nil value
  8. Hi, I have a LUA programming question - for making a scene that helps HC2 heat panel control my AC via ZXT-120. My end-goal (for now) is to set the Fan speed and AC mode (heat/cool/off) by the logic in the following table (explanation below) Explanation for table: Setpoint is retrieved from Heat Panel. The deviation from setpoint is calculated from a global temp-variable subtracting setpoint to get the deviation. Based on that daviation AND the outside temperature, the AC will be set do fan speed and mode. I realize that the amount of if statements would be too big for me to handle, so someone suggested to use "switch-case" (which i am not familiar with but is sort of understood). The below example was provided for me: The problem is i still can't translate this to anything sensible in LUA. Can anyone please help me?
  9. Below is a simple LUA script to turn off most lights at night. The script (my first LUA attempt) works, but raises some basic questions: I would have liked to find the length of the array Lights_exBedrooms using the LUA function n=table.getn(ArrayName). I could not make it work. Is this function not implemented in HC2 LUA? General LUA documentation allows the construction for i,v in ipairs(ArrayName) do .. to cycle through an entire array. This does not seem to be implemented in HC2 LUA either? The script runs without delay, including the do loop turning off all lights in the list. Line 18, however, turning device 251 back on at 20 %, is delayed by about 5 seconds. Why? The idea is to define the device list as a global variable to be used in other scenes. Will adding Lights_exBedrooms{} below line 5 "%% globals" achieve that? More generally: How can something inserted between comment brackets --[[ and --]] in the header be significant to the LUA interpreter? -- "Good night" script - turns off most lights --[[ %% properties %% events %% globals --]] -- set toilet light to low before turning off (night light position, if manually switched on during night) fibaro:call(267,'setValue','20') -- Define vector of all non-bedroom light devices Lights_exBedrooms={306,304,311,305,291,286,271,366,276, 261,267,251,246,373,404,338,328,333} -- Turn off all lights except bedrooms n=18 for i=1,n do fibaro:call(Lights_exBedrooms,'turnOff') end -- Special cases fibaro:call(251,'setValue', '20') -- Hallway at 20%
  10. Is it possible the read out the set of favorite colors for RGBW modules in LUA? How? I want to cycle the favorite colors in a scene. Thanks for hints.
  11. Has anyone found a simple solution to play internet radio stations from like Tunein? if so can you share your VD. thanks
  12. Dear forum readers. I have a virtual device where I wanted to read the XML values from. i know that it is not possible to use external libs to read the XML. the device wich I wanted to control has a status page which in XML format is. I wanted that my virtual device can read the location ID and from each location id the Preset and the name and at last the type of "room" I use Lua for the virtual device. hope that someone can help me out with this This XML file does not appear to have any style information associated with it. The document tree is shown below. <locations> <location id="eec0c0b41b4c43119d33e2bdafe1fc08"> <name>Woonkamer</name> <description/> <type>livingroom</type> <created_date>2019-01-30T17:06:14.387+01:00</created_date> <modified_date>2019-02-13T14:12:37.667+01:00</modified_date> <deleted_date/> <preset>away</preset> <clients/> <appliances> <appliance id="0ae80e58c6354c0ab69dc9f512f73bd0"/> <appliance id="b9cd5290b2c840d6a2cb1e7629987020"/> </appliances> <logs> <point_log id="9b603d2e231e466b83aad0bbe1e3df87"> <updated_date>2019-02-13T14:12:12.637+01:00</updated_date> <type>thermostat</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T13:28:58.345+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:12.637+01:00" end_date="2019-02-13T14:12:12.637+01:00"> <measurement log_date="2019-02-13T14:12:12.637+01:00">15.00</measurement> </period> </point_log> <point_log id="b42775ccb8a34300b89e2783a12d377c"> <updated_date>2019-02-13T14:12:37.627+01:00</updated_date> <type>temperature</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T15:32:18.644+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:37.627+01:00" end_date="2019-02-13T14:12:37.627+01:00"> <measurement log_date="2019-02-13T14:12:37.627+01:00">27.60</measurement> </period> </point_log> </logs> <actuator_functionalities> <thermostat_functionality id="a214798f9ce448b3975d52f0e5b39ed3"> <updated_date>2019-02-13T14:12:12.638+01:00</updated_date> <type>thermostat</type> <setpoint>15</setpoint> <lower_bound>0</lower_bound> <upper_bound>99.99</upper_bound> <resolution>0.01</resolution> <regulations> <open_therm_regulation id="c843041e028c40c7972a37186db7d292"/> </regulations> </thermostat_functionality> </actuator_functionalities> </location> <location id="c2763300e52545c4b702214d842397cd"> <name>Home</name> <description/> <type>building</type> <created_date>2019-01-30T16:31:22.406+01:00</created_date> <modified_date>2019-02-13T14:00:34.694+01:00</modified_date> <deleted_date/> <preset>home</preset> <clients/> <appliances/> <logs> <point_log id="4cdaf2b988d449adb9bcbde2173fabac"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>outdoor_temperature</type> <unit>C</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">6.31</measurement> </period> <thermo_meter id="2874c255abe74e119ce7ae18f28f1620"/> </point_log> <point_log id="6ff4a2747be5466999362dde2ab4de6c"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>wind_vector</type> <unit>m_s</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">(5.10,220.00)</measurement> </period> <wind_vector id="e3b37ca9d9bc4a9c8aa792996c9631f7"/> </point_log> <point_log id="9fedd3ce56544d9cb3ba8741d586195b"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>solar_irradiance</type> <unit>W_m2</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">267.19</measurement> </period> <irradiance_meter id="9f2e62dac6274336abbee38c3f30ae55"/> </point_log> <point_log id="a2b370beeb0340dea1bb4dd76ef4fc69"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>humidity</type> <unit>RH</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">75.00</measurement> </period> <hygro_meter id="7f96900dfb2e47309660a1614e7acc2d"/> </point_log> </logs> <actuator_functionalities/> </location> <location id="9cc6fd06c60c4199b1bd9e97267ee274"> <name>kelder</name> <description/> <type>cellar</type> <created_date>2019-01-31T08:59:18.287+01:00</created_date> <modified_date>2019-02-13T14:12:18.391+01:00</modified_date> <deleted_date/> <preset>away</preset> <clients/> <appliances> <appliance id="6b7d7b6082a54ad7914fac36d268ffd7"/> <appliance id="cee97024adb94776ba6aecddb6ea62d7"/> </appliances> <logs> <point_log id="5b479e2315b84ea3a1b36b9afed23eeb"> <updated_date>2019-02-13T14:12:18.375+01:00</updated_date> <type>temperature</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T15:32:38.107+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:18.375+01:00" end_date="2019-02-13T14:12:18.375+01:00"> <measurement log_date="2019-02-13T14:12:18.375+01:00">24.00</measurement> </period> </point_log> <point_log id="e7787444f4ef461d856a23aa405f3aab"> <updated_date>2019-02-13T14:12:12.765+01:00</updated_date> <type>thermostat</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T14:45:00.766+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:12.765+01:00" end_date="2019-02-13T14:12:12.765+01:00"> <measurement log_date="2019-02-13T14:12:12.765+01:00">15.00</measurement> </period> </point_log> </logs> <actuator_functionalities> <thermostat_functionality id="9c1f952c1cdc470bb72716858b004bf5"> <updated_date>2019-02-13T14:12:12.766+01:00</updated_date> <type>thermostat</type> <setpoint>15</setpoint> <lower_bound>0</lower_bound> <upper_bound>99.99</upper_bound> <resolution>0.01</resolution> <regulations> <open_therm_regulation id="c843041e028c40c7972a37186db7d292"/> </regulations> </thermostat_functionality> </actuator_functionalities> </location> </locations>
  13. Version 1.1.0

    79 downloads

    Hello Everyone, I 've tried Konnected alarm panel in parallel with my old alarm system, and it is working great. (Konnected) My task that was assigned to myself was to integrate Konnected directly to my HC2. So with a little LUA magic we have ready the Konnected Virtual Device for HC2. You can find the Virtual Device Repository here. Enjoy!
  14. I bought a mermaid Devolo (Zipato). I get the LEDs on, but it does not sound. According to the manual there are 7 sounds and for this use this: The device supports using SWITCH_MULTILEVEL SET to play the sound The sound ID is defined as follows: 1 or 255: Emergency sound. 2: Fire alert. 3: Ambulance sound. 4: Police car sound. 5: Door chime. 6 ~ 99: Beep Beep. 0: means stop the sound. But I do not know how to activate it. Then he has some COMMAND_CLASS ....... I do not know how I can configure them with lua. Let's see if someone can help me. Thank you. ph-pse02-Zipato-Siren-User-Manual-v1-2.pdf
  15. Dear readers, I am looking for an option to make an integration for the products from plugwise. their products are programmed with Lua so I think it is an easy job. but i can't find any documentation about how to make an integration so that the fibaro HC2 can work with their devices. products links : www.plugwise.com
  16. Witam, Od wczoraj zmagam się z problemami z HC2. Sceny nie uruchamiają się automatycznie. Miałem wcześniej dużo działących już scen i dopisałem wczoraj nową i przestało działać. Robiłem kilka restartów i nic. Nie widziałem, żeby firmware się aktualizował. Obecna wersja to 4.530. Jeśli odpalę sceny ręcznie to zadziałają, więc kod jest poprawny. Jakieś pomysły?
  17. This is my first topic in a series of post I'm going to write about the advanced LUA scenes I wrote for my home automation project. My goal is not flipping a light scene with a phone but for 90% autonome home automation. Besides posting LUA code I give you more insight why I came to this routine. It may help you with designing your own automation routines. Disclaimer: I am not a professional programmer and I post the scenes as is. I have no time to make the LUA scenes generic like other great members do on this forum. I just post my LUA code to share knowlegde and inspire you to create awesome things! Advanced home wake-up routine with Philips Hue and HC2 Applies to: Fibaro Home Center 2 and Philips HUE bridge. GOALS Use my Philips Hue led strips as a wake-up light. Use 1 app to schedule the whole home wake-up routine. Start the morning routine when walking downstairs (check motion). Turn on the lights only when it’s dark (read lux). In our bedroom we integrated a Philips Hue lightstrip in the ceiling and use this with the Philips Hue app as a wake-up light. It beautifully fakes a sunrise in our whole room. As we use the Hue app to set our wake-up alarm I use this app to trigger the Home Center to run a wake-up routine for the rest of the house. TL;DR Set recurring wake-up schedule in the Philips Hue app. Home Center LUA scene 1 reads schedules at 04:00 with the keyword Wake in it. If schedule is set for today and motion is detected at the hallway after the scheduled time (scene 2), run wake-up routine. HOW I IMPLEMENTED IT IN WORDS Reading Hue schedules from the bridge cannot be done with the Fibaro Hue plug-in. Therefore I wrote a LUA scene to read the Hue schedules from the Hue bridge and run the wake-up routine at the schedules wake-up time. I achieved this with 2 LUA scenes: Scene 1 runs every minute and polls the Hue bridge schedules at 04:00. If a wake-up is scheduled for today write the wake-up times to a global variable. Every minute it checks if there is a wake-up planned by reading the same global variable and if so it sets the WakeUpReady global variable to 1. Scene 2 runs when motion detected by a Fibaro Motion Sensor. If it detects motion it checks if the global variable WakeUpReady is set to 1 and runs the wake-up routine. SCENE 1 EXPLAINED You can download the full LUA scenes at the bottom of this post. I only describe snippets of my code to make you understand what it does and show the challenges I ran into. TAG YOUR HUE SCHEDULE WITH A WAKE-UP STRING IN IT! To know which schedules are used for wake-up I set all those schedules with the Wake keyword in it. Like Wake-up weekday’s and Wake-up weekends. In the LUA scene I find these schedules with the code: if name:find('Wake') and status == 'enabled' then ... end RECURRING DAY’S ARE SAVED AS A BITMASK IN THE HUE BRIDGE The Hue API states: The Hue bridge saves the recurring day’s as a bitmask. You have to convert this bitmask to weekday’s. So you can check if the alarm is set for today. The first step is to convert decimal to a binary. I did this with the folowing LUA function: function bin(dec) local result = "" repeat local divres = dec / 2 local int, frac = math.modf(divres) dec = int result = math.ceil(frac) .. result until dec == 0 local StrNumber StrNumber = string.format(result, "s") local nbZero nbZero = 8 - string.len(StrNumber) local Sresult Sresult = string.rep("0", nbZero)..StrNumber return Sresult end Then I have a binary representation of the scheduled weekday’s. For example: mo tu we th fr sa su 1 1 1 1 0 1 0 You see the alarm is set for monday, tuesday, wednesday, thursday and saturday. With this I can determine if the alarm is set for today: if name:find('Wake') and status == 'enabled' then local huedays, huetime = string.match(timepattern, 'W(.*)/T(.*)') -- Hue starts at monday, LUA starts at sunday, so I have to fix this. local dayofweek = os.date("*t").wday-1 if dayofweek == 0 then dayofweek = 7 end local scheduleddays = bin(huedays) -- dayofweek+1 because a week is 7 days and binary is 8 digits, so -- a have a pre 0 local waketoday = string.sub(scheduleddays, dayofweek+1, dayofweek+1) if waketoday == '1' then wakeUpAlarms = wakeUpAlarms .. huetime:sub(1, -4) .. '|' end ... end WRITE WAKE-UP TIME TO GLOBAL VARIABLE If there is an alarm schedule for today write it to a global variable for later use: if wakeUpAlarms ~= '' then fibaro:setGlobal("WakeUpTime", wakeUpAlarms:sub(1, -2)) -- remove last | else -- If no schedules are set, write disabled to the global variable. fibaro:setGlobal("WakeUpTime", "disabled") end SET WAKEUPREADY GLOBAL VARIABLE FOR MOTION SENSOR LUA SCENE The LUA scene runs every minute using the code: setTimeout(tempFunc, 60*1000) At 04:00 it checks the schedules in the Hue bridge, but every minute it checks the WakeUpTime global variable to set the wakeupReady global variable to 1. This variable triggers the second LUA scene used by the motion sensor. local wakeupTime = fibaro:getGlobal("WakeUpTime") if wakeupTime ~= "disabled" then local waketimes = {} for match in (wakeupTime..'|'):gmatch("(.-)"..'|') do table.insert(waketimes, match); end for k, v in pairs(waketimes) do if os.date("%H:%M") == v then fibaro:setGlobal("WakeUpReady", 1) fibaro:debug("It's wake-up time! Set motion detector ready!") end end end SCENE 2 EXPLAINED (MOTION SENSOR PART) With scene 1 I created a global variable setting to determine if the wake-up routine must run. Now I create a second scene to act if there is motion in our hallway. CHECK FOR MOTION AND IF ALARM IS NOT ARMED First I want to check if there is motion and if the alarm is not armed with the line: if tonumber(fibaro:getValue(158, "value")) > 0 and tonumber(fibaro:getValue(158, "armed")) == 0 then ... RUN WAKE-UP ROUTINE ONLY IF IT’S DARK OUTSIDE The Philips Hue wake-up schedule runs always because our bedroom had curtains and the room is always dark. Downstairs I only want to run the wake-up routine when it’s dark outside. The wakeupReady global variable check’s if the routine needs to run when there is motion (set with scene 1). The line below gets the current lux reading from the Fibaro motion sensor: fibaro:getValue(160, "value") If the illuminance is below 20 I want to turn on my lights. if wakeupReady == "1" then fibaro:setGlobal("WakeUpReady", 0) -- Disable trigger for current wake-up time. -- check lux local currentLux = tonumber(fibaro:getValue(160, "value")) -- id 160 is sensors light device. -- If it's dark then start wake-up routine if currentLux < 20 then fibaro:debug("Illuminance measuring " .. currentLux .. " lx, starting wake-up routine.") fibaro:call(44, "setValue", "8") -- Spots keuken (8%) fibaro:call(29, "setValue", "5") -- Tafel eethoek (5%) fibaro:call(106 , "turnOn") -- Bolles (aan) fibaro:call(118 , "turnOn") -- Spot voordeur (aan) fibaro:call(156, "sendPush", "Started wake-up routine. Debug: " .. currentLux .. " lx") else fibaro:debug("Illuminance measuring " .. currentLux .. " lx, do nothing.") end ... DOWNLOAD MY SCENES COMPLETE LUA CODE You can download the full LUA scene code from GitHub: Scene 1: Wakeup.lua Scene 2: MotionRoutine1.lua You have to change the device id’s from my motion sensors in this scene to your own id’s! And don't forget to set the scenes to run automatic in the Fibaro Home Center 2
  18. I am looking to create a simple Lua scene that looks to see if the door is locked then do "something". everything I enter to look for the door status it is not working. Someone please tell me what I am doing wrong. 92 = my door lock --[[ %% properties %% events %% globals --]] local User = "User_Present"; if tonumber(fibaro:getValue(92, "secured")) == 0 then fibaro:setGlobal(User,"0") fibaro:debug("Door locked"); end
  19. amatt

    Restart Plug

    I am looking to have the wall plug restart (turn off then back on after 30 seconds) at an exact time (midnight). i have tried coding this in Lua but i am having no success on getting it to turn off and on at midnight can some help me?
  20. Hi All, Is it possible to change the colours of the LUA IDE in the Scenes dialogue? The dark background and dark text colours make it difficult to use.. All help greatly appreciated!
  21. I want to subtract "tid_entre" from "tid" and check if it is longer than "entre". fibaro:setGlobal("Tid_entre", (os.date("%Y-%m-%d %H:%M:%S",fibaro:getValue(37, "lastBreached")))) local entre = "00:00:30" --hh:mm:ss local tid_entre = fibaro:getGlobal("Tid_entre") local tid = os.date("%Y-%m-%d %H:%M:%S") [DEBUG] 16:06:52: Variabelen entre = 00:00:30, VariableType = string [DEBUG] 16:06:52: Variabelen Tid_entre = 2018-10-17 14:00:44, VariableType = string [DEBUG] 16:06:52: Variabelen tid = 2018-10-17 16:06:52, VariableType = string Is it possible to do this without using epoc numbers for time?
  22. Hello, Am a learner and currently practicing lua coding, i would like to know how to identify errors before i use the codes on HC2 . Am not really sure what am doing. Am worried i may Crush the system. For instance, can't identify the problem... (i was trying to tell the TVwallplug to detect if the TV is Off then Turn it On, and if TV is On then Turn it Off) i want to use it when running scenes. The TV has 1 Button for On/Off Hop to get help from here. Thank you
  23. I like to initialize an empty table (like HomeTable) from a scene if it is not exist. I tried the simple following lua code but it fails. -- Check if variable exist if (fibaro:getGlobal(DDDTable) == nil) then fibaro:debug("Creating Variable Table "..varName) jsonDDD = { settings = { version='0.1' }, } jDDDTable = json.encode(jsonDDD) fibaro:setGlobal("DDDTable", jDDDTable) -- store table in global else fibaro:debug('Existing Variable') end It sounds crazy but I stuck on this point for 2 days...and my Bosch/Siemens Home-Connect project (I will share it with you guys) is on halt due to this **small** detail. Any help is more than welcome! P.S. @10der I know that you help people (high appreciate, thank you) like me on first steps... what a fool....! here is the code: api.post("/globalVariables", { name="testTable", value="Table", -- optional }) -- Modify existing variable to "predefined" style api.put("/globalVariables/testTable", { name="testTable", value="Table", -- optional isEnum=true, enumValues= { "Table", } }) here is the source: Another question is howto check if a variable is a table or something gone wrong during writing (human interaction).
  24. Hi all, I have an issue trying to make and HTTPS POST request from my LUA scnene in Fibaro HC. I am getting "short read" error with the URL "https://api2.magicair.tion.ru/idsrv/oauth2/token" This is my scene: ============================================= --[[ %% properties %% events %% globals --]] local authData = "username=XXX&password=YYY" function doTest() print('Test!') local requestUrl = "https://api2.magicair.tion.ru/idsrv/oauth2/token" local httpClient = net.HTTPClient() httpClient:request(requestUrl, { options = { method = "POST", headers = { ["Content-Type"] = "application/x-www-form-urlencoded", ["Content-Length"] = tostring(authData:len()) }, data = authData, timeout = 5000 }, success = function (response) fibaro:debug (response.data) end, error = function (err) fibaro:debug ("Error: " .. err) end }) setTimeout(doTest, 5*1000) end print('Script start...') doTest() ============================================= I am getting the following in my log: [DEBUG] 15:16:52: Script start... [DEBUG] 15:16:52: Test! [DEBUG] 15:16:52: Error: short read I have been trying to play with headers, data format, timeouts and all parameters I could find, however I always get the same error with the provided URL. Other HTTPS URLS I tried with GET method works just fine. Also I have been trying to do the same with cURL and it works fine with the exact same set of headers and payload (with full credentials string, of course). So the issue is somehow connected with this specific URL: "https://api2.magicair.tion.ru/idsrv/oauth2/token" The Internet is saying that short read problem in HTTPClient request might be related to ciphering protocols mismatch between the client and server. So there could be some parameter regulating this? 2 main versions, which I see: 1. Some tricky param is required to form the correct HTTPS request. 2. Some bug / missing feature in HTTPClient implementation in HC2. Anyway I am stuck and need the help from the community and HC developers. Has anyone seen something similar? Any clues? Please help! Many thanks in advance. PS Using the latest FW 4.51 of Fibaro Come Center 2
  25. Hi all, I'm new to HC2 having migrated from Domoticz. I've a limited knowledge of LUA and so rely heavily on copy and paste I am trying to create a scene whereby if any of my heat controllers are calling for heat a fibaro relay will switch on my boiler... and if all off... turn it off again i.e. " if A or B or C = On then set H = On elsif A and B and C = Off then set H = Off" My attempt at code is as follows --[[ %% properties 52 operatingMode 62 operatingMode 43 operatingMode 67 operatingMode 7 operatingMode 26 operatingMode %% weather %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if ( ( tostring(fibaro:getValue(52, "operatingMode")) == "1" ) or ( tostring(fibaro:getValue(62, "operatingMode")) == "1" ) or ( tostring(fibaro:getValue(43, "operatingMode")) == "1" ) or ( tostring(fibaro:getValue(67, "operatingMode")) == "1" ) or ( tostring(fibaro:getValue(7, "operatingMode")) == "1" ) or ( tostring(fibaro:getValue(26, "operatingMode")) == "1" ) or startSource["type"] == "other" ) then fibaro:call(48, "turnOn"); elseif ( ( tostring(fibaro:getValue(52, "operatingMode")) == "0" ) and ( tostring(fibaro:getValue(62, "operatingMode")) == "0" ) and ( tostring(fibaro:getValue(43, "operatingMode")) == "0" ) and ( tostring(fibaro:getValue(67, "operatingMode")) == "0" ) and ( tostring(fibaro:getValue(7, "operatingMode")) == "0" ) and ( tostring(fibaro:getValue(26, "operatingMode")) == "0" ) and startSource["type"] == "other" ) then fibaro:call(48, "turnOff"); end This appears to run without bugs but just turns the boiler (device 48) on and stays on. Does anyone have any idea where I am going wrong? Any help/tips would be greatly appreciated. Many thanks Sean
×
×
  • Create New...