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

  • 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. All, I was wondering if someone has any experience with the Honeywell Lyric T6 Thermostat and "integration" with the Fibaro HC2 ? Looks like a great (simple) device from a "respected" Corporation and has, as far as I see, great potential to be integrated with Fibaro (VD and Senes).
  2. Good evening, I'm stuck trying to read the status of a device and use it on a local website. (I want to have a tablet with a continuously refreshing page displaying the status of some devices.) When i use this line in a browser: http://username:[email protected]//api/devices/5 i get the following json response from the HC2 {"id":5,"name":"Kerst Takken","roomID":4,"type":"com.fibaro.binarySwitch","baseType":"com.fibaro.actor","enabled":true,"visible":true,"isPlugin":false,"parentId":4,"remoteGatewayId":0,"interfaces":["deviceGrouping","light","zwave","zwaveConfiguration","zwaveSwitchAll"],"properties":{"parameters":[],"pollingTimeSec":0,"zwaveCompany":"TKB Home","zwaveInfo":"6,3,40","zwaveVersion":"1.4","configured":"true","dead":"false","deviceControlType":"2","deviceGroup":"[]","deviceGroupMaster":"0","deviceIcon":"2","emailNotificationID":"0","emailNotificationType":"0","endPointId":"0","isLight":"true","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"2","parametersTemplate":"201","productInfo":"1,24,1,1,1,3,1,4","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","serialNumber":"","smsNotificationID":"0","smsNotificationType":"0","switchAllMode":"SWITCH_ALL_INCLUDED_IN_THE_ALL_ON_ALL_OFF_FUNCTIONALITY","useTemplate":"true","userDescription":"","value":"true"},"actions":{"getParameter":1,"reconfigure":0,"setParameter":2,"turnOff":0,"turnOn":0},"created":1487237572,"modified":1487237572,"sortOrder":11} ID=5 and properties.value=true so device 5 is switched on. If i save this in a text file as jsondata.txt and use the following example code i found on the net and modified: <html> <head> <title>The jQuery Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { $("#driver").click(function(event){ $.getJSON('jsondata.txt', function(jd) { $('#stage').html('<p> id: ' + jd.id + '</p>'); $('#stage').append('<p>Value : ' + jd.properties.value+ '</p>'); }); }); }); </script> </head> <body> <p>Click on the button to load result.html file:</p> <div id = "stage" style = "background-color:#cc0;"> STAGE </div> <input type = "button" id = "driver" value = "Load Data" /> </body> </html> i get the following response: id: 5 Value : true and that is exactly what i want, only i want it with the http api call. so i changed the "$.getjson" line in: $.getJSON('http://user:[email protected]//api/devices/5', function(jd) { But that does not give any response. So the http request is correct, ( i get the right json response direct from the url in the browser) and the script is correct, ( i get the right response using the textfile) the php file and the jsondata.txt are on a webserver are and accessed from a laptop. What am i missing ? Mike.
  3. Hej, Czy komuś z Was może udało się przy pomocy urządzenia wirtualnego (HCL - bez LUA) zawołać akcje na jakimś urządzeniu wykorzystując REST API? Pogrzebałem na forum, ale nic z podanych rozwiązań nie działa...
  4. Hi, I am looking for help in decode a http success message If I issue the following through a browser it works.... http://192.168.1.89:5005/bed5_office/say/Hello/Amy/30 and the response in the browser is {"status":"success"} now, if I run this in a scene http = net.HTTPClient({ timeout = 3000 }) url = 'http://192.168.1.89:5005/bed5_office/say/Hello/Amy/30' controlHeaders = {['content-type'] = 'application/json; charset=utf-8'} http:request(url, { options = { headers = controlHeaders, method = 'GET', }, success = function(param) if param.status == 200 then print('Success STATUS: ', param.status) print('Param Data: ', param.data) else print('STATUS: ', param.status) end end, }) It also works but I cannot find way to display the success message ( I want to trigger another action if not successful) I tried removing the " ==200 " if-then loop as I can't see any 200 or 201 result. Could somebody explain what the success = function(param) is doing and I may be able to figure out why I may not be seeing the success message Thanks -f
  5. 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
  6. Has anyone ever found a alarm clock on their phone which actually syncs it to the cloud so that you can read from an api? The thing is, i never know when i need to wake up, and my gf has shifts too. If you want to turn on the heat based on when the alarm clock goes off, you need a way to get the current alarms from a phone. It would greatly help with all those "make me coffee" idea's too in the morning. Just set your alarm and the rest of the house will follow.
  7. Hi, Here is my working Volvo interface. Most things you can do with your Volvo On Call app, you can also read out and do with the following Scene + VD. To start off, it is using the jT.hometable so if you don't use that, start using that or strip it away in the Scene/VD. You need to add a entry in your jT.hometable called 'volvo' an example looks like this (yes all here is dummy data and also the 'time' one) volvo = { sceneid = 14, lua = 512, vin = 'YOURVINNUMBER', auth = 'Basic dsjkh42euwendeh279eynhsfd8o3yg7bo3redgefdhf' } And add this line because it uses it to run every xx minutes, add this to your homeTable too. time = { minute = 59000 , five = 299000 , ten = 599000 } Sceneid will be the number of the scene you will create, the 'YOURVINNUMBER' you can get by going into the technical information in your app (usually settings, then technical information, it will be at the bottom) Your basic auth is just a username:password which is base64 encoded. To keep it simple and also have a nice tool to test out api's, i suggest you install Postman. You can add your credentials here: Then click on update request and find your basic auth line here: Next up create your scene: --[[ %% autostart %% properties %% globals volvoTable --]] local jT = json.decode(fibaro:getGlobalValue("HomeTable")) local volvotrigger = tostring(fibaro:getGlobalValue("volvoTable")); local vapi = '/customerapi/rest/v3.0/vehicles/' local shortUrl = 'https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/' .. jT.volvo.vin local trigger = fibaro:getSourceTrigger() if (trigger['type'] == 'global') then controlUrl = shortUrl .. "" .. volvotrigger httpmethod = 'POST' else controlUrl = shortUrl .. "/status" httpmethod = 'GET' end local httpClient = net.HTTPClient({timeout=5000}) httpClient:request(controlUrl, { options = { method = httpmethod, headers = { ['Content-Type'] = 'application/json; charset=UTF-8', ['Authorization'] = jT.volvo.auth, ['User-Agent'] = 'Dalvik/2.1.0 (Linux; U; Android 5.1.1; SM-G925F Build/LME47X)', ['X-Device-Id'] = 'b7d2fb2e39436fe', ['X-OS-Type'] = 'Android', ['X-Originator-Type'] = 'app' } }, success = function(status) if (trigger['type'] ~= 'global') then local result = json.decode(status.data) if result then -- print("successful") -- print(status.data) if result.carLocked then fibaro:call(jT.volvo.lua, "setProperty", "ui.Label1.value", "Yes"); else fibaro:call(jT.volvo.lua, "setProperty", "ui.Label1.value", "No"); end fibaro:call(jT.volvo.lua, "setProperty", "ui.Label2.value", result.distanceToEmpty); fibaro:call(jT.volvo.lua, "setProperty", "ui.Label3.value", result.heater.status); fibaro:call(jT.volvo.lua, "setProperty", "ui.Label4.value", result.serviceWarningStatus); print(result.serviceWarningStatus) end else print(status.data) -- failed end end, error = function(error) --errorlog("ERROR") print(error) end }) As you might have noticed it also uses a GlobalVar called "volvoTable" you need to make this one too. You can leave the value empty for now. Now install the VD (yes remember the ID to fill it in the jT table) Volvo_V40.vfib And then make it fancy with a nice picture for the scene: And one for the lua. And if all goes well, you can see this one: There is more you can do, but for now i think this is sufficient. I own a V40 hence why it says that. Some cars don't have preheating or have other features (but these are most common) If it doesn't work, let me know since this is my first 'bigger' scene & vd scripts in lua. It uses the global var to send over the url it needs to post to the api, while status commands are get commands for example. Have fun (this really should be just a proper plugin)
  8. There was a topic on link Asterisk PBX and HC2 to have telephone caller ID passed to HC2 : The global variables were passed to HC2 via API call as : $url = "http://". $username . ":" . $password . "@" . $HC2serverIP . "/api/globalVariables/" . $variable; where $password = "password" // password for HC2 $username = "username" // username for HC2 $HC2serverIP = "123.123.123.123" // IP of HC2 when we had HC2 username as single word it was working fine, but now when we were forced to convert our username to e-mail address we have special character '@' in the username. The special character '@' of the username is passed to HC2 as '%40' so instead the username of the form "[email protected]" we have "user%40mail.com" and of course we are not authorized by HC2 and our variables are not updated. Any advise how to deal with this to have the global variable updated remotely via API call ?
  9. Hi, My PV panel install from MasterVolt has a MQTT API Details here - IntelliWeb MQTT API spec does anybody know if it is possible access data from this api using vd or scene ? Thanks f
  10. Hi folks. After some time, I have been looking for a (good) solution to track phones (iPhone) and its position. Existing solutions have not worked satisfactorily. So here's my solution. Still under construction but should work. The method relies on to get the coordinates from iCloud (Find My iPhone). I run the script on my local server. If someone wants to be involved and contribute (there are instructions for getting started) https://github.com/raess1/iCloud-HC2-Bridge In the latest version on Github, I have also added 1. Battery status 2. State whether the phone is loaded or not. 3. Timestamp of when the data was last fetched. Things that should be added: create a variable to print the address on the coordinates where the phone is located. And to convert the timestamp to a more reader-friendly. Merry Christmas
  11. HI, Is it possible to create a variable (specifically a predefined variable) As part of creating a VD I want to create the variable on the fly I looked at the developer documentation but couldn't find anything Is this possible ? Thanks -f
  12. Hello Everyone, Today I was notified that LightwaveRF has publicly released a new API document. Hopefully, this will spawn a new raft of Virtual Devices that control LightwaveRF products as, if you live in the UK, you find this platform just works without major headaches and beta upgrades. The link is below: https://api.lightwaverf.com/introduction_basic_comms.html
  13. Hello, I'm using a HC2 in my holiday home and would like to read-out some system-information by a API-call (for example /api/devices). The problem is that I can’t “reach” the HC locally by VPN or Port forwarding. Is ‘t possible to create a LUA-scene to ‘catch’ the API-json-output and send it by email and if so, are there any examples of this kind of LUA-scripts? With kind regards, John Claassens
  14. Any news for the netatmo API change on end of this month ? It this version compatible with the new API ?
  15. Hi, I'm trying to test the REST API via PHP. GET is ok, I'm able to read and display each data in my application. Now I want to test the POST and PUT API. I tryed to change a device name, but nothing happens. This is my code: $dati = '{"id":197,"name":"zanna","roomID":6,"type":"com.fibaro.motionSensor","baseType":"com.fibaro.lifeDangerSensor","enabled":true,"visible":true,"isPlugin":false,"parentId":195,"remoteGatewayId":0,"interfaces":["fibaroAlarm","fibaroAlarmArm","fibaroBreach","tamper","zwave","zwaveSceneActivation"],"properties":{"parameters":[{"id":1,"lastReportedValue":0,"lastSetValue":0,"size":2,"value":0},{"id":2,"lastReportedValue":0,"lastSetValue":0,"size":2,"value":0},{"id":3,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":4,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":5,"lastReportedValue":255,"lastSetValue":255,"size":1,"value":255},{"id":6,"lastReportedValue":255,"lastSetValue":255,"size":1,"value":255},{"id":7,"lastReportedValue":255,"lastSetValue":255,"size":1,"value":255},{"id":8,"lastReportedValue":255,"lastSetValue":255,"size":1,"value":255},{"id":9,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":10,"lastReportedValue":20,"lastSetValue":20,"size":1,"value":20},{"id":11,"lastReportedValue":200,"lastSetValue":200,"size":1,"value":200},{"id":12,"lastReportedValue":8,"lastSetValue":8,"size":1,"value":8},{"id":13,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0},{"id":14,"lastReportedValue":0,"lastSetValue":0,"size":1,"value":0}],"zwaveCompany":"Fibargroup","zwaveInfo":"3,3,52","zwaveVersion":"2.1","pollingTimeSec":0,"alarmDelay":"0","alarmExclude":"false","alarmTimeTimestamp":"0","armConditions":"{}","armConfig":"0","armDelay":"0","armError":"{}","armTimeTimestamp":"0","armed":"false","configured":"true","dead":"false","deviceControlType":"0","deviceIcon":"21","emailNotificationID":"0","emailNotificationType":"0","endPointId":"1","fibaroAlarm":"false","lastBreached":"1479350609","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"38","parametersTemplate":"85","productInfo":"1,15,5,1,16,2,2,1","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","sceneActivation":"0","serialNumber":"","smsNotificationID":"0","smsNotificationType":"0","tamper":"false","useTemplate":"true","userDescription":"","value":"false"},"actions":{"forceArm":0,"meetArmConditions":0,"reconfigure":0,"sceneActivationSet":0,"setArmed":1},"created":1478196735,"modified":1478196735,"sortOrder":112}'; $stringa_dati = json_encode($dati); // Get cURL resource $curl = curl_init(); // Set some options - we are passing in a useragent too here curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $stringa_dati, CURLOPT_HTTPHEADER => array('Content-Type: application/json','Content-Length: ' . strlen($stringa_dati)), CURLOPT_URL => $ZanGeneric->domotica_hc2_api . '/devices/197', CURLOPT_TIMEOUT => 5, CURLOPT_USERAGENT => 'Codular Sample cURL Request' )); // Send the request & save response to $resp $resp = curl_exec($curl); //Trasformo la stringa in un oggetto JSON $obj = json_decode($resp,true); // Close request to clear up some resources curl_close($curl); Is there someone can send an example? Thanks
  16. Hi, Hopefully this an easy one... I have a HEM ( I think its a 1, 60A 1 clamp) and I'm running 4.100 It's on the main feed into my consumer electricity panel for my house In the energy consumption panel I can see the watts and also in the device view ( watts and accumulated kwh) If I check through the API I can see the volts / Amps value but the watts and kwh are showing as 0.00 KWH/WATTS {"id":1475,"name":"House Watts","roomID":234,"type":"com.fibaro.energyMeter","baseType":"com.fibaro.meter","enabled":true,"visible":true,"isPlugin":false,"parentId":1471,"remoteGatewayId":0,"interfaces":["energy","power","zwave"],"properties":{"parameters":[{"id":3,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":5,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":6,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":7,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":9,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":10,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":11,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":101,"lastReportedValue":14,"lastSetValue":14,"size":4,"value":14},{"id":102,"lastReportedValue":590080,"lastSetValue":590080,"size":4,"value":590080},{"id":103,"lastReportedValue":2049,"lastSetValue":2049,"size":4,"value":2049},{"id":111,"lastReportedValue":-740793856,"lastSetValue":-740793856,"size":4,"value":-740793856},{"id":112,"lastReportedValue":120,"lastSetValue":120,"size":4,"value":120},{"id":113,"lastReportedValue":1800,"lastSetValue":1800,"size":4,"value":1800}],"zwaveCompany":"AEON Labs","zwaveInfo":"3,3,67","zwaveVersion":"1.19","pollingTimeSec":0,"configured":"true","dead":"false","deviceControlType":"0","deviceIcon":"102","emailNotificationID":"0","emailNotificationType":"0","endPointId":"1","energy":"1.85","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"212","parametersTemplate":"317","power":"691.92","productInfo":"0,134,0,2,0,28,1,19","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","serialNumber":"","showEnergy":"true","smsNotificationID":"0","smsNotificationType":"0","unit":"kWh","useTemplate":"true","userDescription":"","value":"0.00"},"actions":{"reconfigure":0,"reset":0},"created":1476812003,"modified":1476812003,"sortOrder":430} VOLTS {"id":1476,"name":"House Volts","roomID":234,"type":"com.fibaro.multilevelSensor","baseType":"com.fibaro.sensor","enabled":true,"visible":true,"isPlugin":false,"parentId":1471,"remoteGatewayId":0,"interfaces":["zwave"],"properties":{"parameters":[{"id":3,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":5,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":6,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":7,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":9,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":10,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":11,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":101,"lastReportedValue":14,"lastSetValue":14,"size":4,"value":14},{"id":102,"lastReportedValue":590080,"lastSetValue":590080,"size":4,"value":590080},{"id":103,"lastReportedValue":2049,"lastSetValue":2049,"size":4,"value":2049},{"id":111,"lastReportedValue":-740793856,"lastSetValue":-740793856,"size":4,"value":-740793856},{"id":112,"lastReportedValue":120,"lastSetValue":120,"size":4,"value":120},{"id":113,"lastReportedValue":1800,"lastSetValue":1800,"size":4,"value":1800}],"zwaveCompany":"AEON Labs","zwaveInfo":"3,3,67","zwaveVersion":"1.19","pollingTimeSec":0,"configured":"true","dead":"false","deviceControlType":"0","deviceIcon":"47","emailNotificationID":"0","emailNotificationType":"0","endPointId":"1","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"212","parametersTemplate":"317","productInfo":"0,134,0,2,0,28,1,19","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","serialNumber":"","smsNotificationID":"0","smsNotificationType":"0","unit":"V","useTemplate":"true","userDescription":"","value":"237.36"},"actions":{"reconfigure":0},"created":1476812003,"modified":1476812003,"sortOrder":406} AMPS {"id":1477,"name":"House Amps","roomID":234,"type":"com.fibaro.multilevelSensor","baseType":"com.fibaro.sensor","enabled":true,"visible":true,"isPlugin":false,"parentId":1471,"remoteGatewayId":0,"interfaces":["zwave"],"properties":{"parameters":[{"id":3,"lastReportedValue":1,"lastSetValue":1,"size":1,"value":1},{"id":5,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":6,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":7,"lastReportedValue":50,"lastSetValue":50,"size":2,"value":50},{"id":9,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":10,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":11,"lastReportedValue":10,"lastSetValue":10,"size":1,"value":10},{"id":101,"lastReportedValue":14,"lastSetValue":14,"size":4,"value":14},{"id":102,"lastReportedValue":590080,"lastSetValue":590080,"size":4,"value":590080},{"id":103,"lastReportedValue":2049,"lastSetValue":2049,"size":4,"value":2049},{"id":111,"lastReportedValue":-740793856,"lastSetValue":-740793856,"size":4,"value":-740793856},{"id":112,"lastReportedValue":120,"lastSetValue":120,"size":4,"value":120},{"id":113,"lastReportedValue":1800,"lastSetValue":1800,"size":4,"value":1800}],"zwaveCompany":"AEON Labs","zwaveInfo":"3,3,67","zwaveVersion":"1.19","pollingTimeSec":0,"configured":"true","dead":"false","deviceControlType":"0","deviceIcon":"47","emailNotificationID":"0","emailNotificationType":"0","endPointId":"1","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"212","parametersTemplate":"317","productInfo":"0,134,0,2,0,28,1,19","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","serialNumber":"","smsNotificationID":"0","smsNotificationType":"0","unit":"A","useTemplate":"true","userDescription":"","value":"4.28"},"actions":{"reconfigure":0},"created":1476812003,"modified":1476812003,"sortOrder":408} Does anybody know how to read the watts successfully or is there another clamp meter that works reliably with the HC2 I recently got a 2.6 kw PV array installed and I'm trying to monitor what I am using v generating any help appreciated Thanks -f
  17. When you have multiple HCLs as a slave and HC2 as a master for covering whole project, it's needed to import some devices. Sometimes imported devices in HC2 has a different value, from those in HCL. Please Fibaro, can you make additional command to REST API that represent button "Synchonize" located in "Gateway connections". It's realy pain, to make virtual device for such synchonization.
  18. Hi all, I am looking to build out my understanding of the HC2 Rest API. Specifically its capacity to execute a lot of calls (as opposed to what functions are available) and what else leverages the API and battles for capacity. I have two reasons for posting the topic - (a) I may be having an issue and am trying to debug and (b) increasing my systems knowledge. My understand is that the API is used the following... If an http request is made to the HC2 from an external system If a http request is made from a browser to the HC2 .. but is it used for ... The android app I run on my tablets/phones ( yes ? ) The iOS app running on some ipads/phones ( yes ? ) If the HC2 scene makes a http request to an external system ( assume no ? ) Does the HC2 FW itself leverage the API in anyway ( assume not ?) If a scene executes a http request to localhost / 127.0.0.1 (assume yes ?) .. what else uses it ? now if I send a lot of API calls.. What would people expect to be a resonable number before thresholds are hit (100 per second, 400 per second, 1000 per second ?) ----- assuming the are basic calls, (ie return a sensor state, true-false, return, global variable value,etc What starts to happen to system resources ? ---- Do I start to run out of memory ----- Do I see my CPU utilisation start to peak close to 100% ------ or does the system stay stable and the eveything start to slow down ? Thanks Frank
  19. Hi, All ! We are software company from Ukraine. And we are pleased to announce the release of our app for AppleTV, based on official Fibaro API: https://itunes.apple.com/app/smartiq/id1129869796?mt=8 The application is designed to easy management the devices connected to the FIBARO® System and to displaying their current status on your TV. Application requires FIBARO Home Center 2/or and FIBARO Home Center Lite. Features: - Displaying "favorite devices" state on TopShelf - Lighting/ temperature/ humidity/ security system control - Possibility to display current power consumption - Possibility to display battery status for a battery-powered devices. We'd love to hear your suggestions, comments, suggestions and ideas for further application development. Here is the 10 promo codes for free download the app. FKYEPWAALK6P YA7934PAY436 TRELNNWKJJ3J NPPM73MKT6FA MHEW46FL9J6T 4R9M97KMMNKL FKPX7FRKPJYY H47L46YY7M3T 6WPKKXJ6N9WL XPJL46WAJKJH Valeriy
  20. Morning all! Been trying to figure all the documentation all last night about Global Variables and the API. I can look at the status of a variable but no idea how to set it using the API? Does anyone know the line for setting Global Variables using the API? Thanks!!
  21. Morning all! Been trying to figure all the documentation all last night about Global Variables and the API. I can look at the status of a variable but no idea how to set it using the API? Does anyone know the line for setting Global Variables using the API? Thanks!!
  22. Implement Sonos VD using node-http-API running on raspberry PI The following should help if you want to implement an sonos VD that leverages the node sonos http api by jishi The post consists in two parts Setting up the API on a raspberry pi Creating the VD and summary of other uses of the API and some sample code I use **I'll structure this in a better format in the coming weeks but for now it should be sufficient** I have tested this with Play1, 3, 5 (older version) ZP100, ZP80, ZP90. I don’t have a sonos soundbar or sub but from reading other forums it should work fine for those I intend to use this more in ‘Press Button’ mode rather than directly as a remote control but it should be good either way. You can also select what appears in HC2 UI by clicking the ‘main’ checkbox on the appropriate VD button ( I think you can have one button, one label and one slider) Credit & Reuse: This work draws on the work of many many people from both this forum as well as other forums. Without these people and the work they have done as well as what they have helped me learn over the last 12 months this wouldn't have been created. Like all VD’s please feel free to constructively criticise or modify it to meet your needs STEP1: Setup api on node.js device: This VD requires jishi’s node-sonos-http-api to be installed on a node.js capable device. This can be a RPi, a NAS or something similar. Details on where to get the code and install can be found on Git - https://github.com/jishi/node-sonos-http-api You will also find an excellent blog/issue tracker at the link above for any issues you encounter I have mine installed on a Rpi Added Feb 5th The fastest way I found to get up and running on a PI if you're unsure and just want to try it (takes about 15 minutes) Use the sonos-api precompiled rpi image at http://jishi.github.io/node-sonos-http-api/ (apply to blank sd card) when you login over SSH (with something like putty) the password is root Map a network drive or Start Run to \\<IP of Pi>\flash click apps folder and you'll see the sonos-http-api folder Get an API from VoiceRSS and create a settings.json file (details in the post) and drop it into the sonos-http-api folder reboot and that's it - test through browser with something like http://<ip-of-Pi:5005/<playername>/Say/Hello If you want to upgrade to the latest api release Download the latest zip from https://github.com/jishi/node-sonos-http-api (green button on right) In the flash folder rename the sonos-http-api to -old Rename what you downloaded to to sonos-http-api Drop in your settings.json file SSH into the Pi - login = root cd /flash/apps cd sonos-http-api npm install --production when finished reboot DOCKER from @riemers (thanks ) You could also use docker Some nas systems include docker too (synology) from the gui. Using docker is easy and simple to give to someone else too, work on Pi3 too. For node-sonos-api there is a docker image https://github.com/chrisns/docker-node-sonos-http-api saves you the hassle of installing all dependency's, assuming you have some knowledge with linux. # Edit - additional observation - I like the Synology NAS option but mine doesn't reboot in the event of a power outage. The Rpi does reboot. If you use a NAS it might be good to use a UPS or find a way to reboot after an outage Once you have this setup you are ready to move on to Step 2 STEP 2 : Import the VD, you will need one VD per sonos zone node-sonos-api VD.vfib Name - The zone name needs to be the same as what it is in native Sonos (try and avoid chars such as /,etc) Spaces are okay IP Address: This is the IP of the device where the api is installed (This is NOT the IP address of the sonos zone) Port: Leave at 5005 (can be changed it needed, see git above) STEP 3 : Configure Play, Stop, Repeat, Shuffle, etc – this should work as is The parts you may want to modify are as follows => Volume I opted for the vol + / vol – as opposed to the slider as I find the sliders difficult to use on a tablet Vol + / - operates in increments of 2%. This is easy to change in the url string. The Vol 10% button is also easy to change => Favourites You will need to modify this to your favourites and how they are named in your sonos setup I would advise simplifying these names in the native Sonos setup as much as you can. Spaces are okay, you just need to use %20 where you have a space in a name If you need more of less favourites, please add/delete buttons as required => Playlists I don’t really use them but these are easily enough added in a similar way to the favourites above. => Line-in selection You can create one button for each line in option on your setup for any connect/connect amp or Zp unit.. (I have 4 on my setup) You will need to get the UUID for the zone that has the line in physically connected to it. You can get the UUID of that zone by viewing the topology of the zone with the topology url. (drop it into chrome/ff) http://[IP of any of your zone]:1400/status/topology The format of the url http://192.168.1.89:5005/kitchen/setavtransporturi/x-rincon-stream:RINCON_000E5832B85401400 and you will need to change the last numerical string for your own UUID. => Grouping Zones I have included two examples of grouping and ungrouping The url format is simple and easy to read. below are two examples that were setup on the kitchen zone where I wanted to group the Playroom zone two it and play what was playing on the kitchen zone Group - [playroom joining kitchen and playing kitchen music] http://192.168.1.89:5005/playroom/join/kitchen Ungroup - [playroom leaving kitchen zone] http://192.168.1.89:5005/playroom/ungroup/kitchen You could also include a group all and an ungroup all by stacking the commands from each zone under one button. There are also options to control volume of grouped zones if you like but I haven't explored that yet Beyond this… The api is very extensive and still undergoing development. There are other functions in the api that could be used and might be worth a glance depending on your system and patterns of use I'll update the post this evening with the actual VD as I can't seem to export it remotely. The node.js api will need to be installed first before the VD will be of any use. Hopefully it will be of use to some people Thanks -Frank Update: Adding VD file Adding some extra information The api is very extensive and seems to keep growing I use it for mainly behind the scenes control rather than me clicking the vd/scenes buttons manually If you look at http://zone_ip:5005/room_name/state for any of your players you’ll see all the state json info and what’s possible to control/trigger from Pretifying the json will show it's structure better { "currentTrack": { "title": "x-sonosapi-stream:s2846?sid=254&flags=32", "albumArtUri": "\/getaa?s=1&u=x-sonosapi-stream%3as2846%3fsid%3d254%26flags%3d32", "duration": 0, "uri": "x-sonosapi-stream:s2846?sid=254&flags=32", "type": "radio", "absoluteAlbumArtUri": "http:\/\/192.168.1.63:1400\/getaa?s=1&u=x-sonosapi-stream%3as2846%3fsid%3d254%26flags%3d32" }, "nextTrack": { "artist": "", "title": "", "album": "", "albumArtUri": "", "duration": 0, "uri": "" }, "volume": 10, "mute": false, "trackNo": 1, "elapsedTime": 651, "elapsedTimeFormatted": "00:10:51", "playbackState": "PLAYING", "playMode": { "repeat": "none", "shuffle": false, "crossfade": false } } I have a VD that shows me the status of all my players (attached) main scene code (just add labels local device = fibaro:getSelfId(); local zonename = fibaro:getName(device); local ipaddress = fibaro:getValue(device, "IPAddress"); local port = fibaro:getValue(device, "TCPPort"); sonos = Net.FHttp(ipaddress, port); local jS = json.decode(fibaro:getGlobalValue("StateTable")) -- zero the counter for each loop local zoneCount = 0 -- LANDING response = sonos:GET("/Landing/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.Landing_Stairs.isPlaying = 1 else jS.Landing_Stairs.isPlaying = 0 end jS.Landing_Stairs.volPlaying = jsonTable.volume jS.Landing_Stairs.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblLanding.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- TWINS BEDROOM response = sonos:GET("/Bed_LE/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.lau_eth_bedroom.isPlaying = 1 else jS.lau_eth_bedroom.isPlaying = 0 end jS.lau_eth_bedroom.volPlaying = jsonTable.volume jS.lau_eth_bedroom.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblBedLE.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- FRANK BEDROOM response = sonos:GET("/Bed_Frank/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.frank_bedroom.isPlaying = 1 else jS.frank_bedroom.isPlaying = 0 end jS.frank_bedroom.volPlaying = jsonTable.volume jS.frank_bedroom.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblBedFrank.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- GUEST BEDROOM response = sonos:GET("/Bed_Guests/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.guest_bedroom.isPlaying = 1 else jS.guest_bedroom.isPlaying = 0 end jS.guest_bedroom.volPlaying = jsonTable.volume jS.guest_bedroom.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblGuests.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- OFFICE response = sonos:GET("/Bed5_Office/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.office.isPlaying = 1 else jS.office.isPlaying = 0 end jS.office.volPlaying = jsonTable.volume jS.office.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblOffice.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- MASTER BED response = sonos:GET("/Bed_MasterL/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.master_bedroom.isPlaying = 1 else jS.master_bedroom.isPlaying = 0 end jS.master_bedroom.volPlaying = jsonTable.volume jS.master_bedroom.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblMaster.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- HALL response = sonos:GET("/Hallway/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.hall.isPlaying = 1 else jS.hall.isPlaying = 0 end jS.hall.volPlaying = jsonTable.volume jS.hall.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblhallway.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- KITCHEN response = sonos:GET("/Kitchen/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.kitchen.isPlaying = 1 else jS.kitchen.isPlaying = 0 end jS.kitchen.volPlaying = jsonTable.volume jS.kitchen.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblkitchen.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- PLAYROOM response = sonos:GET("/playroom/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.playroom.isPlaying = 1 else jS.playroom.isPlaying = 0 end jS.playroom.volPlaying = jsonTable.volume jS.playroom.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblplayroom.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- GARAGE response = sonos:GET("/Garage/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.garage.isPlaying = 1 else jS.garage.isPlaying = 0 end jS.garage.volPlaying = jsonTable.volume jS.garage.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblgarage.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- PIZZA BBQ response = sonos:GET("/PizzaBBQ_Area/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.pizza_bbq_area.isPlaying = 1 else jS.pizza_bbq_area.isPlaying = 0 end jS.pizza_bbq_area.volPlaying = jsonTable.volume jS.pizza_bbq_area.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblpizza.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- LIVING response = sonos:GET("/Living_Room/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.living_room.isPlaying = 1 else jS.living_room.isPlaying = 0 end jS.living_room.volPlaying = jsonTable.volume jS.living_room.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lblliving.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); -- GARAGE response = sonos:GET("/DiningRoom/state") jsonTable = json.decode(response); if jsonTable.playbackState == "PLAYING" then zoneCount = zoneCount + 1 jS.dining_room.isPlaying = 1 else jS.dining_room.isPlaying = 0 end jS.dining_room.volPlaying = jsonTable.volume jS.dining_room.nowPlaying = jsonTable.currentTrack.artist jStateTable = json.encode(jS) fibaro:setGlobal("StateTable", jStateTable) fibaro:call(device,"setProperty","ui.lbldining.value",""..jsonTable.playbackState.." | "..jsonTable.volume..""); fibaro:setGlobal("ActiveMusicZones", zoneCount); fibaro:call(device,"setProperty","ui.activeZones.value",zoneCount); Three of my zones use power amps (the are sonos connects) and I use the ‘playstate’ to turn the amp on / off when required. That’s the code at the bottom of the vd At one stage I was even displaying the image (radio station, music album) on an openremote UI using the uri part of the state json. I use the VoiceRSS TTS on teh http api but there are others. That all that was there when I found it and it worked well I have TTS to tell me “welcome home”, “good night”, "gate opening/closing", "garage door opening/closing" and all the usual stuff but I vary the volume it at night so it doesn’t wake everybody up. I intend this expand this feedback out so If we come home and the alarm went off it would tell me or that the washing machine has finished, the humidity is still too high in the bathroom and I should open the window (or that a fan was turned on) or some HC2 system info like the available memory went beyond certain thresholds, temp in a room rose or dropped, My siemens alarm is connected to my HC2 and I keep track of all the status of the alarm zones and when we press the “Leaving Home” button it checks the alarm zones and if one or many are open, it will TTS the open alarm zones in the hall sonos so we know where to go and close. Same thing when we go to bed at night. I found that each of my zones have different volume levels that work at night and during the day. I’ll be using my HomeTable (different topic) to store this info for each zones but it can written directly into the scene/vd. (This is what the the following code is for) I also plan on using a central TTS engine (simple a scene that take a zone/message and vol) so I can TTS more easily to any player. For now I have specific TTS code on a per player basis. I leverage the global variables that @Sankotronic Weather Basic VD populates and a scene that allows me to send the current weather (temp, humidity, wind speed direction, etc) as a TTS to our bedroom in the morning as well as the temp of the house as part of our wake up routine The API has a presets concept. This allows the user to pre-define a set of grouped players, source and volume. This is a file on the rpi and is referenced by a single command rather than starting one zone and grouping other zones. An example of its structure is as follows ... { "players": [ { "roomName": "Landing", "volume": 0 }, { "roomName": "Bed_MasterL", "volume": 0 }, { "roomName": "Bed_LE", "volume": 0 }, { "roomName": "Bed_Frank", "volume": 0 } ], "pauseOthers": false, "favorite": "96FM" } You may notice that the volume is set as 0 because I use another scene to slowly raise the volume so we are not woken to the sharp shock to a loud song. This simple vd button code is what I use to slowly raise the volume slowly local device = fibaro:getSelfId(); local zonename = fibaro:getName(device); local ipaddress = fibaro:getValue(device, "IPAddress"); local port = fibaro:getValue(device, "TCPPort"); sonos = Net.FHttp(ipaddress, port); for v = 1, 10 do response = sonos:GET("/Bed_Frank/volume/"..v.."") fibaro:debug("vol= "..v.."") fibaro:sleep(1000) end I use this for morning music upstairs and downstairs as well as when the kids go to bed. (changing the presets on the rpi requires a restart of the api - i normally just reboot the pi ) Watch out for radio favorites and playlists - try and not have spaces in the names on sonos and you should have no issue calling them ADDED - Jan 21st Creating a single button on a VD to cycle through favorites or playlist instead of using 1 per favorite. Every time you click the button it selects the next favorite. I have it limited to 5 favorites but this is easily adjusted. I store the favorite in my HomeTable but it could also be a global variable. I use an array to decode the numerical value stored globally into the actual favorite so I can append to the sonos api call. This will need to be adjusted to suit your system VD button code .... local device = fibaro:getSelfId(); local ipaddress = fibaro:getValue(device, "IPAddress"); local port = fibaro:getValue(device, "TCPPort"); local jT = json.decode(fibaro:getGlobalValue("HomeTable")) -- Get the current favorite number stored, increment by 1 and if > 5 set back to 1 local f = tonumber(jT.Landing_Stairs.RadFav) + 1 if f > 5 then f = 1 end -- Store the new favorite jT.Landing_Stairs.RadFav = f fibaro:setGlobal("HomeTable", json.encode(jT)) -- Array for the favorites fav = {[1] = "4FM", [2] = "96FM", [3] = "Calm", [4] = "Heart", [5] = "Red_FM"} -- Execute the sonos conmmand sonos = Net.FHttp(ipaddress, port); response = sonos:GET("/Landing/favorite/"..fav[f]..""); I also reflect this on a status label on the VD. -- Get favorite stored globally local f = tonumber(jT.Landing_Stairs.RadFav) -- Translate into favorite name to be displayed fav = {[1] = "96FM", [2] = "4FM", [3] = "Calm", [4] = "Heart", [5] = "Red_FM"} -- fav[f] represents the name. I apppend to otehr date and display in one label local status = " "..fav[f].." | "..jTS.playbackState.." | Volume "..jTS.volume.."%" fibaro:call(device,"setProperty","ui.status.value", status); This display at the top of the VD doesn't account is somebody changes the favorite from the native sonos app. I'll add code later to keep alignment between what is selected and what is stored in the global variable, This is what it looks like on my setup that is still a work in progress x Please see post 163 on this topic on how to get the VD icons dynamic for radio station or line in
  23. Hello. I installed a UPS in my house wich is monitored and controlled by a Raspberry Pi. Is there a posibillity to shutdown the HC2 with an API command via HTTP from a Rasperry PI? There will be a power down for about 3 hours next week in my small town, my UPS can keep up the power for about 35 minutes. So I'll try to shutdown the Rasperries and the HC2 if the load of the UPS is smaller the 5%. I would be happy if there is some solution out there [EDIT] I forgot to tell that the Firmware fo my HC2 is 4.056. [/EDIT]
  24. HI, I am implementing an OpenRemote interface and may have come across an issue. All sensors in OR poll constantly according to what has been has been configured A sensor in OR is a way to read back the status of any device. The polling rate for a switch needs to be 1 second so you can see the status has changed when it is clicked. This creates a possible problem Multiply x 100 devices and you get a lot of API calls just to keep OR functional. I have noticed an increasing use of memory since I started implementing OR This surfaces two issues in my mind Do we know how many API calls (per second, per minute) that the HC can hanndle If I am close to the threshold or prove that it is becomming an issue, would a slave HCl alleviate this stress ? Thanks Frank
  25. Hi folks, A bit of a puzzler I'm hoping that some of our http/api specialist might be able to offer some advice I'm working with openremote and at it's heart are http calls to the HC2 api I have a GET request working but when I try and create a POST request in a similar manner it doesn't seem to work (both work in a browser) Are their some special conditions/setting that a POST must have that a GET doesn't GET - http://192.168.1.90:80/api/devices/92 POST - http://192.168.1.90:80/api/callAction?deviceID=92&name=setValue&arg1=55 I spent a day on this - all suggestions welcome......
×
×
  • Create New...