Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Search the Community

Showing results for tags 'LUA'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

  1. Hi, I would like to receive a notification, when the temperature on the fibaro heat controller is manually changed. I tried to write a lua scene, but I don´t know how to use change of "Setpoint" as trigger. Thanks for your help
  2. Hi, I'm new to LUA but I am trying to read the current value of R and assign it to B. I basically have 2 white strips and 2 sets of downlights, assigned to the RGBW channels. I want the 2 sets of strips to copy each other and the 2 sets of downlights to copy each other, so if I dim one strip, it mimicks on the other strip and if I dim one set of downlights it mimicks on the other set of downlights. So I want to read the current value of R and assign it to B and read the current state of G and assign it to W. Thanks in advance!
  3. Hi everyone, I'm having some issues with Lua code in a virtual device I am writing. I'm getting information on the status of my Bluespray irrigation controller. It has a basic API and reports if any of the zones are on watering. I want to just query the unit and then print out if any are detected as on. When I query bluespray controller and its not watering anything I get some JSON back which looks like this. { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ ], "timestr": "Sat Mar 11 2017 10:09:38 PM", "time": 1489241378000, "door": 0 }, "id": 528452 } When its IS watering I get the following. { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ { "on": 1489240754, "off": 1489241054, "run": 1489240754, "terminal": 3 } ], "timestr": "Sat Mar 11 2017 10:00:12 PM", "time": 1489240812000, "door": 0 }, "id": 218829 } To make it even more complex sometimes the system reports multiple zones operating. (This is normal and ok. I just need to pick up the first zone reported) { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ { "on": 1489241854, "off": 1489241974, "run": 1489241854, "terminal": 4 }, { "on": 1489241854, "off": 1489241974, "run": 1489241854, "terminal": 8 } ], "timestr": "Sat Mar 11 2017 10:17:38 PM", "time": 1489241858000, "door": 0 }, "id": 998161 } My issue is detecting if I get none, one or multiple active zones. If I have a valid zone then I then want to put the first zone number into the zoneterminal variable. If I don't have a valid zone I just want to put 0 into the zoneterminal variable. The problem is when I try something like the code below I get [ERROR] 22:11:22: line 56: attempt to index field '?' (a nil value) I cant figure out how to deal with LUA arrays correctly. (specifically detecting valid entries) The json.null operator does not seem to work the same way on array values. -- This script polls data from a local Bluespray Irrigation controller every 60 seconds and displays the status of the active zones -- Its configured for a speicific system but could easily be adapted to any bluespray controller. -- This script is written for Fibaro HC2 -- Script written by Brom ([email protected]) -- version 0.1 (10/3/17) function round(x, n) n = math.pow(10, n or 0) x = x * n if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end return x / n end fdata = {} zonename_1 = "Front Lawn" zonename_2 = "Road Lawn" zonename_3 = "Front Garden" zonename_4 = "Back Lawn Left" zonename_7 = "Back Lawn Right" zonename_5 = "Back Garden Left" zonename_6 = "Back Garden Right" fdata.selfId = fibaro:getSelfId() fdata.selfIp = fibaro:get(fdata.selfId, "IPAddress"); -- Perform the grab from the irrigation controller. local irrigationcontroller= Net.FHttp(fdata.selfIp); response,status,errorCode = irrigationcontroller:GET("/api/status") -- Basic debugging fibaro:debug(response) -- Check the respose from the controller is valid and Pull out the details from the JSON response. if (tonumber(status)==200 and tonumber(errorCode)==0) then local irrigation = json.decode(response) -- If any of the responses are null then make them 0 if irrigation.result.time == json.null then polltime = 0 else polltime = irrigation.result.time end -- this bit does not work !!!! zoneterminal = irrigation.result.active_zones[1].terminal zoneon = irrigation.result.active_zones[1].on zoneoff = irrigation.result.active_zones[1].off zonerun = irrigation.result.active_zones[1].run -- Basic Debugging fibaro:debug("polltime: "..polltime) fibaro:debug("zoneterminal: "..zoneterminal) fibaro:debug("zoneon: "..zoneon) fibaro:debug("zoneoff: "..zoneoff) fibaro:debug("zonerun: "..zonerun) timeleft = (zoneoff - zonerun) / 2 / 60 fibaro:debug("timeleft: "..timeleft) -- Output to the device. if zoneterminal == 0 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," OFF ") end if zoneterminal == 1 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_1) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 2 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_2) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 3 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_3) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 4 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_4) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 5 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_5) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 6 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_6) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 7 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_7) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 0 or zoneterminal == 1 or zoneterminal == 2 or zoneterminal == 3 or zoneterminal == 4 or zoneterminal == 5 or zoneterminal == 6 or zoneterminal == 7 then fibaro:debug("Valid Zone") else fibaro:call(fdata.selfId, "setProperty", "ui.watering.value","Error") end else fibaro:debug("error Irrigation Controller: "..errorCode) end -- sleep for 1 min fibaro:sleep(10000) -- fibaro:sleep(60000) Any help appreciated. ps Code for the output is really extra long. Looking to understand how I can manipulate the variable name / number I am outputting to reduce the number of if statements. Once I get this figured out I plan to also add in buttons to perform manual runs. Brom
  4. Czy ktoś może podpowiedzieć jak stworzyć scenę w której z określonym interwałem czasowym centrala wyśle powiadomienie push z informacją o aktualnej wartości czujnika? Chciałbym aby klient raz na dzień dostawał info jaka jest wilgotność powietrza, ponieważ jest to ważne dla odpowiedniego utrzymania jego drewnianej podłogi. ____________ Can anyone suggest how to create a scene in which, with a specific time interval, HC3 will send a push notification with information about the current sensor value? I would like to receive information about the air humidity once a day, because it is important for the proper maintenance of client wooden floor.
  5. Hi I'd like to open/close the danalockv3 id541 using two triggers. Holding the light switch (the danalock status changes each time the key id553 is held down) or the alarm output (the ldanalock status changes depending on the alarmoutput id430 status on/off on=unsecure off=secured). In addition, the alarm output state should be synchronized with the lock state, because I can open the lock manually for example. How to modify the lua code below to add a second trigger to it (alarm out) and synchronize lock state? { conditions = { { id = 553, isTrigger = true, operator = "==", property = "centralSceneEvent", type = "device", value = { keyAttribute = "HeldDown", keyId = 1 } }, { id = 430, isTrigger = true, operator = "!=", property = "state", type = "device", value = {} } }, operator = "any" } local deviceValue1 = fibaro.get(541, "value") if deviceValue1 == true then fibaro.call(541, 'unsecure') else fibaro.call(541, 'secure') end
  6. Hello. I have written a code in LUA 5.4 which gives me a list of prices and timestamps through a URL, and on FIBARO HC2 it wont work. I understand that FIBARO HC2 uses Lua 5.1 or something like that. I am trying to start a boiler and a heater using HC2, but I have no idea how to start with that. How can I start the boiler and a heater at the time when prices are low on HC2 using a website URL? If required, I will provide more information in the comments. Thanks in advance.
  7. Witajcie. Jak macie rozwiązane opóźnienie nawadniania? Korzystam z wbudowanych danych centralki HC-2. Chciałbym żeby podczas deszczu automatycznie mi opóźniał nawadnianie o, powiedzmy 12 godzin. Jak to zrobić w LUA?
  8. I am trying to push a certain button from a different device, if the door is closed, but I cant locate how to let FIBARO know that the door is closed. How can I do that in scenes? Thanks in advance.
  9. I am very conversant with the HC2 stuff. For the HC3, the last time I looked at this a year ago, the offerings were rather disappointing with a steep learning curve. Could some one recommend A decent example of a lua scene. I am fine with the language change - I have just grepped and done global modifications on my 30 odd lua scenes. I am looking for a better explanation of the new trigger mechanism. A decent example of the new VD and any gotchas. Before I could just save the lua as a text file on pc with versioning. How are people saving the new scenes, as they come in two parts ?
  10. I am trying to start a boiler and a heater from an URL that has a lot of prices and timestamps. I am using Home Center 2. I have no idea where to start from, I understand I need VD (Virtual Devices) and Scenes, but anything I have tried hasn't worked sadly. How can I start a boiler and a heater during the lowest prices with JSON timestamp values from an URL? If required, I can post the URL here. Can anyone help me?
  11. Introduction to API and http requests Like the other 'Introduction to' posts I'm h0ping this may help some of the people begining their HC2 and lua journey Corrections and suggestions to improve always welcome. What is an API An API can be used to execute commands but the majority are used to request a response or status. Most API’s are interrogated through a http or https request. Some API’s require authentication in the form of a username or a password or an API key. There are public API’s and private API’s. There are a number of API types and the one of the most widely used is a called RESTAPI. This type of API is supported by the HC2 but there are others such MQTT, SOAP, etc The following are API’s that you may have come across in this forum and there are many others Home Center 2 : http://<hc2-ip>/docs (where hc2-ip is the ipaddress of your hc2 192.168.x.x OWN : open weather map ( https://openweathermap.org/api ) Sonos-http-api : ( https://github.com/jishi/node-sonos-http-api ) AWS Polly: used for TTS (http://docs.aws.amazon.com/polly/latest/dg/API_Reference.html ) VoiceRSS : used for TTS (http://www.voicerss.org/api/documentation.aspx ) Some organisations like AWS or Google have multiple API’s that are used for different purposes Structure All API’s has a set of web methods with a set structure. An API call or request can be either a GET, DELETE, POST, PUT and for this introduction we will focus on the GET This means that the data format is predictable and as such is easy to traverse and extract responses. Most RESTAPI responses have a format that conforms to json standard. Json is a way to store information in an organized, easy-to-access manner. It gives us a human-readable collection of data that we can access in a really logical manner. All public API’s are documented like the ones outlined above so a under will know what to expect when they issue a http request. A simple json example would be something like local jStr = {"age" : "24", “hometown" : "Missoula, MT", "gender" : "male" }; A slightly more complicated json string could be be {"coord":{"lon":15.98,"lat":45.81},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"base":"stations","main" :{"temp":10.86,"pressure":1018.82, "humidity":66,"temp_min":10.86,"temp_max":10.86,"sea_level":1035.43,"grnd_level":1018.82},"wind":{"speed":1.06,"deg":281.501},"clouds":{"all":32},"dt":1487346966,"sys":{"message":0.0038,"country":"HR","sunrise":1487310847,"sunset":1487348795},"id":6618983,"name":"Zagreb - Centar","cod":200} This could also be referreed to as a tbale because of it's structured format. Fortunately there are websites like http://jsonprettyprint.com/ that make these json strings easier to read { "coord": { "lon": 15.98, "lat": 45.81 }, "weather": [ { "id": 802, "main": "Clouds", "description": "scattered clouds", "icon": "03d" } ], "base": "stations", "main": { "temp": 10.86, "pressure": 1018.82, "humidity": 66, "temp_min": 10.86, "temp_max": 10.86, "sea_level": 1035.43, "grnd_level": 1018.82 }, "wind": { "speed": 1.06, "deg": 281.501 }, "clouds": { "all": 32 }, "dt": 1487346966, "sys": { "message": 0.0038, "country": "HR", "sunrise": 1487310847, "sunset": 1487348795 }, "id": 6618983, "name": "Zagreb - Centar", "cod": 200 } To access an api you need 2 things ip address, port, etc to make the http/https request Structure/format of the response so you know how to traverse it and extract what you want The easiest way to explain and learn is by example. As it is highly likely that everybody reading this will have a HC2 we can use to demonstrate the principles. The HC2 RESTAPI is documented on the Fibaro developer site at https://developer.fibaro.com/docs/fghc-restapi The one we will look at is devices. This the first one under the General category at the developers website above. The developer website shows the various parameters that are returned with this call. The API can be used to request information or complete an action. We will look at the request for information If you go to http://,hc2-ip./docs you will see the interactive or inline documentation for web API Go to the section on devices and select deviceid enter a device number ( I selected device 176 which is a dimmer module ) and click Try It. You will see the json formatted or encoded response for that API call. You will also see the full url for the call. If you copy the url and paste it into a browser you will get the same thing (except as one long string) {"id":176,"name":"kitchenPendant","roomID":7,"type":"com.fibaro.multilevelSwitch","baseType":"com.fibaro.binarySwitch","enabled":true,"visible":true,"isPlugin":false,"parentId":175,"remoteGatewayId":0,"interfaces":["deviceGrouping","fibaroFirmwareUpdate","levelChange","light","power","zwave","zwaveConfiguration","zwaveSceneActivation"],"properties":{"parameters":[{"id":1,"lastReportedValue":255,"lastSetValue":255,"size":1,"value":255},{"id":6,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":7,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":8,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":9,"lastReportedValue":5,"lastSetValue":5,"size":1,"value":5},{"id":10,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":11,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":12,"lastReportedValue":99,"lastSetValue":99,"size":1,"value":99},{"id":13,"lastReportedValue":2,"lastSetValue":2,"size":1,"value":2},{"id":14,"lastReportedValue":2,"lastSetValue":2,"size":1,"value":2},{"id":15,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":16,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":17,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":18,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":19,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":20,"lastReportedValue":110,"lastSetValue":110,"size":1,"value":110},{"id":30,"lastReportedValue":3,"lastSetValue":3,"size":1,"value":3},{"id":39,"lastReportedValue":600,"lastSetValue":600,"size":2,"value":600},{"id":41,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0}],"pollingTimeSec":0,"zwaveCompany":"Fibargroup","zwaveInfo":"3,3,52","zwaveVersion":"2.2","configured":"true","dead":"false","deviceControlType":"23","deviceGroup":"[]","deviceGroupMaster":"0","deviceIcon":"15","emailNotificationID":"0","emailNotificationType":"0","endPointId":"0","firmwareUpdate":"{\"info\":\"\",\"progress\":0,\"status\":\"UpToDate\",\"updateVersion\":\"2.2\"}","isLight":"true","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"false","model":"","nodeId":"49","parametersTemplate":"235","power":"0.00","powerConsumption":"42","productInfo":"1,15,1,0,16,10,2,2","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","sceneActivation":"0","serialNumber":"","showEnergy":"true","smsNotificationID":"0","smsNotificationType":"0","updateVersion":"","useTemplate":"true","userDescription":"","value":"0"},"actions":{"associationGet":1,"associationSet":2,"getParameter":1,"reconfigure":0,"setParameter":2,"setValue":1,"startLevelDecrease":0,"startLevelIncrease":0,"stopLevelChange":0,"turnOff":0,"turnOn":0,"updateFirmware":1},"created":1486747960,"modified":1486747960,"sortOrder":13} EXAMPLE - API Call from a Virtual Device The following is a http request to the HC2 api. Copy the following in a button or main loop in a virtual device local device = fibaro:getSelfId() localhost = '127.0.0.1' local port = 11111 diag = Net.FHttp(localhost, port); response = diag:GET("/api/devices/176") result = json.decode(response); fibaro:debug("name: "..result.name) fibaro:debug("properties.value: "..result.properties.value) run the vd and open the debug window You’ll see the name and value of the device you selected. If you look through the json response from further up in the tutorial you’ll see the correlation between the results and the json There are some examples of how to iterate through an array in another one of the tutorials I posted. Please see my signature… One last one in case you have difficulty sleeping and the if the above was too simple This function iterates through all the virtual devices on your HC2 and looks for one called 'LAN Network 2.0' The 'LAN Network 2.0' virtual device has multiple labels The function iterates through the virtual device and counts all the labels ( in the json for the virtual device these are called rows) For each row above it looks for an element type ‘Label’ It then iterates through all the labels checking that they match the default format of Label1, Lable2, etc. string.match(jT[i].properties.rows[r].elements[e].name, "Label")) == "Label" The result is a loop inside a loop inside another loop, iterating and checking at each step full code for function to pick through when you have some time. function labelCheck() fibaro:log("vdCheck mode enabled") local device, localhost, port = fibaro:getSelfId(), '127.0.0.1', 11111; diag = Net.FHttp(localhost, port); response = diag:GET("/api/virtualDevices") jT = json.decode(response); for i = 1, #jT do if jT[i].name == "LAN Monitor 2.0" then if #jT[i].properties.rows == #jN then labelCount = "true" else labelCount = "false" end for r = 1, #jT[i].properties.rows do for e = 1, #jT[i].properties.rows[r].elements do if (string.match(jT[i].properties.rows[r].elements[e].name, "Label")) == "Label" then labelMatch = labelMatch else labelMatch = "false" end end end end end if labelCount == "true" and labelMatch ~= "false" then fibaro:debug("Quantity and format of labels is correct") else if labelCount == "false" then fibaro:debug("Quantity of labels incorrect") fibaro:log("Quantity of labels incorrect") end fibaro:sleep(3000) if labelMatch == "false" then fibaro:debug("Label format is incorrect") fibaro:log("Label format is incorrect") end end end Happy coding and suggestions to improve/correct always welcome -f
  12. Is it possible to change the range of a slider, I mean, instead of going from 0% to 100%, can I make it go from 15ºC to 30ºC somehow, if not, can I remove the percentage tag of the slider completely? Thx
  13. Quick question: How can I update the value of a slider? I've tried self:updateProperty, self:updateView, fibaro:call, etc, and none of them seem to work.
  14. Hi, I would like to set a device parameter thru either a virtual device (preferred) or a scene In my example, I have a doorlock (IDLock 101) and would like to set parameter number 1 (autolock mode) The parameter can set the lock to autolock(arm or not armed) or manual (arm or not armed) https://idlock.no/wp-content/uploads/2018/03/IDL-Operational-Manual-EN-v1.3.pdf Is it possible thru LUA or do I need to set it another way? Regards
  15. There is supposed to be only three types of controls: buttons, sliders and labels, but if I create a Quick App with a template (thermostat auto for instance), I has other controls, like combo boxes. How can I add those custom controls or create them myself. And why can I not delete the controls of the templates, I mean, if I use a template, I can only delete the controls that I add on top of the default ones, in fact, those templates controls don't even show up in the preview window. whut ?¿?¿
  16. I need to send commands to a Modbus router to turn on a thermostat. I've heard that the commands need to be sent in hexadecimal format, as shown in this example I found online: function QuickApp:turnOn() comand = string.char(0x00,0x01,0x00,0x00,0x00,0x06,0x01,0x06,0x00,0x64,0x00,0x01); self:send(comand) -- sending data to the device. In a normal implementation it will be a code with an appropriate command. self:updateProperty("value", true) end But how can I know how to encript the commands I want in this format, I mean, how many characters it needs to be, in what order, etc. I can't find any info online so any help is appreciated. Thx.
  17. I have some device connected to z-wave plugs that can measure the energy consumption and aeon labs plugs are used. Now I would like every month a report how many kWh, all summary of consumption. Best would be to get that report by email. Is something like this possible in the HC3 lite with LUA? Can anybody help me to get started: - how to get all consumption summary - how to send an email - how to run the script only once per month Thanks
  18. Hi Everyone Smart Message Hub v1.2 (SMsgH v1.2) is now available. This release includes fixes tor three bugs that had various impacts and support for international characters. Thanks to @Sankotronic and @szmyk for locating the faults and extra feature for international characters "FIRST TIME USERS" - Please read below and follow the instructions laid out for first time users UPGRADING FROM 1.1b to 1.2 - Please use this Post - if you are a current user and may wish to consider avail of the fixes or extra feature This scene enables a user to send a message from either a scene or a virtual device to a number of notification and TTS services with a startScene call fibaro:startScene(682, {message, target}) -- Using ID of scene fibaro:startScene(SMsgH, {message, target}) -- Using HomeTable reference The scene also enables messages to be re-routed or queued depending on whether the house is set to Away mode, Sleep mode or if internet is not available. (See below for more details) A demo VD {v1.1} is also available to help demonstrate the scene features. SCENE FEATURES Smart Configuration options include the ability to re-route and/or queue all messages under certain conditions. (Internet unavailability , home occupancy mode presentState = Away) Messages with international characters are also supported Notification messages can be redirected to Home Center 2 Popup notification service if the internet is offline or unavailable Notification messages can be queued if the internet is offline or unavailable. All Messages in the queue will be released as one combined message once the internet come s back online. All TTS messages can be redirected to Home Center 2 Popup notification service if the internet is unavailable or offline or if the sonosAPI is offline if this solution is being leveraged All TTS messages can be queued if presentsState = Away. All TTS messages in the queue will be announced once presentsState = Home Simplified the message invocation method to startScene Invoked via startScene(SMsgHid, {message string} (SMsgHid is the id of the SMsgH scene when it is saved to your system ) See below for examples messageHub global no longer required (please delete when you have migrated all your scenes to using 1.1) Added support for sleepState (no TTS messages if set to Sleep) Additional support for HC2 popup notifications Types (Critical, Successs, Info, Warning) Images (use full url) Buttons (represented as a table) - See @Sankotronic [TUTORIAL] on popup notifications to see how to format Added ability to delay unloading of TTS messages by predefined time in seconds Added support for custom language in for TTS and Notify redirects default Popup title and subtitle Minor bug fixing and code cleaning Configuration options also include a default message notification target, title, subtitle and volume but all these can also be specified as part of the message invocation. There are three levels of debug verbosity. In normal mode there is a minimal amount of information displayed as the scene is triggered. The two other modes allow for much more expressive displaying of scene variables as well as configuration settings if enabled deBgVar is enabled in the scene so you can see the interactions- it can be disabled in normal running mode SCENE MESSAGING OPTIONS The supported services in this release include the following (supported in 1.0 & 1.1) Pushover Notifications -------------------------------------------------------> [TUTORIAL] on creating Pushover account and set up allinone ( jompa68 scene) Telegram messages hc2email (Home Center 2 email service) hc2push (Home Center 2 push notification service) hc2popup (Home Center 2 Popup Notification service) -------------------> [TUTORIAL} Popup Noification and Custom Inages Sonos-api based TTS --------------------------------------------------------> [TUTORIAL] Setting up and using Alternative Sonos VD using node-sonos-api Sonos VD Remote based TTS -----------------------------------------------> Discussion on Sonos Remote V1.0.0 beta I have also included a Companion Demo VD. The virtual device will allow the user to demonstrate the scenes queuing/unloading capabilities. CAUTION: The companion VD in demo mode can adjust the presentState and sleepState globals and will cause any other scene you may have with this as a trigger to execute A simplified version of the LAN Monitor VD called the WWWAPI Monitor will monitor just the sonos-api if desired and does not any in-built notification options like the LAN Monitor VD 2.5.Smart Message Hub users should use either the WWWAPI Monitor or LAN Monitor 2.6 Special thanks extended to @Sankotronic @petergebruers, @jompa68 and @szmyk for their contributions leading to 1.2 Once the scene configuration is complete I would recommend running the demonstration virtual device. This will give you a better understanding of the options and features as well providing some sample messages that you can run. Ideas for subsequent revisions are always welcome _f RELEASE CHANGELOG v1.0 - First release (march 4th 2017) v1.1 - Second release (march 17th 2017) v1.2 - Third Release (june 24th 2017) ================================================ FIRST TIME USERS - INSTALLATION & CONFIGURATION ================================================ The code is available in both lua and txt format below Paste code into scene and run - All global variables will be automatically created (Please do not adjust global triggers in scene header) Configure options as required at top of scene (line 100 onwards) Configure enable smart redirects Configure HC2 email settings, HC2 push settings and TTS services Configure default message titles, subtitles and volume Configuration notification settings, tokens, etc Enable/Disable increased debug and config verbosity for troubleshooting MESSAGE INVOCATION This message hub can be called from either a scene or a virtual device using a startScene call. The following is an example Sample invocations are included below Please see the section on Message Invocation lower down in this post of you wish to send messages with international characters local message = "Warning: Utility room freezer temperature is 10 degrees" local target = "hc2popup" local volume = "25" -- (can be left as "" if not TTS message) local title = "new alert title" local subtitle = "new subtitle" local popType = "Critcal" local popImg = "" local popButtons = "" fibaro:startScene(IDofSMsgHscene, {message, target, volume, title, subtitle, popType, popImg, popButtons}) Note: Replace IDofSMsgHscene with HomeTable reference of numerical ID of the SMsgH scene when it is installed on your system You need to include all parameters up to last one you populate. For example, if you want to specify a subtitle, you need to include message, target, volume and title as well. You CANNOT leave out a parameter in the call. Leave as "" if not used/required and default will be invoked. **USER CONFIGURATIONS & SETTINGS** OPTIONS FOR SMART RE-ROUTING OF MESSAGES The following four options can be set to true or false depending on what features you wish to enable. local tts2popup = "true" Set to true to enables re-routing of sonos TTS messages from either the Sonos VD or the sonos-api solution to HC2 notification Popup if the sonos-http-api or Internet is unavailable/offline to your local LAN local tts2queue = "true" Enable to Silence TTS announcement in sleepState, TTS announcements are NOT queued, they are simply discarded local tts2sleep = "true" Enable a Delay before TTS announcements are unloaded (seconds). Leave as "" for no delay local ttsUnloadDelay = "" -- seconds Set to true to enable Sonos TTS messages to queue when presentState = 'Away'. When presentState is set to Home it triggers the scene to automatically unload all the messages in the TTS queue to the default player that has been named in the configuration section local notify2popup = "true" Set to true to enable all notifications to re-route to HC2Popup notifications if the internet is unavailable/offline to your local LAN local notify2queue = "true" Set to true to enable all notifications to queue when presentState= 'Away'. When presentState is set to Home it triggers the scene automatically and unloads the message in the notifications queue to the default notification service that has been named in the configuration section below The scene as provided has all these 4 options set to true and this is the recommended setup if you wish to leverage full functionality and the demo OPTIONS TO MONITOR THE INTERNET STATUS To achieve the most benefit from this scene the internet and sonos-api should be dynamically monitored. Dynamically monitoring the internet will enable messages (TTS and notifications) to be queued while the internet if offline. Queued message can also be sent as hc2 pop notifications on the local LAN. The preferred monitoring option is named here. The example below is setup to use the LAN Monitor VD 2.5 local ipMonitor = "networkTable" There are 3 options available: Select 'manual' if you wish internet and sonos-api to be permanently set to online. Please note that this option does NOT enable queuing of notification messages. Select 'networkTable' to leverage the LAN Monitor VD 2.5, Select 'wwwapiTable' to leverage the new simplified WWWAPI Monitor 1.0 HC2 EMAIL CONFIGURATION hc2emailUsers = {["su"]="2", ["frank"]="1564", ["sylvia"]="1565"} List all users that you want to be able send messages to. The user id's are located from the HC2. Select Configuration, then Access Control to see the current users. HC2 PUSH CONFIGURATION hc2pushUsers = {["DadiPh"]="563", ["MumiPh"]="155", ["DogiPa"]="175"} List all users that you want to be able send push messages to. The mobile devices ID can be found by going to http://<HC_IP>/docs/ and looking under iosDevices section. local defhc2pushUser = "563" -- identify default hc2push user Select a default user from this list and this is used if there is no user specified as part of the message invocation. TTS PREFERENCES Select your TTS preference. If you use the sonos-http-api solution please enter API. If you use the Sonos VD Remote solution please enter REM. local ttsMethod = "API" Default volume for TTS announcements local defTTSvolume = "12" This allows you to select a default volume and this aplies to both the API and REM sonos solutions. This volume can be changed by including a different volume in the message invocation SONOS-API PREFERENCES Configure this section if you have selected API in the above section. APIplayers = {"hallway","kitchen","bed5_office","landing"} List all the sonos players you want to send TTS messages to. The zone/player names must match exactly what is on your sonos native application local defAPIzone = "bed5_office" The default player/zone selected is used to unload the TTS message when presentState = Home. The default player must be included in the overall players list above local APIipaddress = "192.168.1.89" local APIport = "5005" The ip address and port are of the device that is hosting the sonos-api local defAPIlanguage = "Amy" The final item here is the language or voice code for the respective TTS service. Thisoculd be something like en-gb for google or Amy for AWS Polly SONOS REMOTE VD PREFERENCES Configure this section if you have selected REM in the above section. REMplayers = { ["kitchen"] = {vd="295", btn="28"}, ["hall"] = {vd="765", btn="27"}, } List all the sonos player virtual devices you want to send TTS messages to. The virtual device id's and process button id’s much match exactly what is on your HC2 for each virtual device. Please note the process button may differ if you have modified the standard virtual device. local defREMvd = "hall" -- Id of player vd for unloading queue The default player/zone is user to unload the TTS message when presentState = Home. This zone must be included in the overall REMplayers table and the name must match exactly. local defREMlanguage = "en-gb" The final item in this section is the language or voice code for the respective TTS service DEFAULT TITLES AND SUBTITLES This scene has default titles and subtitles and these are used if no title or subtitle is included in the message invocation. local defTitle = "Alert Title" local defSubtitle = "Alert Subtitle" Adjust the default titles and subtitles as you require. Note: Subtitles are only used for PopUp Notifications NOTIFICATION SERVICES There is a broad range of notification services available to use. Some are native to the home center and others are third party services provided by external vendors. local defmessageSvc = "pushover" Select the default notification service that you wish to use. This default service will be used if no service is invoked in the message and is also used as the service to unload the queued messages when presentState = Home PUSHOVER CONFIGURATION This service is provided by pushover.org. You will need to register with them and obtain a token and user key. local POtkn = "" local POusr = "" Once registered you will need to select the devices that you wish to send the pushover notifications to. Once they are added to your pushover account you will need to add their details below. Currently there is only one setting for device which means that all messages to pushover will be send to the devices named in this list. Priority can be set at ) like I have below local POdevice = "Dad_Ph, Kit_iPad, Landing iPad" local POpriority = "0" TELEGRAM CONFIGURATION This service is provided by telegram.org. You will need to register with them and obtain a token and a chat ID local TGtoken = "" local TGchatID = "" DEBUG VERBOSITY OPTIONS This allows a number of levels of debug verbosity. There is a minimal amount of debug window responses running in normal mode but these two capabilities allow the user to observe extra information in the debug window when the scene is running. local deBugVar = true -- deBugVar will display the scene variables local deBugCfg = false -- deBugCfg will display the scene configaution that you have set OCCUPANCY/PRESENCE STATE I am also supporting the presentState as it is defined by Sankotronic and others. -- "PresentState" is predefined global value that determines if you are at home -- or away. This variable value is set by other scene or VD. Enter name of your -- global variable between "" if called different or leave as it is local presentState = "PresentState"; -- Enter corresponding values that you use for presence in your language. Change -- the one in quotes or leave as it is local presentStateMapping = {Home="Home", Away="Away"}; HOMETABLE There is also support for the hometable solution. Hometable is a approach to storing all device ID in a global variable. Please Uncomment the following line if you wish to use Hometable data in scene -- local jT = json.decode(fibaro:getGlobalValue("HomeTable")); POPUP MESSAGE TYPES Default popup message type, possible values: Success, Info, Warning, Critical. Please define popup message default popup type, button caption and buttons if you wish These defaults can be left as is or modified/translated into your own language local defPopType = "Info" local defPopCaption = "OK" local defPopButton = { { caption = defPopCaption, sceneId = 0 }} Please refer to Sankotronic Tutorial "Popup Notifications and Custom Images" for format and examples POPUP REDIRECT TITLES AND SUBTITLES Please amend the text sent to PopUp Notification when Internet or TTS is offline to your own language if you wish. Both Title and subtitle can be modified local TTSofflineTitle = "Announcement" local TTSofflineSubtitle = "TTS is offline, TTS announcement sent as popup notification" local WWWofflineSubtitle = "Internet is offline, TTS announcement sent as popup notification" SAMPLE MESSAGE INVOCATIONS The message function can be invoked with as little as one parameter or as many as five parameters. The following examples will provide a good understanding. Send message to default notification service, with default titles/subtitles fibaro:startScene(682, {message}) -- Replace 682 with id of your SMsgH v1.1 scene or a hometable reference Send message to specific notification service (The notification service must match exactly what is contained in the notifySve table in the variables section) fibaro:startScene(682, {message, target}) (The hc2user in the message invocation must match exactly what is contained in the hc2emailUsers table in the user configuration section) fibaro:startScene(682, {message, "hc2email"}) - send to superuser fibaro:startScene(682, {message, "hc2email frank"}) - send to user frank fibaro:startScene(682, {message, "hc2email frank su"}) - send to user frank and superuser (The hc2push device in the message invocation must match exactly what is contained in the hc2emailUsers table in the user configuration section) fibaro:startScene(682, {message, "hc2push DadiPhone"}) - send to superuser fibaro:startScene(682, {message, "hc2push MumiPhone SarahiPhone"}) - send to mumphone and sarah phone (The sonos player name in the message invocation must match exactly what is contained in either the APIplayers or REMplayers table in the user configuration section) The target can also specify sonos player or VD id for TTS with options fibaro:startScene(682, {message, "kitchen"}) -send TTS to kitchen, default volume fibaro:startScene(682, {message, "hallway", "10"}) -send TTS to kicthen, volume=10 Custom titles and subtitles can also be specified. These will overwrite the default titles and subtitles. Subtitles are only available for HC2 Popup notifications. They can be used with or with a target notification. If the target is omitted it will send to the default notification service that has been named in the configuration section local message = "what ever the message is" fibaro:startScene(682, {message, "", "", "Alert !!", "The wine fridge temp is rising"}) Finally an example of a Message to popup with specified popup type local message = "kitchen window has been breached" fibaro:startScene(682, {message, "hc2popup", "", "Alarm", "House Breach", "Critical"}) MESSAGE WITH INTERNATIONAL CHARACTERS If you want to send message with special characters just use urlencode function: fibaro:startScene(682, {"message", "hc2email", "", "title"}) -- without special chars fibaro:startScene(682, {urlencode("message ąść"), "hc2email", "", "title"}) -- with special chars fibaro:startScene(682, {urlencode("message ąść"), "hc2email", "", urlencode("title ČčĆ抚ĐđŽžáäéè")}) -- with special chars COMPANION DEMONSTRATION VD INSTRUCTIONS (1.1) A number of sample notification and TTS messages can be activated giving the user an understanding of the message invocation format and options Demonstration mode enabled the toggling of 'Internet online/offline', presentState Home/Away, sleepState Sleep/Awake modes. This capability allows the used to observe the queuing and unloading of queued notification messages and TTS messages in action. Import the VD into your home center 2. Review the messages and adjust based on your own implementation of Smart Message Hub Send messages and TTS as required To demonstrate the queuing and unload of queue’s Set demo mode to ON. Send messages and TTS and observe in selected notification services and apps, Set internet to offline, sent messages and observe queuing, Set internet to online, observer unloading of queue. Set presetState to Away, send messages and observe queuing. Set presentState to Home and observe unloading of queue. Set sleepState to Sleep and observe TTS are silenced. For normal operation - set Demo mode to OFF FILES [Smart Message Hub SCENE] SMsgH 1.2.lua (lua file) WWWAPI Monitor Virtual Device [VIRTUAL DEVICE] WWWAPI_Monitor_1.0.vfib Companion Virtual Device [VIRTUAL DEVICE] SMsgH_Demo_1.1.vfib
  19. (I'm a n00b. Using a Home Center 2) I have a space where I want any one of three (motion) sensors to be able to switch lights on, and when not more activity has been sense for some time, switch them off. I'd like to extend it such that the lights only come on between sunset and sunrise. I have created 4x scenes, 3x Turn On, 1x Turn Off. The logic I am using is: I created a Global Variable (called LastOnTime) to track the last activation/on time. All of the motion sensors trigger a scene that turn the lights on; and set the LastOnTime to os.time() - I have three copies of that scene. I created one more scene that is triggered off a timer; then if [os.time() - LastOnTime] > 600 turn the lights off. The scripts are below. Questions I have are: is this a good way of doing it? is there a better way? the timer is not working (the scenes are not triggered). I found this 'hack' somewhere in this forum. how do I put something here to check os.time() > [sunset] ? ---------- The On scenes look like: --[[ %% properties 58 value %% weather %% events %% globals --]] local minLight = 100 local motionSensorName = 'F438944-Motion' local motionSensorId = 58 local luxSensorId = 60 fibaro:debug('Lights On - ' .. motionSensorName .. ' (' .. motionSensorId .. ')') local startSource = fibaro:getSourceTrigger() local currentTime = os.time() local deviceStatus = tonumber(fibaro:getValue(motionSensorId, "value")) local currentLux = tonumber(fibaro:getValue(luxSensorId, "value")) fibaro:debug('Device Status: ' .. deviceStatus ) fibaro:debug('currentTime: ' .. currentTime ) fibaro:debug('Lux: ' .. currentLux ) if ( (deviceStatus >= 0) and (currentLux < minLight) ) then fibaro:debug('Turn On Lights') fibaro:call(20, "turnOn") fibaro:call(24, "turnOn") fibaro:debug('Set Global Variable (LightsOnTime) to ' .. currentTime) fibaro:setGlobal("LightsOnTime", currentTime) end fibaro:debug('Complete') The Off script looks like: --[[ %% properties %% events %% globals %% time log *00:01 zoneAlights --]] local currentTime = os.time() fibaro:debug('currentTime: ' .. currentTime ) local lastOnTime = fibaro:getGlobal("LightsOnTime") fibaro:debug('lastOnTime: ' .. lastOnTime ) local delta = tonumber(currentTime) - tonumber(lastOnTime) fibaro:debug('delta: ' .. delta ) if delta > 600 then fibaro:debug('Turn Off Lights') fibaro:call(20, "turnOff") fibaro:call(24, "turnOff") end
  20. Hallo Ich habe versucht, eine verschachtelte Tabelle zu sortieren und zu drucken. Leider bekomme ich einen Tisch zurück aber mit json nicht darstellen. Ich bitte um Hilfe.
  21. Hi I have to understand the Quick app HC2 code to make the same app to HC3. This Quick App control Multiroom AMCP MR4.50-XT - 4 Zones with Itach RS232 Serial Interface. I do not understand where in the LUA Code call function like above: local ID_VD = fibaro:getSelfId() fibaro:call(ID_VD, "pressButton", "6") fibaro:sleep(600) fibaro:call(ID_VD, "pressButton", "16") fibaro:sleep(600) fibaro:call(ID_VD, "pressButton", "26") fibaro:sleep(600) fibaro:call(ID_VD, "pressButton", "36") fibaro:sleep(300) Where I need to looking for some information about this code? MULTIROOM.vfib
  22. Hi. I'm an experienced programmer, but a novice in LUA. 1. I have some qubino smart meters, and would like (of course) to read all the parameters they can provide. It seems to me that every single parameter in them get an ID in HC2. When I want one of the values, i use fibaro:getValue(63,'value'); But: For some of the parameters there are no ID's! So how can I get their values? Examples of missing parameters are 143: Reactive power total and 144: Power factor total How can I get to those? 2. Is there a way to get parameters based on the device parameter numbers? I'd like to use some function v=fibaro:getParameter(main id,parameter number); Is this possible? 3. Where can I find a list of legal parameter values to the getValue call? Helgemor
  23. Hello Forum members, I am a Newbie on Fibaro HC2 / LUA and struggling with my next project: I have a Hydrawise Irrigation Controller (sister company of Hunter). This controller is already smart and adjusting the irrigation schedule based on weather data via WUnderground. My plan is to track the status of each zone in HC2 and switch the pump (wall plug) on and off. API key is available and the connection is working on browser and in LUA code. I can run and stop specific irrigation zones via code but I do not know how to get the datastring into HC2 variables. start relay 485761 / zone 3 for 600 seconds: local http = net.HTTPClient() http:request('https://api.hydrawise.com/api/v1/setzone.php?action=run&api_key=XXXXXX&period_id=999&relay_id=485761&custom=600') stop same relay: http:request('https://api.hydrawise.com/api/v1/setzone.php?action=stop&api_key=XXXXXXX&relay_id=485761') Both is working and I can see the effect on the Hydrawise controller. code for the statusschedule: https://api.hydrawise.com/api/v1/statusschedule.php?api_key=XXXXXXXXX I receive following string in the browser: {"time":1613911956,"nextpoll":60,"message":"","simRelays":1,"options":17,"master":12,"master_timer":0,"master_post_timer":0,"expanders":[],"sensors":[{"input":0,"type":1,"mode":1,"timer":0,"offtimer":0, "relays":[{"id":485761},{"id":488979},{"id":488980},{"id":488981}]}], "relays":[{"relay_id":488979,"time":1576800000,"type":110,"run":0,"relay":1,"name":"Rasen Terrasse","period":259200,"timestr":""}, {"relay_id":488980,"time":1576800000,"type":110,"run":0,"relay":2,"name":"Beete Eingang","period":259200,"timestr":""}, {"relay_id":485761,"time":1576800000,"type":110,"run":0,"relay":3,"name":"Rasen Erker","period":259200,"timestr":""}, {"relay_id":488981,"time":1576800000,"type":110,"run":0,"relay":4,"name":"Hochbeet","period":259200,"timestr":""}] Hopefully somebody can support in this topic. Hydrawise REST API.pdf
  24. Möchte gerne, wenn ich den KeyFob Taste 1 drücke das, eine Push Nachricht geschickt wird, wenn das Garagentor offen ist. Und wenn ich wieder drücke , das eine Push Nachricht geschickt wird, wenn das Garagentor geschlossen ist. Kann mir jemand dabei helfen ? LUA ist für mich sehr neu. Vielen Dank für eure Hilfe. Trigger: { conditions = { { id = 97, isTrigger = true, operator = „==“, property = „centralSceneEvent“, type = „device“, value = { keyAttribute = „Pressed“, keyId = 1 } }, { id = 100, isTrigger = true, operator = „==“, property = „value“, type = „device“, value = true }, { id = 100, isTrigger = true, operator = „==“, property = „value“, type = „device“, value = false } }, operator = „all“ } AKTION: local Taste = json.encode(sourceTrigger.value.keyId) – Betätigte Taste local Aktion = json.encode(sourceTrigger.value.keyAttribute) – Anzahl Betätigungen if Taste == „1“ and Aktion == ‚„Pressed“‘ then fibaro.call(90, ‚toggle‘) print(„Garagentor“) end fibaro.alert(‚simplePush‘, {[1] = 98, }, 'Garagentor ist offen’false) print(„Garagentor ist offen“) end fibaro.alert(‚simplePush‘, {[1] = 98, }, ‚Garagentor ist geschlossen‘, false) print(„Garagentor ist geschlossen“) end
  25. Hello everyone, As many before on this forum I'm working on my heating system and want to convert my current single room heating plan into to a multi zone heating plan. I want to integrate my boiler into my heating plan but want to create some safety interlock that I won't fire up the boiler if all the thermostats are closed. I think this is a very important feature and often overlooked as the behavior of a thermostat is to close more and more when the thermostat is reaching it's set-point to prevent overshoot. So therefore I need to know what to position is of the valve, based on that condition i went for the TRV's of eurotronic as it stated in the manual that it is able to report it's current valve position. And it looked like everything would work correct with the fibaro template as I was able to set parameter 6 and enable the valve postion reporting. I think everything is configured correctly but i have a bit of strange behavior now in fibaro when I enable parameter 6. The setpoint value is getting overwritten with the valve position percentage: Setpoint displays: new setpoint in degree Celsius After few minutes same device is overwritten and setpoint value displays Open valve percentage (unit doesn't update and stays on degree Celsius): Enabled parameter 6. When i change setpoint and debug the info. I noticed the following behavior: Setpoint change -> Setpoint value displays setpoint -> after few minutes Setpoint value displays: valve position -> Setpoint value displays setpoint value again. Maybe I'm looking at the wrong values but here is the list of the available values: I wasn't able to locate the opening valve percentage value in this list to make a virtual device as work around.. Does someone have a solution for my problem? I would like to receive the actual setpoint and the open valve percentage on a different value/device.
×
×
  • Create New...