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. Dear All, I want to get into learning LUA. It seems that this is the right way to move forward if anyone is to use the HC2 seriously. However, as a newbie (relatively) to programming, I want to first understand if I need to learn other languages besides LUA in order to get the most out of the HC2. Any advice on where I should start this adventure?
  2. Hi there, I'm a developer but I'm fairly a newbie with LUA language and I'm having some problems undestanding the scope of the variables/functions, or maybe I'm just writing some garbage code... I need your help I want to use the native LUA function "load()" to evaluate a string and let it parse it as LUA code. I'm following LUA 5.2 documentation ( http://www.lua.org/manual/5.2/manual.html#pdf-load ) to use function, but I keep getting this error "attempt to call global "load" (a nil value) and I can't solve it. Here's my chunk of code: And here's the error Btw I'm using load() to make sure mainloop code is called right after button press, and not after 2/3 secs. Hope someone can help me out =) Thank you!
  3. Hi, I have implemented @cag014 HomeTable to track the device ID's of my HC2 the table structure is like this office = { Light=33,Temp=1186,Motion=1251,Lamp=720,rcSonos=1 }, Landing_Stairs = { stairsLight=92,landingLight=168,rcSonos=1 }, scene = { MainScene=614,AlarmControl=598,rebootHC2=593,goodMorning=463,goodNight=331,LeavingHome=483,welcomeHome=488,quietMorning=499,kidsToBed=490,plaroomTvOn=580,firstFloorMusicOn=579,firstFloorAllOff=578, hallSceneControl=519,StairsLight30=556,GateOpen5=526,GateOpenHold=361,GateOpenClose=425,DumpEventLog=565,PlayroomOff=617 }, vd = { AlarmManagement=881,TVPresets=1545,SonosTTS=1452,LightPresets=1534,HouseModeExt=1538,SonosPresets=1536,RackTempMngt=1453,MediaSourcePresets=1567,JhomeTable=1566,GateControl=1537,GarageControl=1559 }, I can update the whole table but was wondering if it was possible to update a specific vale such as "scene.AlarmControl" in the example I posted above. Any helpful code snippets gratefully accepted thanks -f
  4. HI, Is it possible to create a variable (specifically a predefined variable) As part of creating a VD I want to create the variable on the fly I looked at the developer documentation but couldn't find anything Is this possible ? Thanks -f
  5. Hi, I am converting and combining some of my scenes into Virtual devices I noticed that the main loop code seems to 'loop' every 3 seconds. I thought it was every one second here is the code and the debug screen function UpdateEventLog(eventStr) local currDate = (os.date("%b %d - %H:%M")) local updStr = (fibaro:getGlobal("Log_Event") .."".. currDate .." ".. eventStr .." \n") fibaro:setGlobal("Log_Event", updStr) end -- Auto lights Hotpress local HotPressLightID = 143 local HotPressDoorSensorID = 888 if (tonumber(fibaro:getValue(HotPressDoorSensorID, "value"))) == 1 then fibaro:call(HotPressLightID, "turnOn") UpdateEventLog("Hotpress auto-light activated") else fibaro:call(HotPressLightID, "turnOff") end -- Auto lights Dining Room local DiningCenterLightID = 25 fibaro:debug(tonumber(fibaro:getValue(DiningCenterLightID, "value"))) if ((fibaro:getGlobalValue("G_SPC_ZONE_INPUT_19") == "OPEN") and (fibaro:getGlobalValue("TODModeInside") == "night") and (tonumber(fibaro:getValue(DiningCenterLightID, "value"))) == 0) then fibaro:call(DiningCenterLightID, "setValue", "30") UpdateEventLog("Dining Room auto-lights activated") end Thanks Frank
  6. Multiroom Heating Controller My project was to write a multiroom heating controller to give indipendant control over each room using as much as the built in functionality of Home Center 2 as possible. Starting point: Create multiple rooms in the heating panel in accordance with the Advanced User Guide section 5.9.3 I did have some code to enumerate from these panels and get the following from the JSON files http://yourHC2IPAddress/api/panels/heating & http://yourHC2IPAddress/api/rooms Room Name, Room "Default Thermostat" & Default Temperature Sensor As I failed to add them to my array roomsArray I abandoned this for the time being. (Any developers want to help here??? You add your rooms to the roomsArray, set the HeatON and HeatOff as you need them these will stop overshoot of Temperature. - Any developers want to turn this in to a heating PID? I have been running this now for a couple of months without problem, and even moved it to other HC2 controllers. Make a LUA Scene, drope the code in, change the Variables and away you go. My setup and all I have tested with: HC2 v 4.1x Danfoss LC-13 TRVs these control the radiators and also act as a Thermostat for any room that does not have a external Thermostat Fibaro or AEON Multisensor for Temperature Sensor Secure SRT321 Wall thermostat & Secure HRT boiler Receiver - This was so i could put in manual mode if anything went wrong Happy to have suggeestions and additions! Enjoy! Brent --[[ %% autostart %% properties %% globals --]] -- REFERENCE -- forum.fibaro.com, lua.org, domotique-fibaro.fr, www.zwaveforum.net -- 0.0.1 2/11/16 iniital version -- 0.0.2 3/11/16 added get setpoint fucntion -- 0.0.3 4/11/16 Get Setpoints from Heating Panel -- Scrapped for -- 0.0. 11/11/16 Get default sensors from roms panel version = '1.0.0' -- 13/11/16 Stable version -- local arrays local roomsArray={} local heatOn = 0.7 -- temp has to drop this value below setpoint before boiler is on again -- adjust these two levels to reduce the sawtooth effect. local heatOff = 0.5 local smoothFactor = 3 local boilerControllerID=97 local programStart = os.time() local boilerOnTime = 0 local boilerOffTime = 0 local boilerOnTotal = 0 -- roomsArray[Room Name]={SetPointID, ThermostatID} -- These are temporary until Panels and Rooms Functions return Arrays roomsArray[1]={'Lounge',99,12} roomsArray[2]={'Master Bedroom',100,13} roomsArray[3]={'Kitchen',101,14} roomsArray[4]={'Bathroom',102,15} -------------------- USER SETTINGS ----------------------- --This will be redundant with version 0.0.4 debug = true -- set debug to true or false enumerateRooms = true -- Set this to true and within the debug window on the scene advance tab you will see room names and IDs enumerateSensors = true -- Set this to true to see within the Debug Window on the scene advance tab you will see Sensors for the room names and IDs enumerateErrors = true ----------------------------------------------------------- ------------- DO NOT CHANGE LINES BELOW ------------------- startSource = fibaro:getSourceTrigger(); -- Not using this at this time but will do BJB -- Give debug a fancy color Debug = function ( color, message ) fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); end Debug( "orange", "Read Heating Panel scene - LUA Scripting by Brent Brown 2016" ); Debug( "orange", "Version: "..version); -- Passed RoomID, ThermostatID, TemporatureSensorID -- Returns via adding to roomsArray TermostatSetpoint, currentTemperature, errorTemperature getTempError = function(room, tempID, thermID) local temperatureError = -999 if type(tonumber(fibaro:getValue(thermID, "targetLevel"))) ~= 'number' then if enumerateErrors == true then Debug("Green", "The device Thermostat in room " .. roomsArray[room][1] .. " has a NIL value!") Debug("Green", fibaro:getValue(thermID, "targetLevel")) temperatureError=0 end elseif type(tonumber(fibaro:getValue(tempID, "value"))) ~= 'number' then if enumerateErrors == true then Debug("Red", "The device temperature sensor in room " .. roomsArray[room][1] .. " has a NIL value!") Debug("Red", fibaro:getValue(tempID, "value")) temperatureError=0 end else roomsArray[room][5]=tonumber(fibaro:getValue(tempID, "value")) roomsArray[room][4]=tonumber(fibaro:getValue(thermID, "targetLevel")) roomsArray[room][6]=tonumber(fibaro:getValue(thermID, "targetLevel")) - tonumber(fibaro:getValue(tempID, "value")) end return temperatureError end meanTempFunc = function() local averageTempError, count = 0, 0 for k,v in pairs(roomsArray) do if debug == ture then Debug("White",roomsArray[k][6]) end if type(roomsArray[k][6]) ~= 'number' then if debug == ture then Debug("Red",roomsArray[k][1]..", TempError is not a number [Nil]") end elseif roomsArray[k][6] <= 0 then if debug == true then Debug("Red", roomsArray[k][1]..", is "..roomsArray[k][6]*-1 .."° above SetPoint") end else if debug == true then Debug("Blue", roomsArray[k][1]..", is: "..roomsArray[k][6]*-1 .."° below SetPoint") end averageTempError = averageTempError + roomsArray[k][6] count = count + 1 end end if count == 0 then averageTempError = 0 Debug("Blue","Average temperature across "..count.." room(s), is:"..averageTempError.."°") else averageTempError=averageTempError/count Debug("White","Average temperature across "..count.." room(s), is:"..averageTempError.."°") end return averageTempError end debugRoomFunc = function(room) if type(roomsArray[room][4]) == 'number' then Debug("White", roomsArray[room][1].." SetPoint Temperature is: "..roomsArray[room][4]) end if type(roomsArray[room][5]) == 'number' then Debug("White", roomsArray[room][1].." Sensor is showing the Temperature is: "..roomsArray[room][5]) end if type(roomsArray[room][6]) == 'number' then Debug("White", roomsArray[room][1].." Error Temperature is: "..roomsArray[room][6]) end end -- Main Process while true do local boilerOnTime for k, v in pairs(roomsArray) do --Debug("White", k..'.'..roomsArray[k][2]..'.'..roomsArray[k][3]) -- From each room get the Setpoint - Temperature to give ErrorTemperature getTempError(k,roomsArray[k][2],roomsArray[k][3]) end -- Get Each positive error temperature from roomArray[roomID][6] == ErrorTemp local meanTempError=meanTempFunc() Debug("Yellow",meanTempError) if meanTempError > 0 and meanTempError > heatOn then if tonumber(fibaro:getValue(boilerControllerID,"mode"))~=1 then fibaro:call(boilerControllerID, "setMode",1) boilerOnTime=os.time() Debug("Yellow", "Boiler on at = "..os.date("%X")) end end if meanTempError < heatOff then if tonumber(fibaro:getValue(boilerControllerID,"mode"))~=0 then fibaro:call(boilerControllerID,"setMode",0) boilerOnTotal=os.difftime(os.time(), boilerOnTime) Debug("White", "The boiler has been on for ".. boilerOnTotal.. " Seconds") fibaro:sleep(120000) -- Wait 2 mins whilst the latent heat tin the system keeps warming the room Debug("Yellow", "Boiler off at = "..os.date("%X")) end end --[[local whichRooms = "All" -- Options all or room 1,2,3,4,5, etc if whichRooms == "All" then for k, v in pairs(roomsArray) do debugRoomFunc(k) end -- Remove the comment "--" to show each of the room settings else debugRoomFunc(whichRooms) end --]] fibaro:sleep(30000) end Brent
  7. Hello Everyone, Today I was notified that LightwaveRF has publicly released a new API document. Hopefully, this will spawn a new raft of Virtual Devices that control LightwaveRF products as, if you live in the UK, you find this platform just works without major headaches and beta upgrades. The link is below: https://api.lightwaverf.com/introduction_basic_comms.html
  8. I am trying to create a day/night setup via lua. Where at 8 am-10pm the variable is set to day and at 10pm-8am the variable is set to night. I cannot successfully do this via a block scene so i have used LUA to do this. Could someone help me look over my code to see if this is correct as i am fairly new in LUA. Thanks! --[[ %% autostart %% properties %% globals --]] -- Only need to call getSourceTrigger once -- For better debugging, I moved it to the top, -- before countScenes local sourceTrigger = fibaro:getSourceTrigger() fibaro:debug("Script started because of: " .. sourceTrigger["type"]) if fibaro:countScenes()>1 then fibaro:debug("Scene already running, aborting this one") fibaro:abort() end if (sourceTrigger["type"] == "autostart") then while true do local currentDate = os.date("*t") -- Do the time-string manipulation thingy here, instead of in -- each and every if-then statement -- %02u means unsigned int, 2 wide, leading zero TimeAsString = string.format("%02u",currentDate.hour).. ":" .. string.format("%02u", currentDate.min) fibaro:debug("TimeAsString: ".. TimeAsString) Day_night = fibaro:getGlobalValue("Day_night") fibaro:debug("Day_night: " .. Day_night) 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 TimeAsString == "8:00" then fibaro:debug("Setting scenario number 1") fibaro:setGlobal("Day_night", "Day") elseif ( 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 TimeAsString == "22:00" then fibaro:debug("Setting scenario number 2") fibaro:setGlobal("Day_night", "Night") else fibaro:debug("Current time doesn't match any scenario") end end fibaro:debug("Scene not started, this is autostart-only!") end -- end of sourceTrigger["type"] == "autostart"
  9. HI, Looking for some advice here I have a simple scenario. Enter room, sensor picks up the movement, lamp turns on. I can implement this as a scene (clode below) but I seem to get a lot of "too many instances", presumable because the sensor gets triggered when we are in the room I could also implement this as a VD in the main loop (code below) In terms of best practice or least load on the HC2 or what do our guru's generally do ? Thanks Frank VD Lua -- Configuration Device ID's local LivingRoomLamp = 1423 local LivingRoomLight = 231 if (fibaro:getGlobalValue("G_SPC_ZONE_INPUT_18") == "OPEN") and (fibaro:getGlobalValue("TODModeInside") == "night") and (fibaro:getValue(LivingRoomLight, "value") == "0") then fibaro:debug("turning on living room lamp") fibaro:call(LivingRoomLamp, "turnOn") end fibaro:sleep(3000) Scene Lua --[[ %% properties %% events %% globals G_SPC_ZONE_INPUT_18 --]] -- Configuration - Scene Info sceneName = "Autolights On for living room" sceneVersion = "1.0.1" -- Configuration Device ID's local LivingRoomLamp = 1423 local LivingRoomLight = 231 -- Validate Number of Scene Instance if (fibaro:countScenes()>1) then fibaro:debug("stop scene, to many instances") fibaro:abort() end function UpdateEventLog(eventStr) local currDate = (os.date("%b %d - %H:%M")) local updStr = (fibaro:getGlobal("Log_Event") .."".. currDate .." ".. eventStr .." \n") fibaro:setGlobal("Log_Event", updStr) end -- Main Scene Execution Code function tempFuncLiving() if (fibaro:getGlobalValue("G_SPC_ZONE_INPUT_18") == "OPEN") and (fibaro:getGlobalValue("TODModeInside") == "night") and (fibaro:getValue(LivingRoomLight, "value") == "0") then fibaro:debug("turning on living room lamp") fibaro:call(LivingRoomLamp, "turnOn") UpdateEventLog("living room auto lamp on") end fibaro:sleep(3000) end tempFuncLiving()
  10. Hi, I tried to get messages from my alarm system Honeywell Vista 10. To connect to the alarm system I use AD2Pi installed on Raspberry Pi. On Raspberry Pi started ser2sock program that redirect messages from serial to tcp. On HC2 I created VD, in which I can arm/disarm alarm system. I just sent the code for disarming I created a scene to get messages from alarm system, but always I see error message: [DEBUG] 11:35:40: line 12: attempt to index global 'Net' (a nil value) --[[ %% properties %% events %% globals --]] local ip = "10.0.1.5" local port = 10000 -- Initialising TCP-port if (tcpSocket == nil) then tcpSocket = Net.FTcpSocket(ip, port); tcpSocket:setReadTimeout(2000); end response, errorCode = tcpSocket:read() fibaro:log(tostring(response)); fibaro:debug(tostring(response)); My question: ser2sock sends messages about all alarm system events. How I can read and parsing messages from tcp? I always have to keep an open TCP connection, and when I get a new line, must run the parser. How to do this?
  11. Hi Guys. Im seeking a skilled LUA coder who can do some work for us with integrating a couple of things for HC2. For instance some advanced light control to make everything more automated But also integrating new products that has API into Fibaro.. Send me a message please and we can talk about it Thanks!
  12. 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
  13. 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.
  14. Hello, I'm using a HC2 in my holiday home and would like to read-out some system-information by a API-call (for example /api/devices). The problem is that I can’t “reach” the HC locally by VPN or Port forwarding. Is ‘t possible to create a LUA-scene to ‘catch’ the API-json-output and send it by email and if so, are there any examples of this kind of LUA-scripts? With kind regards, John Claassens
  15. For roller shutters there is a setting "Local protection state": If it is set to "No operation possible" in the web interface, then it is not possible at all to control a device directly via buttons. Same is available to block operation via scenes: By setting "Remote protection state" to "No remote control". The state of this parameter can be read by this command: print (fibaro:getValue(ID, "protectionState")); Now I want to set this protection state via LUA (to protect the blinds from operated at strong winds). The Fibaro support page states a parameter "setProtectionLocalAndRF" can be set via fibaro:call function if used with the callAction API call. Question A: How to call the callAction API via http from within a LUA scene? Will this set the protection state? What are the parameters for setProtectionLocalAndRF? However, when changed in the web interface my roller shutter module does not store that value, but always is set back to "unprotected". Question B: What can be the reason, why my roller shutter module doesn't accept the state "No operation possible"? Thanks for help. ------ FGRM--222 Software Version 25.25 HCL2 Software Version 4.100
  16. Hi folks, I have a bit of a puzzler. I have a scene that sets to global variables based on light level from a sensor (device 217 ) The two options within the code are either 'day' or 'night' but sometimes it gets set to 'normal' Could anybody offer an explanation Scene code below... Thanks Frank --[[ %% autostart %% properties 217 value %% events %% globals --]] -- Configuration - Scene Info sceneName = "GV Time of Day, inside and outside" sceneVersion = "1.0.1" -- Scene Description -- Sets a global variable called TOD_LightMode depending on lux level from an outside sensor -- Configuration - Device IDs local OutsideLuxSensorID = 217 -- Validate Number of Scene Instance if (fibaro:countScenes()>1) then --fibaro:debug("stop scene") fibaro:abort() end function UpdateEventLog(eventStr) local currDate = (os.date("%b %d - %H:%M")) local updStr = (fibaro:getGlobal("Log_Event") .."".. currDate .." ".. eventStr .." \n") fibaro:setGlobal("Log_Event", updStr) end -- Main Code for the Scene function tempFunc() --set reference for outside lights if tonumber(fibaro:getValue(OutsideLuxSensorID, "value")) == 0 then fibaro:setGlobal("TOD_LightMode", "night") fibaro:debug("Outside = 0 - "..fibaro:getGlobal("TOD_LightMode")) UpdateEventLog("Outside mode set - night mode") else fibaro:setGlobal("TOD_LightMode", "day") fibaro:debug("Outside > 0 - "..fibaro:getGlobal("TOD_LightMode")) UpdateEventLog("Outside mode set - day mode") end fibaro:sleep(5000) fibaro:debug(fibaro:getValue(OutsideLuxSensorID, "value")) -- set refernce for inside lights if tonumber(fibaro:getValue(OutsideLuxSensorID, "value")) < 50 then fibaro:setGlobal("TODModeInside", "night") fibaro:debug("Inside <40 - "..fibaro:getGlobal("TODModeInside")) UpdateEventLog("Inside mode set - night") else fibaro:setGlobal("TODModeInside", "day") fibaro:debug("Inside >40 - "..fibaro:getGlobal("TODModeInside")) UpdateEventLog("Inside mode set - day") end fibaro:debug("Inside - "..fibaro:getGlobal("TODModeInside")) fibaro:debug("Outside - "..fibaro:getGlobal("TOD_LightMode")) end -- Trigger Management local currentDate = os.date("*t") local startSource = fibaro:getSourceTrigger() --Start of Scene Execution if (startSource["type"] == 'property') then fibaro:debug("Started through property") tempFunc() -- this is calling the the function if something happens. elseif (startSource["type"] == 'global') then fibaro:debug("Started through variable") tempFunc() -- this is calling the the function if something happens. elseif (startSource["type"] == "autostart") then fibaro:debug("Started through autostart") tempFunc() -- this is calling the the function if something happens. elseif (startSource["type"] == "other") then fibaro:debug("Scene not started, this can only be started through property, global or autostart!"); end -- End of Scene Execution fibaro:debug("Scene, " .. sceneName .. " v" .. sceneVersion .. " completed.")
  17. I've got a HC2, Nest and some Danfoss-valves, eventually I want a Multi-zoned Heating Systems. = Modulating through a Nest = Problem is I live in The Netherlands and out here usually have Modulating Central Heating Systems. So I can't just use The Heating Panel and keep my pipes heated or not according to the outside temperature. With the Modulating system, I need to control my Central Heating through for example a Nest. I am controlling the Nest through an API, with the help of @TW1979 in topic "https://forum.fibaro.com/index.php?/topic/22466-nest-thermostat-v3-fibaro-plugin-not-updating-workaround-found" = LUA = I've read up on the Danfoss-radiator valves. (special thanks to: @tinman@Momos@hTiger1@petergebruers) * They're not that reliable. So before I start with the Multi-zone-LUA, here is my description of the LUA I'm gonna write for the one-room-system. Can someone tell me if this is gonna work? Global Variables: int Target_Temp_room1 Function:SCHEDULE Trigger : Time Action : Changes Target_Temp_room1 Function:EDIT Target_Temp_room1 WHEN THERMOSTAT IS CHANGED MANUALLY Trigger : Physical changes at Thermostat or manual changes in Fibaro GUI. Action : Change the Target_Temp_room1 accordingly Function:TURN ON CENTRAL HEATING (by turning on the Nest) Trigger : Target_Temp_room1 is changed PreExec : Check if I am home (if I'm Away do nothing) Action : check how much the Target_Temp_room1 is away from the FIBMOTION:current_temp_room1 (=Temp_Difference_room1) --> Set API:Nest_target to API:Nest_Current_Temp + Temp_Difference. Set the Thermostat to Target_Temp_room1 if it isn't already. Function:TURN OFF CENTRAL HEATING Trigger : Room Temperature has reached the Target_Temp Action : Set API:Nest_target to API:Nest_Current_Temp * https://forum.fibaro.com/index.php?/topic/22592-danfoss-valves-and-room-sensor-winter-is-upon-us https://forum.fibaro.com/index.php?/topic/21275-danfoss-lc-13-how-does-it-work http://www.vesternet.com/knowledgebase/technical/kb-7 https://forum.fibaro.com/index.php?/topic/21899-danfoss-thermostat https://forum.fibaro.com/index.php?/topic/22644-4100-danfos https://forum.fibaro.com/index.php?/topic/19782-thermostat-danfoss-lc13-versus-devolo-thermostat https://forum.fibaro.com/index.php?/topic/22981-nest-fibaro-z-wave-radiator-valves https://forum.fibaro.com/index.php?/topic/22466-nest-thermostat-v3-fibaro-plugin-not-updating-workaround-found
  18. Zauważyłem brak jednej sceny napisanej w LUA. Ale ta scena działa. Zrobiłem ją jeszcze w FW 3. Nie potrzebowałem jej modyfikować więc nie wiem od kiedy jej nie widać. Jestem zalogowany jako admin. Co mogę zrobić aby dobrać się do tej niewidocznej sceny?
  19. Playing around with my MagicMirror installation, for now i just run app in servermode only and to my iPad, no mirror installation yet. Installing was no rocket sience, just followed the instructions. Added a couple of modules to play around with, first one out was weather data from wunderground and then a module with name syslog. So together with MagicMirror and a scene in my HC2 i can send data to be shown in the syslog module, thats nice Here is the lua scene code (just my first draft) --[[ %% properties %% events %% globals yeasterdayKW test --]] -- USER SETTINGS -- MMip = '192.168.0.137' MMport = '8080' local trigger = fibaro:getSourceTrigger(); local daysoftheweek={"Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag"} local yesterday = urlencode(daysoftheweek[os.date("*t").wday-1]) function urlencode(str) if (str) then str = string.gsub(str, "\n", "\r\n") str = string.gsub(str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") end return str end function MM(types,data) local function getMethod(requestUrl, successCallback, errorCallback) local http = net.HTTPClient() http:request(requestUrl, { options = { method = 'GET', headers = { }, }, success = successCallback, error = errorCallback }) end local url = 'http://'..MMip..':'..MMport..'/syslog?type='..types..'&message='..data getMethod(url, function(resp) print(resp.data) end, function(err) print('error' .. err) end ) end if (trigger['type'] == 'global') then if trigger['varName'] == 'yeasterdayKW' then MM('INFO',yesterday..'+'..fibaro:getGlobal(trigger['varName'])..'+'..'kWh') elseif trigger['varName'] == 'test' then MM('ERROR',fibaro:getGlobal(trigger['varName'])..'+'..'variabel') end elseif (trigger['type'] == 'other') then print('Scene started by other.') end
  20. local daysoftheweek={"Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag"} local day = urlencode(daysoftheweek[os.date("*t").wday-1]) function urlencode(str) if (str) then str = string.gsub (str, "\n", "\r\n") str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") end return str end function MM(data) local function getMethod(requestUrl, successCallback, errorCallback) local http = net.HTTPClient() http:request(requestUrl, { options = { method = 'GET', headers = { }, }, success = successCallback, error = errorCallback }) end local url = 'http://192.168.0.137:8080/syslog?type=INFO&message='..data getMethod(url, function(resp) print(resp.data) end, function(err) print('error' .. err) end ) end MM(day..'+'..fibaro:getGlobal("yeasterdayKW")..'+'..'kWh') Result [DEBUG] 14:13:32: {"status":"success","payload":{"type":"INFO","message":"Söndag 34.96 kWh","timestamp":"2016-10-10T12:13:32.103Z"}} Should be [DEBUG] 14:13:32: {"status":"success","payload":{"type":"INFO","message":"Söndag 34.96 kWh","timestamp":"2016-10-10T12:13:32.103Z"}} so i think my header with utf8 is not correct. If i run url direct in browser it works with same data
  21. Created a LUA function you can use in a scene to upload data to emoncms.org. toEmonCMS = function(id,value,InputKey) local http = net.HTTPClient() -- CHANGE WRITE API KEY FOR EMONCMS local apikey = '1966dcf7b44xxxxxxxxxxxxxxxxxxx' -- SHOULD NOT BE NECESSARY TO EDIT BELOW THIS LINE -- local url = 'https://emoncms.org/input/post.json?json={' http:request(url .. InputKey .. ':' .. fibaro:getValue(id, value).. '}' ..'&apikey='..apikey, { options = { method = "POST", }, success = function(response) fibaro:debug (response.data) end, error = function(err) fibaro: debug ("Error:" .. err) end }) end toEmonCMS(58,'value','Temperature') Example first 319 is id of device, second power is what value you want to upload, third Power is the InputKey in emoncms site Upload power data toEmonCMS(319,'power','Power') Upload temperature data toEmonCMS(58,'value','Temperature')
  22. Hi! I need to create this functionality in LUA Code on Virtual Devices: Aim: To toggle commands each time that button is pressed. Description: The Virtual Device button called “Cursor Left” needs to save Two Commands “Global Cache Executable : InfraRed Code 1” and “Global Cache Executable : InfraRed Code 2”. Working: We need that each time we press the button “Cursor Left”, “IR Code 1” is sent and the second time we press the button “IR Code 2” is sent, when we press it the third time “IR Code 1” is sent and so on. At no instance “IR Code 1” and “IR Code 2” should be sent together. It should always execute Code 1 then Code 2 then Code 1 . . . . . only when the virtual device button is pressed. The program would be saved on each button of the virtual device, virtual device in this case would be a remote comprising of different buttons and codes. How RC6 Codes Work : RC6 each codes is used in alternating order. After the first code gets sent, the equipment is looking for the next code. Best Regards, Kunal Sabharwal
  23. CANCEL THIS - I SOLVED IT WITH A VD USING THE MAIN LOOP Hi, This is prob not a huge mystery and something basic I'm missing. If I remove the While true do loop from the code below and execute it manually it works okay but once I add the while loop to get it check all the time the scene doesn't run Could somebody take a look and tell me where I'm being stupid Thanks -F --[[ %% autostart %% properties %% events %% globals --]] -- Configuration - Scene Info sceneName = "Sonos State tracker" sceneVersion = "1.0.1" -- Scene Description -- Track and stores the state of three of the sonos -- zones so the respective amp can be switched on -- Configuration - Device IDs -- none for this scene -- Validate Number of Scene Instance if (fibaro:countScenes()>1) then --fibaro:debug("stop scene") fibaro:abort() end -- read playroom state function StateFunc() while true do fibaro:sleep(2000) -- execute this every 2 seconds if fibaro:getGlobal("G_SPC_AREA_STATUS_1") == "UNSET" then -- don't check if we are not at home http = net.HTTPClient({ timeout = 3000 }) url = 'http://192.168.1.89:5005/Playroom/state' controlHeaders = {['content-type'] = 'application/json; charset=utf-8'} http:request(url, { options = { headers = controlHeaders, method = 'GET', }, success = function(response) if response.status == 200 then local responds = json.decode(response.data) local zPRState = responds.zoneState fibaro:debug(zPRState) fibaro:setGlobal("Sonos_PRState", zPRState); end end, }) -- read living room state http = net.HTTPClient({ timeout = 3000 }) url = 'http://192.168.1.89:5005/Living_Room/state' controlHeaders = {['content-type'] = 'application/json; charset=utf-8'} http:request(url, { options = { headers = controlHeaders, method = 'GET', }, success = function(response) if response.status == 200 then local responds = json.decode(response.data) local zLRState = responds.zoneState fibaro:debug(zLRState) fibaro:setGlobal("Sonos_LRState", zLRState); end end, }) -- read dining room state http = net.HTTPClient({ timeout = 3000 }) url = 'http://192.168.1.89:5005/Dining_Room/state' controlHeaders = {['content-type'] = 'application/json; charset=utf-8'} http:request(url, { options = { headers = controlHeaders, method = 'GET', }, success = function(response) if response.status == 200 then local responds = json.decode(response.data) local zDRState = responds.zoneState fibaro:debug(zDRState) fibaro:setGlobal("Sonos_DRState", zDRState); end end, }) end -- end if statement end -- end while loop end -- end function -- Main Scene execution code StateFunc()
  24. Hi, I was wondering if anybody had tried this before. I am looking to ping a device on my home network to see if it is 'online' and then store something like an online/offline in a variable that I can display. I use static IP's for all the devices I am looking to monitor I was thinking about using the arp approach and see if the device is returned as part of the list Has anybody tried this before .. or do people think it may be possible or is there another route ? Thoughts appreciated Thanks Frank
  25. Hi, I am very confused by the functioning and documentation of "startLevelIncrease" that was made available a while ago. It is not documented, I think, outside of the release notes for the release, but the description there was: Ok, so I assume that devices with this call available in the interface when making a Lua scene will work for this. I also assume, since the documentation is a bit vague here, that the first optional parameter gives a time in milliseconds (usually the case) in which the change should have occurred, and a starting level. So, this code should dim up a light from 0 in 30 seconds then: fibaro:call(24, "startLevelIncrease",30*1000,0) But it does not. It dims in just about one second, and it does not matter att all what you specify in the third parameter. Trying it with a TKB plug in dimmer, which makes the call available in the Fibaro lua scene editor (so I guess it should work?)
×
×
  • Create New...