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. 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
  2. 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()
  3. 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"
  4. 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?
  5. 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!
  6. 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: @[email protected]@[email protected]) * 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
  7. 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
  8. 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
  9. 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.")
  10. 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
  11. 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?
  12. Hi, I have two central scene event 'scenes' that represent two different button press actions on one device (Remotec ZRC90) --[[ %% properties %% events 1425 CentralSceneEvent 4 Pressed %% globals --]] local MorningSceneID = 463 local startSource = fibaro:getSourceTrigger(); if ( ( true ) or startSource["type"] == "other" ) then fibaro:startScene(MorningSceneID); -- morning scene end and --[[ %% properties %% events 1425 CentralSceneEvent 3 Pressed2 %% globals --]] local HomeSceneID = 488 local startSource = fibaro:getSourceTrigger(); if ( ( true ) or startSource["type"] == "other" ) then fibaro:startScene(HomeSceneID); -- home scene end Does anybody know how to combine into one scene as this device has 8 buttons/4 options per button (32 events) and I'm trying not to end up with 32 separate scenes the api device dump is as follows... {"id":1425,"name":"Hall Scene Controlle","roomID":5,"type":"com.fibaro.remoteController","baseType":"com.fibaro.actor","enabled":true,"visible":true,"isPlugin":false,"parentId":1424,"remoteGatewayId":0,"interfaces":["battery","zwave","zwaveCentralScene","zwaveWakeup"],"properties":{"parameters":[],"zwaveCompany":"Remotec","zwaveInfo":"2,4,5","zwaveVersion":"1.1","wakeUpTime":0,"pollingTimeSec":0,"batteryLevel":"96","batteryLowNotification":"true","centralSceneSupport":"[{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":1},{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":2},{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":3},{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":4},{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":5},{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":6},{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":7},{\"keyAttributes\":[\"Pressed\",\"Released\",\"HeldDown\",\"Pressed2\"],\"keyId\":8}]","configured":"true","dead":"false","defInterval":"0","deviceControlType":"0","deviceIcon":"103","emailNotificationID":"0","emailNotificationType":"0","endPointId":"0","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"true","maxInterval":"0","minInterval":"0","model":"","nodeId":"196","parametersTemplate":"0","productInfo":"82,84,0,1,133,16,1,1","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","serialNumber":"","smsNotificationID":"0","smsNotificationType":"0","stepInterval":"0","useTemplate":"false","userDescription":""},"actions":{"reconfigure":0,"setInterval":1},"created":1468671788,"modified":1468671788,"sortOrder":414} Thanks -Frank SOLUTION local pressSource = fibaro:getSourceTrigger()["event"]["data"] --get data what was pressed --fibaro:debug(json.encode(pressSource)) -- Button 1 to 8 when button is PRESSED once if (tostring(pressSource["keyAttribute"]) == "Pressed") then if (tostring(pressSource["keyId"]) == "1") then fibaro:debug('Key 1 pressed once') -- replace with scene you want executed elseif (tostring(pressSource["keyId"]) == "2") then fibaro:debug('Key #2 pressed once') -- replace with scene you want executed elseif (tostring(pressSource["keyId"]) == "3") then fibaro:debug('Key #3 pressed once') -- replace with scene you want executed elseif (tostring(pressSource["keyId"]) == "4") then fibaro:debug('Key #4 pressed once') -- replace with scene you want executed elseif (tostring(pressSource["keyId"]) == "5") then fibaro:debug('Key #5 pressed once') -- replace with scene you want executed elseif (tostring(pressSource["keyId"]) == "6") then fibaro:debug('Key #6 pressed once') -- replace with scene you want executed elseif (tostring(pressSource["keyId"]) == "7") then fibaro:debug('Key #7 pressed once') -- replace with scene you want executed elseif (tostring(pressSource["keyId"]) == "8") then fibaro:debug('Key 8 pressed once') -- replace with scene you want executed end end Please see post http://forum.fibaro.com/index.php?/topic/21905-at-last-a-wall-mounted-scene-controller-that-works-scene-code-included/ for full scene that works with ZRC90
  13. 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
  14. 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')
  15. 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
  16. Guest

    Update of DDNS Using Scene

    Hi Guys, First post on here. I've just moved from a Vera to the HC2 to give it a go and find things quite difficult. I had a scene set up on my Vera than ran periodically to update my Dynamic DNS server using a wget function in Luup. I've been mucking around tonight for quite a while using Lua scenes trying to achieve the same outcome with no luck! I'm sure it's easy but can anyone help out? Thanks! Sam.
  17. 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()
  18. 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
  19. hi I thought I read somewhere that multiple http commands are not executed in the order that they are listed in the scene. I have a scene and it doesn't work 100% of the time and I think this may be the issue I tried grouping 3 or 4 commands into one http request and added a few sleep but with limited success sample script... function tempFunc() -- music on local http1 = net.HTTPClient() -- ungroup bed lauren-ethan from other rooms http1:request('http://192.168.1.89:5005/Landing/ungroup/Bed_LE') http1:request('http://192.168.1.89:5005/Bed_MasterR/ungroup/Bed_LE') http1:request('http://192.168.1.89:5005/Bed_MasterL/ungroup/Bed_LE') http1:request('http://192.168.1.89:5005/Bed_Guests/ungroup/Bed_LE') http1:request('http://192.168.1.89:5005/Bed5_Office/ungroup/Bed_LE') fibaro:sleep(200) local http2 = net.HTTPClient() -- ungroup bed frank from other rooms http2:request('http://192.168.1.89:5005/Landing/ungroup/Bed_Frank') http2:request('http://192.168.1.89:5005/Bed_MasterR/ungroup/Bed_Frank') http2:request('http://192.168.1.89:5005/Bed_MasterL/ungroup/Bed_Frank') http2:request('http://192.168.1.89:5005/Bed_Guests/ungroup/Bed_Frank') http2:request('http://192.168.1.89:5005/Bed5_Office/ungroup/Bed_Frank') fibaro:sleep(200) -- select radio favourite local http3 = net.HTTPClient() http3:request('http://192.168.1.89:5005/BED_FRANK/Favorite/Calm%20Radio') http3:request('http://192.168.1.89:5005/BED_LE/join/BED_FRANK') fibaro:sleep(1000) -- clean up to make sure master room spaekers remain joined and volume is correct local http4 = net.HTTPClient() http4:request('http://192.168.1.89:5005/BED_MASTERL/join/BED_MASTERR') http4:request('http://1922168.1.89:5005/BED_FRANK/Volume/14') http4:request('http://192.168.1.89:5005/BED_LE/Volume/14') fibaro:sleep(1000) -- setup music for kids at night local http5 = net.HTTPClient() http5:request('http://192.168.1.89:5005/BED_FRANK/Favorite/Calm%20Radio') http5:request('http://192.168.1.89:5005/BED_LE/join/BED_FRANK') fibaro:sleep(1000) -- clean up to make sure master room speakers remain joined and volume is correct local http6 = net.HTTPClient() http6:request('http://192.168.1.89:5005/BED_MASTERL/join/BED_MASTERR') http6:request('http://1922168.1.89:5005/BED_FRANK/Volume/14') http6:request('http://192.168.1.89:5005/BED_LE/Volume/14') end BACKGROUND I am using the nodejs sonos bridge and need to be to execute http commands in a certain sequence of commands ie ungroup RoomA, RoomB, RoomC Group Room B with RoomZ Set station to Fav1 and play Adjust volume to 18% Complications arise when they are executed out of sequence Has anybody experienced this and have a solution...
  20. Is it possible to check if the virtual device button was pressed in lua? Is there any function for that in lua? I want to code something like this: (If Button "3" of virtual device with an ID of 674 was pressed than a=a+1) for example
  21. Are the IP Address and TCP Port properties for a virtual device read only in LUA and only able to be changed using the web interface? Tried the following from a scene with no success. fibaro:call(id.vd, "setProperty", "ip", newIP) fibaro:call(id.vd, "setProperty", "port", newPort) fibaro:call(id.vd, "setProperty", "IPAddress", newIP) fibaro:call(id.vd, "setProperty", "TCPPort", newPort)
  22. Hi, I just registered for a developer.fibaro.com account to see if the Lua library description was better there than what is posted on the public web (http://www.fibarouk.co.uk/support/lua/library/). It is not. As I understand it, these functions you still need to hunt around in the forum release notes to get a description of: setTimeout fibaro:setSceneRunConfig fibaro:getSceneRunConfig fibaro:setSceneEnabled fibaro:isSceneEnabled fibaro:getDevicesId And this function is more of a rumor. A mystical being that someone discovered and that may be present (have not checked yet, but just the fact that new functions are mentioned first in the forum tells you something about the state of things): clearTimeout So, for how long will this be the way developers are treated? Would there not be less problems reported on the forum if documentation was actually updated (not just copied in to a more pretty frame) AT LEAST when a non-beta version is released. Fredrik
  23. Hi all, I want to send commands to my Rotel amplifier from my HC2, using lua in a virtual device. The service I want to connect to is a websockets service on an RPi2 connected to the Rotel over USB. It's the json-serial-port-server by John Lauer, https://github.com/chilipeppr/serial-port-json-server. I did find connections using tcpsockets in lua, but tcpsockets and websockets are different things. All other (http) connections don't work. If I get something like a connection from lua, an additional window opens on top of my browser connection to my HC2. This is not useful. Anyone any idea how to use websockets from lua? Thanks in advance, Evert
  24. Hi all is there a lua command to perform a "soft reconfiguration" on a zwave device. Specifically, my immediate need is to configure s remotec zxt-120 v1.6 aircon controller. It's just a little tedious to change the IR code set, then perform a soft reconfiguration to test it. I'd rather write a script and stop the script when the device in question receives a valid IR signal.
  25. Hi guys, is there a lua command to soft reconfigure a device. I'm trying to write a script to test the IR code sets of a remotec zxt-120 v1.6 aircon controller, but given a soft reconfigure is required after every code set change, it would be easier with a lua script
×
×
  • Create New...