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'.



More search options

  • 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

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

Found 198 results

  1. 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
  2. Hi everyone, is there any way how to obtain (access) information from HC2 heating schedules in LUA scripts? I need to work with information about what temperature and when it is going to be set in some particular rooms. I can workaround this by making heating schedules sort of static and completely overpass heating panel in HC2, but that would be a bit contra productive, right? Thanks Edit: BTW my first post here, so please be gentle
  3. Several posts on this forum recommend including a check in LUA scenes to ensure that only one instance of the scene is currently running. The recommended code is similar to this: if fibaro:countScenes() > 1 then scenes = fibaro:countScenes() fibaro:debug(os.date("%d %b").." Scenes active "..scenes) fibaro:abort(); end The main panel for each scene, however, includes a parameter controlling max. running instances: Why is it necessary to include the extra code, if this parameter already limits the scene to one active instance? Is it only to get the explicit warning from the fibaro:debug() command?
  4. damo78

    Get HC User Ids

    Is there a way to get the user ids of the Home Centre, either manually through the UI or using Lua? If anybody has any pointers on how to use users in Lua that would help. At the moment I'm just trying to add them to a JSON table, but I would also like to use the user ids in code maybe. Thanks in advance.
  5. Witam, Od wczoraj zmagam się z problemami z HC2. Sceny nie uruchamiają się automatycznie. Miałem wcześniej dużo działących już scen i dopisałem wczoraj nową i przestało działać. Robiłem kilka restartów i nic. Nie widziałem, żeby firmware się aktualizował. Obecna wersja to 4.530. Jeśli odpalę sceny ręcznie to zadziałają, więc kod jest poprawny. Jakieś pomysły?
  6. 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
  7. Hi Everyone v 2.6 now available for users that have the SMsgH installed Three offerings - Please read below to see which is right for you 1) WWWAPI Monitor {v1.0} - New (Mar8th) - vd that monitors only availability of the internet with option for sonos-api device. (leverages Smart Message Hub {v1.0} 2) Network Device Monitor VD {v2.5} - vd that can monitor several + devices and has built-in alert notification options (pushover/pc2popup/hc2email/allinone) or 3) Network Device Monitor VD {v2.6} - vd that can monitor several + devices and deigned to be used with the recently released Smart Message Hub {v1.0} Regards [Autofrank] LAN Monitor / Network Device Monitor {v2.6} ------ to be used with Smart Message Hub {v 1.0} Modified to to be used with Smart Message Hub - Label check removed to simplify virtual device 4 simple steps to upgrade from v2.5 to v2.6 Import the new virtual device Configure your SendMsg preferences Copy your v2.5 jsonNetwork table to v 2.6 and set UpdateData to 'true' Set UpdateData to 'false' and that's it !! LAN Monitor / Network Device Monitor {v2.5} ------ has built in Notification Services The main difference between 2.0 and 2.5 are the following Virtual Device ONLY - ( no need for separate scene, table updates are now done through VD) Global variable table is created automatically created for new users Added HC2 Popup service as an extra notification option The following features are still available Individual LAN devices can be marked for Alert Alert Notification options configurable for HC2 email (default), pushover, or ALLINONE (@jompa68) One Alert will be received when device goes offline and another when it comes back online Online/Offline status is captured in global table that can be used to trigger other events Debug routine called vdCheck will verify that correct quantity of vd labels and format was setup Status/Error/Check feedback through the virtual device log console as visible through the Web UI I use this to monitor Internet, Unifi Security Gateway, HC2, Sonos API (pi), TV's, Sat Box, Apple TV, Droid Box, Alarm Panel, Alarm Gateway, Syn NAS Global cache device, Cameras, Tablets, Sonos players, Access points and phones. Alerts setup for Internet, USG, Sonos API, Access points, cameras, Sonos players, Alarm panel, alarm gateway and NAS. There are some nuances with some devices such as TV's and Phones. Open Ports of some devices that were shared by users Internet google (port 80) Sonos players/zone (port 1400) Sonos API (port 5005 or 5006) Raspberry Pi Hosting API (port 22) iPhone Port (port 62078) Smarter coffee maker (port 2081) Smarter iKittle (port 2081) Philips TV 47PFL5000 (port 1925) Foscam cameras (port 88) NAS Netgear U6 (port 80) Global cache GC100-12 (port 21) Humax FoxSat satellite receiver(port 80) Apple TV Gen 3 (port 5000) NPET MXQ Pro TV Box - Android 5.1 (port 7002) Sony TV’s (port 80) Samsung TV (port 8080) Synology NAs DS415Play (port 80) SPC Gateway (port 80) Siemens Alarm Panel (port 443) HKVision IP Camera (port 80) Unifi security Gateway (port 80) Unifi UniFi AC LR Access Point (port 22) Samsung Galaxy S6 / S7 (port 5060) Samsung Tablet (port 5060) Generic Android Tablets (port 5060) Airport Express and Airport Extreme (port 5009) Amazon Echo Dot and Fullsize Echo (port 4070) == INSTALLATION: Upgrading from 2.0 == - Import the LAN Monitor 2.5 VD and copy in device table from Update Network Table 2.0 - Run VD with updateData = "true" to update the Network table (default setting is false) - Run VD with updateData = "false" to operate in normal mode - Update notification and frequency of update options == INSTALLATION: First Time Users == STEP 1 - Import the LAN Monitor 2.5 virtual device - Populate the device table. Device, ip, port and enter alert = "1" for device notification - alert is user configurible per device - alert = 1 (enable alerts - alerts sent if it goes offline or comes back online ) - alert = 0 (disable alerts for this device) - Select the notification options - Run VD with updateData = "true" to populate the device table - Run VD with updateData = "false" to operate in normal mode Step 2 (optional) - create labels to display device status in VD - Create one label for each device in the global variable table, use the default ID - Label1, Label2, etc. - Enter Label Names (1, 2, 3, etc) to match order order of devices in Table (devices can be skipped but ID's must match) - Select Main label to display one device when observing through Web UI - If you want to use all labels you can use Set vdCheck = "true" to confirm correct quantity and format of labels. == FILES == Use the version if you don't have Smart Message Hub installed >> Network device Monitor VD {v2.5} ------------> LAN_Monitor_2.5.vfib Use this version if you HAVE Smart Message Hub installed >> Network Device Monitor VD {v 2.6} -----------> LAN_Monitor_2.6.vfib Thanks to @jompa68 , @petergebruers , @sonnyboy and @boerremk for their input Regards -f
  8. Witam Mam prośbę, czy mógłby mi ktoś rzucić okiem na kod pętli głównej urządzenia wirtualnego? Mianowicie chodzi o to, że urządzenie działa poprawnie, służy do sterowania klimakonwektorem, jednak nie wyświetla mi stanu poszczególnych elementów na etykietach. Co zrobiłem źle w kodzie pętli głównej? klima_salon_2(1).vfib
  9. Hi guys, is there a way to stop the ringing or cancel the call using lua or an api call? Sometimes I just walk to the door and open it. But the intercom keeps ringing. Thanks
  10. Version 20180525

    190 downloads

    20180525 (Stable) release Added/Changed: - Added some code to the mainloop to detect critical error occurring when a device is forced-removed [ERROR] line 195: attempt to perform arithmetic on a nil value
  11. I have created different scenes in the block scene editor. These are all working except for the one that should do the following: 1. When I arm the alarm, the door sensor is armed. 2. When I open the door it should give me 10 seconds before the alarm goes off. 3. If I disarm the alarm, therefore disarm the door sensor within 10 seconds the alarm should not go off. This all works fine with a minor detail: if I shut the door within 10 seconds the alarm does not go off, while it should go off unless I have disarmed the alarm. I have tried the following block scene: First I tried stating at the device that if it's armed and breached it should trigger and I put a 10 second delay at the end. That did not work. Then I tried the above method checking if the door is device is triggered while armed and breached AND if after 10 seconds the device is NOT disarmed. By the way I also tried the statement if after 10 seconds it IS armed. Both with the same result: If I close the door quickly enough, I'm inside and the alarm is not triggered. Then I thought that maybe it just does not work that well within the block scenes. So I transfered it to LUA (automatic method by Fibaro). The LUA code I get, looks horrendous though. I'm not a developer, but this does not look as very well written code to me. --[[ %% properties 200 value 200 armed %% weather %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if(startSource["type"] == "other") then fibaro:call(49, "turnOn"); fibaro:call(104, "turnOn"); fibaro:startScene(12); fibaro:call(203, "sendDefinedPushNotification", "4"); fibaro:call(207, "sendDefinedPushNotification", "4"); setTimeout(function() fibaro:call(49, "turnOff"); fibaro:call(104, "turnOff"); end, 900000) else if (( (tonumber(fibaro:getValue(200, "value")) > 0 and tonumber(fibaro:getValue(200, "armed")) > 0) ) and ( tonumber(fibaro:getValue(200, "armed")) ~= 0 )) then local delayedCheck0 = false; if ( (tonumber(fibaro:getValue(200, "value")) > 0 and tonumber(fibaro:getValue(200, "armed")) > 0) ) then delayedCheck0 = true; end setTimeout(function() local delayedCheck1 = false; local tempDeviceState1, deviceLastModification1 = fibaro:get(200, "value"); if (( tonumber(fibaro:getValue(200, "armed")) ~= 0 ) and (os.time() - deviceLastModification1) >= 10) then delayedCheck1 = true; end local startSource = fibaro:getSourceTrigger(); if ( ( delayedCheck0 == true and delayedCheck1 == true ) or startSource["type"] == "other" ) then fibaro:call(49, "turnOn"); fibaro:call(104, "turnOn"); fibaro:startScene(12); fibaro:call(203, "sendDefinedPushNotification", "4"); fibaro:call(207, "sendDefinedPushNotification", "4"); setTimeout(function() fibaro:call(49, "turnOff"); fibaro:call(104, "turnOff"); end, 900000) end end, 10000) end end So here I am, with the big question to you out there: is there anyone who has this working and what code do you have?
  12. Hello, Is it possible to read the relay state from the Heatit thermostat with LUA? i can read the setpoint, roomtemp, but not if the heating/cooling is on or off fibaro:getValue(50, "value")) >> setpoint fibaro:getValue(51, "value")) >> roomtemp I also tried a lot of the other getValue commands, like 'mode' and 'thermostatState' but nothing happens And of course i can create a scene that calculates the difference between roomtemp and setpoint, so that the relay is on if roomtemp - setpoint > diff but i like to check the real state
  13. Hi I recently figured out that my scenes with sending picture to e-mail from a ip camera not working anymore. It stops working around November 2017, I think after update to 4.150 or 4.140. Now running 4.170 on HC2 and command "sendPhotoToUser" not working. Button with camera logo on the device which used to send a snapshot to mail, also doesn't work. Has anyone else same issue? Code which should send a picture looks like this: Exactly the same code coming from block scene, when I making new scene now and converting to lua. --[[ %% properties 874 value %% weather %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if ( ( tonumber(fibaro:getValue(874, "value")) > 0 ) -- id 874 is triggering device or startSource["type"] == "other" ) then fibaro:call(648, "sendPhotoToUser", "2"); -- 648 is a camera id, 2 is a user id end Camera's settings and plugins/for cameras wasn't changed since this worked.
  14. Hi All! Is there a way to automatic create labels in VD with LUA? I want to add, or delete labels in VD depending on results of my code. For example if i have a VD displaying humidity sensor values and i add a new sensor the code should add a new label to display its value. Any ideas? Thanks in advance.
  15. 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
  16. Hi I have this function function getHueLight(id) local hueIP = 'xxx.xxx.xxx.xxx' local huePort = '80' local hueKey = '--------------------------------' local requestUrl = "http://"..hueIP..":"..huePort.."/api/"..hueKey.."/lights/"..id; local httpClient = net.HTTPClient(); httpClient:request(requestUrl, { options = { headers={}, method='GET' }, success = function (response) fibaro: debug (response. data) end, error = function (err) fibaro: debug ("Error:" .. err) end }); end and i want to assign output of this to variable i've tried somthing like this local var = getHueLight(id) but it's get nil value
  17. hallo, Ich habe mehrere MCO Home MH7 Thermostate in meiner Wohnung installiert. Nach dem Neustart des HC2 wird die Uhr der Thermostate zurückgesetzt. Die meiste Zeit ist die Uhr auf UTC-Zeit statt CET eingestellt. Nachdem sie den Support von MCO Home kontaktiert und gefragt haben, wie sie die Zeit mit LUA zurücksetzen könnten, sagten sie mir, dass sie OpenZWave-konform sind. Ich sollte innerhalb der Klasse "COMMAND_CLASS_TIME_PARAMETERS" den Befehl "TIME_PARAMETERS_SET" verwenden. Weiß jemand, wie ich ZWave-Klassen ( http://www.openzwave.com/dev/classOpenZWave_1_1TimeParameters.html ) in einem LUA-Szenario aufrufen kann ? Danke & Mit freundlichen Grüßen thomas
  18. Hi, I have an ACTRONAIR at Home with Wireless Controller. I have done extensive research to understand how the AC is controlled. It turns out that the AC wireless controller get it's instruction from a Web Service in the cloud. I have intercepted the Web Service Call and this is what get passed on to the cloud: PUT https://actron.ninja.is/rest/v0/device/ACONNECTXXXXXXXXXXXX_0_2_5?user_access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx HTTP/1.1 Accept: application/json Content-Type: application/json Referer: https://actronair.com.au/aconnect/ Accept-Language: en-AU,en;q=0.8,ar-LB;q=0.5,ar;q=0.3 Origin: https://actronair.com.au Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393 Host: actron.ninja.is Content-Length: 24 Connection: Keep-Alive {"DA":[0,1,1,0,0,0,0,0]} I need help with creating a Scene that sends instructions to the same cloud service. So far I tried the following without any sucess. Appreciate any guidance please! --[[ %% properties %% events %% globals --]] -- Callback at success local function successCallback(resp) fibaro:debug('connection success, status: ' .. resp.status) end -- Callback at error local function errorCallback(resp) fibaro:debug('connection no success, error: ' .. resp) end -- http-request Scene : senden über AutoRemote Tasker WiFi Service enabled in Tasker Action local function getDirect() local http = net.HTTPClient() payload = '"DA":[1,1,1,1,1,0,0,0]' fibaro:debug('this is the payload: ' .. payload .. '.') http:request('https://actron.ninja.is/rest/v0/device/ACONNECTXXXXXXXXXXX_0_2_4?user_access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', { options = payload, success = successCallback, error = errorCallback } ) end -- Do the request getDirect()
  19. Hi, I have a LUA programming question - for making a scene that helps HC2 heat panel control my AC via ZXT-120. My end-goal (for now) is to set the Fan speed and AC mode (heat/cool/off) by the logic in the following table (explanation below) Explanation for table: Setpoint is retrieved from Heat Panel. The deviation from setpoint is calculated from a global temp-variable subtracting setpoint to get the deviation. Based on that daviation AND the outside temperature, the AC will be set do fan speed and mode. I realize that the amount of if statements would be too big for me to handle, so someone suggested to use "switch-case" (which i am not familiar with but is sort of understood). The below example was provided for me: The problem is i still can't translate this to anything sensible in LUA. Can anyone please help me?
  20. Below is a simple LUA script to turn off most lights at night. The script (my first LUA attempt) works, but raises some basic questions: I would have liked to find the length of the array Lights_exBedrooms using the LUA function n=table.getn(ArrayName). I could not make it work. Is this function not implemented in HC2 LUA? General LUA documentation allows the construction for i,v in ipairs(ArrayName) do .. to cycle through an entire array. This does not seem to be implemented in HC2 LUA either? The script runs without delay, including the do loop turning off all lights in the list. Line 18, however, turning device 251 back on at 20 %, is delayed by about 5 seconds. Why? The idea is to define the device list as a global variable to be used in other scenes. Will adding Lights_exBedrooms{} below line 5 "%% globals" achieve that? More generally: How can something inserted between comment brackets --[[ and --]] in the header be significant to the LUA interpreter? -- "Good night" script - turns off most lights --[[ %% properties %% events %% globals --]] -- set toilet light to low before turning off (night light position, if manually switched on during night) fibaro:call(267,'setValue','20') -- Define vector of all non-bedroom light devices Lights_exBedrooms={306,304,311,305,291,286,271,366,276, 261,267,251,246,373,404,338,328,333} -- Turn off all lights except bedrooms n=18 for i=1,n do fibaro:call(Lights_exBedrooms,'turnOff') end -- Special cases fibaro:call(251,'setValue', '20') -- Hallway at 20%
  21. Is it possible the read out the set of favorite colors for RGBW modules in LUA? How? I want to cycle the favorite colors in a scene. Thanks for hints.
  22. I bought a mermaid Devolo (Zipato). I get the LEDs on, but it does not sound. According to the manual there are 7 sounds and for this use this: The device supports using SWITCH_MULTILEVEL SET to play the sound The sound ID is defined as follows: 1 or 255: Emergency sound. 2: Fire alert. 3: Ambulance sound. 4: Police car sound. 5: Door chime. 6 ~ 99: Beep Beep. 0: means stop the sound. But I do not know how to activate it. Then he has some COMMAND_CLASS ....... I do not know how I can configure them with lua. Let's see if someone can help me. Thank you. ph-pse02-Zipato-Siren-User-Manual-v1-2.pdf
  23. Fetch data from wunderground.com, send morning and afternoon forecast to your smartphone using Fibaro app, Telegram or Pushover. Data from wunderground.com can be from a PersonalWeatherStation(PWS) or nearest LocationID(LOCID) Example of forecast and pushoptions to use. 1'st value is smartphoneID, 2'nd value is morning forecast, 3'rd is afternoon forecast, 4'th is pushoption smartphoneID_and_fcst ={{281, "06:30", "17:00", "Telegram"},{320, "08:00", "17:00", "Pushover"},{32, "08:00", "17:00", "Fibaro"}} Sending as Pushover message requires an own scene that monitors Pushover variable, read about it here: http://forum.fibaro.com/index.php?/topic/17422-tutorial-pushover-lua-vd-global-function/#entry55857 All important keys like API keys, tokens etc will be saved to variable panel. Supports many languages (EN, FR, SW, PL, NL, DE, NO, RO, CZ, GR, PT, RU (default is en)) Complete lua code (save in a new scene) --[[ %% autostart %% properties %% globals --]] ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- -- HOWTO -- -- 1. Create a virtual device with 9 labels and set the ID to like below, else this scene will not work. -- 2. lblTemp, lblHum, lblBar, lblWind, lblRain, lblFcst, lblStation, lblUpdate, lblNotify -- 3. Change ID of virtual device in WU.selfId -- FIRST TIME USERS NEEDS TO COPY ALL CODE TO SCENE, after version 2.5.0 it should only be neccessary to update from "UPDATE FROM HERE" text -- NOTE -- -- Scheduled time you set for forecast push is just an indication of time. -- Real time will be the hour you set + minute of when scene starts. -- Script will check server version for new updated version (default = true) -- WU WeatherData - Fetch weather data from wunderground.com. Multilanguage support! -- Inspired by GEA(steven), stevenvd, Krikroff and many other users. -- Source - forum.fibaro.com, domotique-fibaro.fr and worldwideweb -- Special thanks to petergebruers from forum.fibaro.com with demo script -- -- -- PWS = Personal Weather Station -- LOCID = Public station -- -- -- 2014-03-22 - Permissions granted from Krikroff -- 2014-03-23 - Added rain and forecast, Added FR language. -- 2014-03-23 - Language variable changed to get the translation from wunderground.com in forcast -- 2014-03-24 - Added PL language -- 2014-03-24 - Select between PWS or LOCID to download weather data -- 2015-10-23 - New source code. -- 2015-10-23 - Added NL translation -- 2015-11-16 - Added DE, FR translation. Fixed some bug in the code(hardcoded smartphoneID,inch to metric for rain value) -- 2015-11-18 - Script moved to scene instead of mainloop in VD. VD is only used as GUI. -- 2015-11-18 - Send push if script cannot fetch data -- 2015-11-26 - adjustment of code. Function from sebcbien at domotique-fibaro.fr -- 2015-11-27 - Oops! Removed forecast push by mistace. -- 2016-02-11 - send push if new version of script is out -- 2016-03-31 - Added NO translation, did cleanup the code a little bit. -- 2016-03-31 - It is now posible to use Telegram as push. Change WU.pushOption value to Telegram or Fibaro. -- - also change WU.Telegramtoken and WU.Telegramchat_id to your values -- 2016-04-01 - Fixed bug when using Telegram push, forecast must send with lowercases. -- 2016-05-26 - Added support for multiple smartphone id when sending push -- 2016-05-30 - Implemented "UPDATE SECTION" -- 2016-07-13 - Bug fixed some code for sendPush to fibaro app -- 2016-07-14 - Telegram, possible to have forecast pushed to 2 different chat_id's -- 2016-07-15 - Save all importent values to variable. -- 2016-07-15 - Added RO, GR, PT, RU and CZ translation -- 2016-07-16 - Possible to have different time for push to all smartphones -- 2016.07-17 - Bugfixes. Changed layout of JSON table for smartphoneID, time and push option -- 2016-07-18 - Bugfixes and better error reporting. Supports Pushover (works together with -- 2016-07-19 - Bugfixes again. -- 2016-07-22 - Added seconde forcast to both morning and afternoon push message. Added parse_mode for bold telegram text message -- 2016-07-24 - Added ES (Spanish) translation -- 2016-08-03 - Bugfixes (in WU.dualChat_ID part of code) WU = {} versionCheck = true -- check if new version of script exist on server WU.language = "SW"; -- EN, FR, SW, PL, NL, DE, NO, RO, CZ, GR, PT, RU, ES (default is en) ---- UPDATE FROM HERE ---- -- WU settings if not fibaro:getGlobal("WUAPI") == nil then WU.APIkey = fibaro:getGlobal("WUAPI") else -- [CHANGE THIS IF VALUES ARE NOT STORED IN VARIABLE PANEL] WU.APIkey = "14eaffxxxxxxxxxxxxxx" --Put your WU api key here end WU.PWS = "IGVLEBOR5" -- The PWS location to get data for (Personal Weather Station) WU.LOCID = "SWXX0076" -- The location ID to get data for (City location) WU.station = "PWS" -- PWS or LOCID ---- UPDATE FROM HERE ---- version = "{V3.0.5}" -- Other settings smartphoneID_and_fcst ={{281, "06:30", "21:10", "Telegram"},{32, "08:00", "16:00", "Fibaro"}} -- ID, time for morning and afternoon forecast and what push to use WU.sendPush = true -- send forecast with push -- Telegram settings -- IMPORTANT -- -- Telegramtoken needs to splitted into 2 parts. First part1 is before the ":", part2 is after the ":" if not fibaro:getGlobal("Telegramtoken1_part1") == nil then WU.Telegramtoken1_part1 = fibaro:getGlobal("Telegramtoken1_part1") else -- [CHANGE THIS IF VALUES ARE NOT STORED IN VARIABLE PANEL] Telegramtoken needs to splitted into 2 parts. First part1 is before the ":", part2 is after the ":" WU.Telegramtoken1_part1 = "187xxxxxx" -- ******** end if not fibaro:getGlobal("Telegramtoken1_part2") == nil then WU.Telegramtoken1_part2 = fibaro:getGlobal("Telegramtoken1_part2") else -- [CHANGE THIS IF VALUES ARE NOT STORED IN VARIABLE PANEL]Telegramtoken needs to splitted into 2 parts. First part1 is before the ":", part2 is after the ":" WU.Telegramtoken1_part2 = "AAHfzhTcsKloviNxxxxxxxxxxxxxxxxx" -- ******** end if not fibaro:getGlobal("Telegramchat_id1") == nil then WU.Telegramchat_id1 = fibaro:getGlobal("Telegramchat_id1") else -- [CHANGE THIS IF VALUES ARE NOT STORED IN VARIABLE PANEL] Telegramtoken chat_id 1 WU.Telegramchat_id1 = "2025xxxxx" -- ******** end -- If you want forecast to be pushed to a second phone WU.dualChat_ID = false -- set to true if more then 1 smartphone that should have forecast pushed. if not fibaro:getGlobal("Telegramtoken2_part1") == nil then WU.Telegramtoken2_part1 = fibaro:getGlobal("Telegramtoken2_part1") else -- [CHANGE THIS IF VALUES ARE NOT STORED IN VARIABLE PANEL] Telegramtoken needs to splitted into 2 parts. First part1 is before the ":", part2 is after the ":" WU.Telegramtoken2_part1 = "187xxxxxx" end if not fibaro:getGlobal("Telegramtoken2_part2") == nil then WU.Telegramtoken2_part2 = fibaro:getGlobal("Telegramtoken2_part2") else -- [CHANGE THIS IF VALUES ARE NOT STORED IN VARIABLE PANEL] Telegramtoken needs to splitted into 2 parts. First part1 is before the ":", part2 is after the ":" WU.Telegramtoken2_part2 = "AAHfzhTcsKloviNxxxxxxxxxxxxxxxxx" -- ******** end if not fibaro:getGlobal("Telegramchat_id2") == nil then WU.Telegramchat_id2 = fibaro:getGlobal("Telegramchat_id2") else -- [CHANGE THIS IF VALUES ARE NOT STORED IN VARIABLE PANEL]Telegramtoken chat_id 2 WU.Telegramchat_id2 = "2025xxxxx" -- ******** end updateEvery = 5 -- get data every xx minutes WU.selfId = 150 -- ID of virtual device WU.translation = {true} WU.currentDate = os.date("*t"); DoNotRecheckBefore = os.time() WU.scheduler = os.time()+60*updateEvery WU.translation["EN"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Push forecast", Temperature = "Temperature", Humidity = "Humidity", Pressure = "Pressure", Wind = "Wind", Rain = "Rain", Forecast = "Forecast", Station = "Station", Fetched = "Fetched", Data_processed = "Data processed", Update_interval = "Next update will be in (min)", No_data_fetched = "No data fetched", new_version = "New version of WUWeather.lua script is out! ", script_url = "http://jonnylarsson.se/JL/", NO_STATIONID_FOUND = "No stationID found", NO_DATA_FOUND = "No data found" } WU.translation["FR"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Push prévisions", Temperature = "Température", Humidity = "Humidité", Pressure = "Pression", Wind = "Vent", Rain = "Pluie", Forecast = "Prévisions", Station = "Station", Fetched = "Reçu", Data_processed = "Données Analysées", Update_interval = "Prochaine update prévue dans (min)", No_data_fetched = "Pas de données reçues", new_version = "New version of WUWeather.lua script is out! ", script_url = "http://jonnylarsson.se/JL/", NO_STATIONID_FOUND = "StationID non trouvée", NO_DATA_FOUND = "Pas de données disponibles" } WU.translation["SW"] = { Exiting_loop_push = "Push loop avslutad", Push_forecast = "Push forecast", Temperature = "Temperatur", Humidity = "Fuktighet", Pressure = "Barometer", Wind = "Vind", Rain = "Regn", Forecast = "Prognos", Station = "Station", Fetched = "Hämtat", Data_processed = "All data processat", new_version = "New version of WUWeather.lua script is out! ", script_url = "http://jonnylarsson.se/JL/", Update_interval = "Nästa uppdatering är om (min)", No_data_fetched = "Inget data hämtat", NO_STATIONID_FOUND = "StationID ej funnet", NO_DATA_FOUND = "Ingen data hos WU" } WU.translation["PL"] = { Exiting_loop_push = "Kończę pętlę PUSH", Push_forecast = "PUSH prognozy", Temperature = "Temperatura", Humidity = "Wilgotność", Pressure = "Ciśnienie", Wind = "Wiatr", Rain = "Deszcz", Forecast = "Prognoza", Station = "Stacja", Fetched = "Nie pobrano danych", Data_processed = "Dane przetworzone", new_version = "Dostępna nowa wersja skryptu WUWeather.lua ! ", script_url = "http://jonnylarsson.se/JL/", No_data_fetched = "Brak danych", Update_interval = "Następna aktualizacja za (min)", NO_STATIONID_FOUND = "Nie znaleziono ID Stacji", NO_DATA_FOUND = "Brak danych" } WU.translation["NL"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Push verwachting", Temperature = "Temperatuur", Humidity = "Vochtigheid", Pressure = "Druk", Wind = "Wind", Rain = "Regen", Forecast = "Verwachting", Station = "Weerstation", Fetched = "Ontvangen", Data_processed = "Gegevens verwerkt", new_version = "New version of WUWeather.lua script is out! ", script_url = "http://jonnylarsson.se/JL/", Update_interval = "Volgende update in (min)", No_data_fetched = "Geen gegevens ontvangen", NO_STATIONID_FOUND = "Geen stationID gevonden", NO_DATA_FOUND = "Geen gegevens gevonden" } WU.translation["DE"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Push vorhersage", Temperature = "Temperatur", Humidity = "Luftfeuchtigkeit", Pressure = "Luftdruck", Wind = "Wind", Rain = "Regen", Forecast = "Vorhersage", Station = "Station", Fetched = "Abgerufen", Data_processed = "Daten verarbeitet", new_version = "New version of WUWeather.lua script is out! ", script_url = "http://jonnylarsson.se/JL/", No_data_fetched = "Keine Daten abgerufen", Update_interval = "Das nächste Update in (min)", NO_STATIONID_FOUND = "Keine stationID gefunden", NO_DATA_FOUND = "Keine Daten gefunden" } WU.translation["NO"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Push værmelding", Temperature = "Temperatur", Humidity = "Fuktighet", Pressure = "Barometer", Wind = "Vind", Rain = "Regn", Forecast = "Prognose", Station = "Stasjon", Fetched = "Hentet", Data_processed = "All data prosessert", Update_interval = "Neste oppdatering om (min)", No_data_fetched = "Ingen data hentet", NO_STATIONID_FOUND = "StasjonID ikke funnet", NO_DATA_FOUND = "Ingen data hos WU" } WU.translation["CZ"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Push forecast", Temperature = "Teplota", Humidity = "Vlhkost", Pressure = "(Atmosférický) Tlak", Wind = "Vítr", Rain = "Déšť ", Forecast = "Předpověď", Station = "Stanice", Fetched = "Předána", Data_processed = "Data_zpracována", Update_interval = "Časová_prodleva_mezi_aktualizacemi", No_data_fetched = "Data_nebyla_předána", NO_STATIONID_FOUND = "Stanice_nenalezena", NO_DATA_FOUND = "Data_Nenalezena" } WU.translation["RO"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Prognoza apăsare", Temperature = "Temperatura", Humidity = "Umiditate", Pressure = "Presiune", Wind = "Vant", Rain = "Ploaie", Forecast = "Prognoza", Station = "Statie", Fetched = "Preluat", Data_processed = "Datele prelucrate", Update_interval = "Urmatorul update va fi in (min)", No_data_fetched = "Nu exista date preluate", NO_STATIONID_FOUND = "Nu a fost gasit stationID ", NO_DATA_FOUND = "Datele nu au fost gasite" } WU.translation["GR"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Πρόγνωση push", Temperature = "Θερμοκρασία", Humidity = "Υγρασία", Pressure = "Πίεση", Wind = "Άνεμος", Rain = "Βροχή", Forecast = "Πρόβλεψη", Station = "Σταθμός", Fetched = "Παραλήφθηκαν", Data_processed = "Επεξεργασμένα δεδομένα", Update_interval = "Η επόμενη ενημέρωση θα γίνει σε (min)", No_data_fetched = "Δεν παραλήφθηκαν δεδομένα", NO_STATIONID_FOUND = "Δεν βρέθηκε το Station ID", NO_DATA_FOUND = "Δεν βρέθηκαν δεδομένα" } WU.translation["PT"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Previsão do impulso", Temperature = "Temperatura", Humidity = "Humidade", Pressure = "Pressão", Wind = "Vento", Rain = "Chuva", Forecast = "Previsão", Station = "Estação", Fetched = "Procurar", Data_processed = "Dados processados", Update_interval = "Próxima atualização será em (min)", No_data_fetched = "Não foram encontrados dados", NO_STATIONID_FOUND = "Não foi detetada nenhuma estação", NO_DATA_FOUND = "Não foram encontrados dados" } WU.translation["RU"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Прогноз Нажмите", Temperature = "Температура", Humidity = "Влажность", Pressure = "Давление", Wind = "Ветер", Rain = "Дождь", Forecast = "Прогноз", Station = "Станция", Fetched = "Получено", Data_processed = "Данные обработаны", Update_interval = "Следующее обновление через (мин.)", No_data_fetched = "Данные не получены", NO_STATIONID_FOUND = "Данная станция не найдена", NO_DATA_FOUND = "Данные не найдены" } WU.translation["ES"] = { Exiting_loop_push = "Exiting_loop_push", Push_forecast = "Pronóstico enviado", Temperature = "Temperatura", Humidity = "Humedad", Pressure = "Presión", Wind = "Viento", Rain = "Precipitaciones", Forecast = "Pronóstico", Station = "Estación", Fetched = "Extraído", Data_processed = "Datos procesados", Update_interval = "La próxima actualización será en (min)", No_data_fetched = "Ningún dato extraído", new_version = "Nueva versión del script WUWeather.lua disponible! ", script_url = "http://jonnylarsson.se/JL/", NO_STATIONID_FOUND = "No se ha encontrado la stationID", NO_DATA_FOUND = "Datos no encontrados" } if WU.station == "LOCID" then locationID = WU.LOCID elseif WU.station == "PWS" then locationID = WU.PWS end Debug = function ( color, message ) fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); end function log(str) if debug then fibaro:debug(str); end end function errorlog(str) fibaro:debug("<font color='red'>"..str.."</font>") end function Telegrambot(msg) -- Read settings from variable WU.Telegramtoken1 = fibaro:getGlobal("Telegramtoken1_part1")..":"..fibaro:getGlobal("Telegramtoken1_part2") WU.Telegramchat_id1 = fibaro:getGlobal("Telegramchat_id1") WU.Telegramurl1 = "https://api.telegram.org/bot"..WU.Telegramtoken1.."/sendMessage?chat_id="..WU.Telegramchat_id1.."&text=" if WU.dualChat_ID then WU.Telegramtoken2 = fibaro:getGlobal("Telegramtoken2_part1")..":"..fibaro:getGlobal("Telegramtoken2_part2") WU.Telegramchat_id2 = fibaro:getGlobal("Telegramchat_id2") WU.Telegramurl2 = "https://api.telegram.org/bot"..WU.Telegramtoken2.."/sendMessage?chat_id="..WU.Telegramchat_id2.."&text=" end -- End read settings from variable local selfhttp = net.HTTPClient({timeout=2000}) url = WU.Telegramurl1 .. msg selfhttp:request(url, { options={ headers = selfhttp.controlHeaders, data = requestBody, method = 'GET' }, success = function(status) local result = json.decode(status.data); if result.ok == true then Debug("grey", "Sucessfully sent message to Telegram Bot...") else --errorlog("failed"); print(status.data); end end, error = function(error) --errorlog("ERROR") Debug("red", error) end }) if WU.dualChat_ID then url2 = WU.Telegramurl2 .. msg selfhttp:request(url2, { options={ headers = selfhttp.controlHeaders, data = requestBody, method = 'GET' }, success = function(status) local result = json.decode(status.data); if result.ok == true then Debug("grey", "Sucessfully sent message to Telegram Bot...") else --errorlog("failed"); print(status.data); end end, error = function(error) --errorlog("ERROR") Debug("red", error) end }) end end function versionChecker() local function getMethod(requestUrl, successCallback, errorCallback) local http = net.HTTPClient() http:request(requestUrl, { options = { method = 'GET', headers = { }, }, success = successCallback, error = errorCallback }) end content = "WUWeather.lua" local url = 'http://jonnylarsson.se/JL/'..content getMethod(url, function(resp) s = resp.data serverVersion = string.match(s, "{V(.-)}"); scriptVersion = string.match(version, "{V(.-)}"); if serverVersion > scriptVersion then Debug("grey", "Checking script version...") Debug("yellow", "There is a new version out! "..'<a href="http://jonnylarsson.se/JL/WUWeather.lua" target="_blank" style="display:inline;color:Cyan">Get it!</a>') if WU.sendPush then for k,smartphoneID_and_fcst in ipairs(smartphoneID_and_fcst) do if smartphoneID_and_fcst[4] == "Fibaro" then fibaro:call(smartphoneID_and_fcst[1] , "sendPush", WU.translation[WU.language]["new_version"].." "..WU.translation[WU.language]["script_url"]) elseif smartphoneID_and_fcst[4] == "Telegram" then Telegrambot(WU.translation[WU.language]["new_version"].." "..WU.translation[WU.language]["script_url"]) end end end end end, function(err) print('error' .. err) end ) end local http = net.HTTPClient() local function errorWU(err) if WU.pushOption == "Fibaro" then fibaro:call(WU.smartphoneID , "sendPush", "[WUWeather scene]. Error: "..err ) elseif WU.pushOption == "Telegram" then Telegrambot("[WUWeather scene]. Error: "..err ) end Debug( "red", "[HTTPClient:request]. Error: "..err ); end local function sendPopup() -- variable containing path of Motion Sensor’s icon local imgUrl = popupIMG -- pop-up call HomeCenter.PopupService.publish({ -- title (required) title = 'Weather forecast', -- subtitle(optional), e.g. time and date of the pop-up call subtitle = os.date("%I:%M:%S %p | %B %d, %Y"), -- content header (optional) contentTitle = 'Forecast from WU Weather', -- content (required) contentBody = fcastday.." - "..fcast, -- notification image (assigned from the variable) img = imgUrl, -- type of the pop-up type = 'Info', }) end function createGlobalIfNotExists(varName, defaultValue) if (fibaro:getGlobal(varName) == nil) then Debug("cyan", "Creating the variable: "..varName.." with value: "..defaultValue) newVar = {} newVar.name = varName newVar.value = defaultValue local http = net.HTTPClient() http:request("http://127.0.0.1:11111/api/globalVariables", { options = { method = 'POST', data = json.encode(newVar)}}) end end local function processWU(response) http:request("http://api.wunderground.com/api/"..WU.APIkey.."/conditions/forecast/lang:"..WU.language.."/q/"..WU.station..":"..locationID..".json",{ options = {method = 'GET'}, success = processWU, error = errorWU }) Debug( "green", "Now downloading data from www.wunderground.com"); if response then -- the first time you enter the loop, this will be nil jsonTable = json.decode(response.data) if jsonTable.response.error ~= nil then Debug( "red", jsonTable.response.error.description) else jsonTable = json.decode(response.data) WU.now = os.date("%H:%M") stationID = jsonTable.current_observation.station_id city = jsonTable.current_observation.observation_location.city humidity = jsonTable.current_observation.relative_humidity temperature = jsonTable.current_observation.temp_c pression = jsonTable.current_observation.pressure_mb wind = jsonTable.current_observation.wind_kph rain = jsonTable.current_observation.precip_today_metric icon = jsonTable.current_observation.icon weathericon = jsonTable.current_observation.icon_url fcstday1 = jsonTable.forecast.txt_forecast.forecastday[1].title fcst1 = jsonTable.forecast.txt_forecast.forecastday[1].fcttext_metric fcst1icon = jsonTable.forecast.txt_forecast.forecastday[1].icon_url fcstday2 = jsonTable.forecast.txt_forecast.forecastday[2].title fcst2 = jsonTable.forecast.txt_forecast.forecastday[2].fcttext_metric fcst2icon = jsonTable.forecast.txt_forecast.forecastday[2].icon_url fcstday3 = jsonTable.forecast.txt_forecast.forecastday[3].title fcst3 = jsonTable.forecast.txt_forecast.forecastday[3].fcttext_metric fcst3icon = jsonTable.forecast.txt_forecast.forecastday[3].icon_url fcst1_mobile = jsonTable.forecast.simpleforecast.forecastday[1].conditions fcst2_mobile = jsonTable.forecast.simpleforecast.forecastday[2].conditions if (stationID ~= nil) then fibaro:call(WU.selfId , "setProperty", "ui.lblStation.value", locationID); fibaro:call(WU.selfId , "setProperty", "ui.lblCity.value", city); fibaro:call(WU.selfId , "setProperty", "ui.lblTemp.value", WU.translation[WU.language]["Temperature"].." "..temperature.." °C"); fibaro:call(WU.selfId , "setProperty", "ui.lblHum.value", WU.translation[WU.language]["Humidity"].." "..humidity); fibaro:call(WU.selfId , "setProperty", "ui.lblBar.value", WU.translation[WU.language]["Pressure"].." "..pression.." mb"); fibaro:call(WU.selfId , "setProperty", "ui.lblWind.value", WU.translation[WU.language]["Wind"].." "..wind.." km/h"); fibaro:call(WU.selfId , "setProperty", "ui.lblRain.value", WU.translation[WU.language]["Rain"].." "..rain.." mm"); if (WU.now >= "03:00" and WU.now <= "15:59") then fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value",WU.translation[WU.language]["Forecast"].." "..fcstday1.." - "..fcst1_mobile); --fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value","<img src=http://jonnylarsson.se/JL/png/"..icon..".png>"); elseif (WU.now >= "16:00" and WU.now <= "23:59") then --fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value","<img src=http://jonnylarsson.se/JL/png/nt_"..icon..".png>"); fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value", WU.translation[WU.language]["Forecast"].." "..fcstday2.." - "..fcst2_mobile); end if WU.sendPush then for k,smartphoneID_and_fcst in ipairs(smartphoneID_and_fcst) do if (os.date("%H:%M") == smartphoneID_and_fcst[2]) then if versionCheck then versionChecker() end if smartphoneID_and_fcst[4] == "Fibaro" then fcastday = fcstday1 fcast = fcst1 fibaro:call(smartphoneID_and_fcst[1], "sendPush", fcstday1.." - "..fcst1) popupIMG = "http://jonnylarsson.se/JL/png/"..icon..".png" sendPopup() Debug("grey", "Sucessfully sent push message to "..smartphoneID_and_fcst[1]) elseif smartphoneID_and_fcst[4] == "Telegram" then Telegrambot(fcstday1.."%0A"..string.lower(fcst1).."%0A"..fcst1icon.."%0A".."%0A"..fcstday2.."%0A"..string.lower(fcst2)) elseif smartphoneID_and_fcst[4] == "Pushover" then fibaro:setGlobal("pushoverBody", fcstday1.." - "..string.lower(fcst1).." - "..fcst1icon) end end end for k,smartphoneID_and_fcst in ipairs(smartphoneID_and_fcst) do if (os.date("%H:%M") == smartphoneID_and_fcst[3]) then if smartphoneID_and_fcst[4] == "Fibaro" then fcastday = fcstday2 fcast = fcst2 fibaro:call(smartphoneID_and_fcst[1] , "sendPush", fcstday2.."\n"..string.lower(fcst2).."\n"..fcst2icon.."\n".."\n"..fcstday3.."\n"..string.lower(fcst3)) popupIMG = "http://jonnylarsson.se/JL/png/nt_"..icon..".png" sendPopup() Debug("grey", "Sucessfully sent push message to "..smartphoneID_and_fcst[1]) elseif smartphoneID_and_fcst[4] == "Telegram" then Telegrambot(fcstday2.."%0A"..string.lower(fcst2).."%0A"..fcst2icon.."%0A".."%0A"..fcstday3.."%0A"..string.lower(fcst3)) elseif smartphoneID_and_fcst[4] == "Pushover" then fibaro:setGlobal("pushoverBody", fcstday2.."\n"..string.lower(fcst2).."\n"..fcst2icon.."\n".."\n"..fcstday3.."\n"..string.lower(fcst3)) end end end end if WU.sendPush then fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value", WU.translation[WU.language]["Push_forecast"].." = true"); else fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value",WU.translation[WU.language]["Push_forecast"].." = false"); end WU.scheduler = os.time()+updateEvery*60 fibaro:call(WU.selfId, "setProperty", "ui.lblUpdate.value", os.date("%c")); fibaro:debug(WU.translation[WU.language]["Data_processed"]) fibaro:debug(WU.translation[WU.language]["Update_interval"].." "..updateEvery) else fibaro:debug(WU.translation[WU.language]["NO_STATIONID_FOUND"]) end end sleepAndcheck = 0 while sleepAndcheck <= 20*updateEvery do fibaro:sleep(3000) sleepAndcheck = sleepAndcheck+1 for k,smartphoneID_and_fcst in ipairs(smartphoneID_and_fcst) do if (DoNotRecheckBefore <= os.time()) and ((WU.scheduler == os.time) or (os.date("%H:%M") == smartphoneID_and_fcst[2]) or (os.date("%H:%M") == smartphoneID_and_fcst[3])) then fibaro:debug(WU.translation[WU.language]["Push_forecast"]) Debug("orange", WU.translation[WU.language]["Exiting_loop_push"]); DoNotRecheckBefore = os.time()+60 sleepAndcheck = 20*updateEvery end end end end end Debug( "orange", "WU Weather - LUA Scripting by Jonny Larsson 2015/2016" ); Debug( "orange", "Version: "..version); if versionCheck then versionChecker() end createGlobalIfNotExists("WUAPI", WU.APIkey) createGlobalIfNotExists("Telegramtoken1_part1", WU.Telegramtoken1_part1) createGlobalIfNotExists("Telegramtoken1_part2", WU.Telegramtoken1_part2) createGlobalIfNotExists("Telegramchat_id1", WU.Telegramchat_id1) if WU.dualChat_ID then createGlobalIfNotExists("Telegramtoken2_part1", WU.Telegramtoken2_part1) createGlobalIfNotExists("Telegramtoken2_part2", WU.Telegramtoken2_part2) createGlobalIfNotExists("Telegramchat_id2", WU.Telegramchat_id2) end for k,smartphoneID_and_fcst in ipairs(smartphoneID_and_fcst) do Debug( "yellow", "Morning forecast push will be for ID: "..smartphoneID_and_fcst[1].." @ "..smartphoneID_and_fcst[2].." with "..smartphoneID_and_fcst[4]); Debug( "yellow", "Afternoon forecast push will be for ID: "..smartphoneID_and_fcst[1].." @ "..smartphoneID_and_fcst[3].." with "..smartphoneID_and_fcst[4]); end processWU() --this starts an endless loop, until an error occurs ---- END OF UPDATE ----
  24. Has anyone found a simple solution to play internet radio stations from like Tunein? if so can you share your VD. thanks
  25. Dear forum readers. I have a virtual device where I wanted to read the XML values from. i know that it is not possible to use external libs to read the XML. the device wich I wanted to control has a status page which in XML format is. I wanted that my virtual device can read the location ID and from each location id the Preset and the name and at last the type of "room" I use Lua for the virtual device. hope that someone can help me out with this This XML file does not appear to have any style information associated with it. The document tree is shown below. <locations> <location id="eec0c0b41b4c43119d33e2bdafe1fc08"> <name>Woonkamer</name> <description/> <type>livingroom</type> <created_date>2019-01-30T17:06:14.387+01:00</created_date> <modified_date>2019-02-13T14:12:37.667+01:00</modified_date> <deleted_date/> <preset>away</preset> <clients/> <appliances> <appliance id="0ae80e58c6354c0ab69dc9f512f73bd0"/> <appliance id="b9cd5290b2c840d6a2cb1e7629987020"/> </appliances> <logs> <point_log id="9b603d2e231e466b83aad0bbe1e3df87"> <updated_date>2019-02-13T14:12:12.637+01:00</updated_date> <type>thermostat</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T13:28:58.345+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:12.637+01:00" end_date="2019-02-13T14:12:12.637+01:00"> <measurement log_date="2019-02-13T14:12:12.637+01:00">15.00</measurement> </period> </point_log> <point_log id="b42775ccb8a34300b89e2783a12d377c"> <updated_date>2019-02-13T14:12:37.627+01:00</updated_date> <type>temperature</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T15:32:18.644+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:37.627+01:00" end_date="2019-02-13T14:12:37.627+01:00"> <measurement log_date="2019-02-13T14:12:37.627+01:00">27.60</measurement> </period> </point_log> </logs> <actuator_functionalities> <thermostat_functionality id="a214798f9ce448b3975d52f0e5b39ed3"> <updated_date>2019-02-13T14:12:12.638+01:00</updated_date> <type>thermostat</type> <setpoint>15</setpoint> <lower_bound>0</lower_bound> <upper_bound>99.99</upper_bound> <resolution>0.01</resolution> <regulations> <open_therm_regulation id="c843041e028c40c7972a37186db7d292"/> </regulations> </thermostat_functionality> </actuator_functionalities> </location> <location id="c2763300e52545c4b702214d842397cd"> <name>Home</name> <description/> <type>building</type> <created_date>2019-01-30T16:31:22.406+01:00</created_date> <modified_date>2019-02-13T14:00:34.694+01:00</modified_date> <deleted_date/> <preset>home</preset> <clients/> <appliances/> <logs> <point_log id="4cdaf2b988d449adb9bcbde2173fabac"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>outdoor_temperature</type> <unit>C</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">6.31</measurement> </period> <thermo_meter id="2874c255abe74e119ce7ae18f28f1620"/> </point_log> <point_log id="6ff4a2747be5466999362dde2ab4de6c"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>wind_vector</type> <unit>m_s</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">(5.10,220.00)</measurement> </period> <wind_vector id="e3b37ca9d9bc4a9c8aa792996c9631f7"/> </point_log> <point_log id="9fedd3ce56544d9cb3ba8741d586195b"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>solar_irradiance</type> <unit>W_m2</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">267.19</measurement> </period> <irradiance_meter id="9f2e62dac6274336abbee38c3f30ae55"/> </point_log> <point_log id="a2b370beeb0340dea1bb4dd76ef4fc69"> <updated_date>2019-02-13T13:20:00+01:00</updated_date> <type>humidity</type> <unit>RH</unit> <last_consecutive_log_date>2019-02-13T13:20:00+01:00</last_consecutive_log_date> <period start_date="2019-02-13T13:20:00+01:00" end_date="2019-02-13T13:20:00+01:00"> <measurement log_date="2019-02-13T13:20:00+01:00">75.00</measurement> </period> <hygro_meter id="7f96900dfb2e47309660a1614e7acc2d"/> </point_log> </logs> <actuator_functionalities/> </location> <location id="9cc6fd06c60c4199b1bd9e97267ee274"> <name>kelder</name> <description/> <type>cellar</type> <created_date>2019-01-31T08:59:18.287+01:00</created_date> <modified_date>2019-02-13T14:12:18.391+01:00</modified_date> <deleted_date/> <preset>away</preset> <clients/> <appliances> <appliance id="6b7d7b6082a54ad7914fac36d268ffd7"/> <appliance id="cee97024adb94776ba6aecddb6ea62d7"/> </appliances> <logs> <point_log id="5b479e2315b84ea3a1b36b9afed23eeb"> <updated_date>2019-02-13T14:12:18.375+01:00</updated_date> <type>temperature</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T15:32:38.107+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:18.375+01:00" end_date="2019-02-13T14:12:18.375+01:00"> <measurement log_date="2019-02-13T14:12:18.375+01:00">24.00</measurement> </period> </point_log> <point_log id="e7787444f4ef461d856a23aa405f3aab"> <updated_date>2019-02-13T14:12:12.765+01:00</updated_date> <type>thermostat</type> <unit>C</unit> <last_consecutive_log_date>2019-01-31T14:45:00.766+01:00</last_consecutive_log_date> <period start_date="2019-02-13T14:12:12.765+01:00" end_date="2019-02-13T14:12:12.765+01:00"> <measurement log_date="2019-02-13T14:12:12.765+01:00">15.00</measurement> </period> </point_log> </logs> <actuator_functionalities> <thermostat_functionality id="9c1f952c1cdc470bb72716858b004bf5"> <updated_date>2019-02-13T14:12:12.766+01:00</updated_date> <type>thermostat</type> <setpoint>15</setpoint> <lower_bound>0</lower_bound> <upper_bound>99.99</upper_bound> <resolution>0.01</resolution> <regulations> <open_therm_regulation id="c843041e028c40c7972a37186db7d292"/> </regulations> </thermostat_functionality> </actuator_functionalities> </location> </locations>
×
×
  • Create New...