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

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

  1. Hi everyone, I'm having some issues with Lua code in a virtual device I am writing. I'm getting information on the status of my Bluespray irrigation controller. It has a basic API and reports if any of the zones are on watering. I want to just query the unit and then print out if any are detected as on. When I query bluespray controller and its not watering anything I get some JSON back which looks like this. { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ ], "timestr": "Sat Mar 11 2017 10:09:38 PM", "time": 1489241378000, "door": 0 }, "id": 528452 } When its IS watering I get the following. { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ { "on": 1489240754, "off": 1489241054, "run": 1489240754, "terminal": 3 } ], "timestr": "Sat Mar 11 2017 10:00:12 PM", "time": 1489240812000, "door": 0 }, "id": 218829 } To make it even more complex sometimes the system reports multiple zones operating. (This is normal and ok. I just need to pick up the first zone reported) { "result": { "sensors": { "door": 0, "rain": 1 }, "active_zones": [ { "on": 1489241854, "off": 1489241974, "run": 1489241854, "terminal": 4 }, { "on": 1489241854, "off": 1489241974, "run": 1489241854, "terminal": 8 } ], "timestr": "Sat Mar 11 2017 10:17:38 PM", "time": 1489241858000, "door": 0 }, "id": 998161 } My issue is detecting if I get none, one or multiple active zones. If I have a valid zone then I then want to put the first zone number into the zoneterminal variable. If I don't have a valid zone I just want to put 0 into the zoneterminal variable. The problem is when I try something like the code below I get [ERROR] 22:11:22: line 56: attempt to index field '?' (a nil value) I cant figure out how to deal with LUA arrays correctly. (specifically detecting valid entries) The json.null operator does not seem to work the same way on array values. -- This script polls data from a local Bluespray Irrigation controller every 60 seconds and displays the status of the active zones -- Its configured for a speicific system but could easily be adapted to any bluespray controller. -- This script is written for Fibaro HC2 -- Script written by Brom ([email protected]) -- version 0.1 (10/3/17) function round(x, n) n = math.pow(10, n or 0) x = x * n if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end return x / n end fdata = {} zonename_1 = "Front Lawn" zonename_2 = "Road Lawn" zonename_3 = "Front Garden" zonename_4 = "Back Lawn Left" zonename_7 = "Back Lawn Right" zonename_5 = "Back Garden Left" zonename_6 = "Back Garden Right" fdata.selfId = fibaro:getSelfId() fdata.selfIp = fibaro:get(fdata.selfId, "IPAddress"); -- Perform the grab from the irrigation controller. local irrigationcontroller= Net.FHttp(fdata.selfIp); response,status,errorCode = irrigationcontroller:GET("/api/status") -- Basic debugging fibaro:debug(response) -- Check the respose from the controller is valid and Pull out the details from the JSON response. if (tonumber(status)==200 and tonumber(errorCode)==0) then local irrigation = json.decode(response) -- If any of the responses are null then make them 0 if irrigation.result.time == json.null then polltime = 0 else polltime = irrigation.result.time end -- this bit does not work !!!! zoneterminal = irrigation.result.active_zones[1].terminal zoneon = irrigation.result.active_zones[1].on zoneoff = irrigation.result.active_zones[1].off zonerun = irrigation.result.active_zones[1].run -- Basic Debugging fibaro:debug("polltime: "..polltime) fibaro:debug("zoneterminal: "..zoneterminal) fibaro:debug("zoneon: "..zoneon) fibaro:debug("zoneoff: "..zoneoff) fibaro:debug("zonerun: "..zonerun) timeleft = (zoneoff - zonerun) / 2 / 60 fibaro:debug("timeleft: "..timeleft) -- Output to the device. if zoneterminal == 0 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," OFF ") end if zoneterminal == 1 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_1) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 2 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_2) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 3 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_3) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 4 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_4) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 5 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_5) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 6 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_6) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 7 then fibaro:call(fdata.selfId, "setProperty", "ui.watering.value"," ON "..zonename_7) fibaro:log("Time Left "..timeleft.." Min"); end if zoneterminal == 0 or zoneterminal == 1 or zoneterminal == 2 or zoneterminal == 3 or zoneterminal == 4 or zoneterminal == 5 or zoneterminal == 6 or zoneterminal == 7 then fibaro:debug("Valid Zone") else fibaro:call(fdata.selfId, "setProperty", "ui.watering.value","Error") end else fibaro:debug("error Irrigation Controller: "..errorCode) end -- sleep for 1 min fibaro:sleep(10000) -- fibaro:sleep(60000) Any help appreciated. ps Code for the output is really extra long. Looking to understand how I can manipulate the variable name / number I am outputting to reduce the number of if statements. Once I get this figured out I plan to also add in buttons to perform manual runs. Brom
  2. Hi all, The wife and I have done some work on getting json data from a Raspberry PI, running PI1Monitor. The Pi is reading the data from a smart meter P1 port and we built a virtual device that shows the meter readings in a VD screen. I included the VD and LUA-code. It's not pretty, but it works. We would like to take this to the next level, but here is where we need help. - Would it be possible to change the VD so it delivers the current usage to the power metering of the HC2. Right now, we have only some switches and dimmers that are counted in the power panel and we would like to have all power usage visible and we're not so interested in the usage of individual lights. We could use "some" help with that. - How can we add icons to the labels. We've seen some examples with beautiful screenshots, but we are stuck with plain text. Feel free to use the code. We're happy to share it with you. Regards, Erwin & Linda Slimme meter.lua Slimme_meter.vfib
  3. Hi, I integrated my mechanical ventilation system with a RGBW Controller into FIBARO and want to control it by a Virtual Device. I made a VD with a couple of lines and buttons to set a certain mode for a certain time period. I added LUA per button but it doesn't seem to work correctly. What I want is that if I press one of the 50% buttons, the ventilation goes this mode for X minutes and than go back to 25%. When I add "IF" and "THEN" in the button it's not changing to 50%, but if I remove that the time frame does not seem to work. Anybody who can help me with this? ?
  4. Hello All, I am looking for some help to create a virtual device for a epson projector that utilizes the PJLink protocol. that way it could be used for a lot of different projectors. I am a newbie and have little experience with coding, Any help would be gtreatly appreciated.
  5. Morning all, It's been a while since I have seen any chatter about the Broadlink devices. Has anyone created a virual device or further thoughts on integrating the Broadlink IR / 433 blaster???
  6. Version 1.0.0

    261 downloads

    The Virtual Device shows the battery status of battery powered devices. In addition, it will send an email to a user when the battery is low or dead. It is suitable for a small number of devices and gives you a snapshot view. Note that the Lithium battery drops suddenly and if its below 80 then its marked as low and should be replaced. The battery is checked once a day roughly. The lua code is attached. I have written it for efficiency instead of accuracy, as lua execution is so so slow. Hence the use of delays. You need as many labels in the VD as the number of devices and it uses label1..labeln for simplicity. CODE.TXT
  7. Hello! i Wonder how can i change width of virtual device to get perfect square? now it's very large and take much space for only energy consumption report
  8. so im quite astonished that in the widget options on the android app, there is NO widgets to quickly access virtual devices. The only option is to open the app and hunt down for which virtual device i want to control., be it VSL for example... it really limits the "quick access" you'd expect from a smart phone/tablet app. Does anyone have any ideas or suggestions for quickly accessing them?
  9. Hi all, I'm a newbie at this and stuck on something which should probably be simple. I have created a Global Variable "HomeAway" with three values (home), (Away) and (Workweek). I have then created a virtual device so that i can make a button to set this variable. Once done I will use this to manage a range of things in the house like hot water, heating, blinds and lighting. But I just cant get the virtual device to change the variable. I have found plenty about this online but all solutions i read don't work. It seems i need to add code into the virtual device. but what code. The LUA manual says this line should work "fibaro:setGlobal(‘HomeAway’, ‘Home’);" but nothing happens. Any help greatly appreciated.
  10. A simple, rather basic question: I would like to control several devices through one control. The control could be on/off or "set to chosen common value"/off. "Set to common value" could be a dim level for dimmers, or a temperature for thermostats, where the value is not preset but determined as the control is used. I see several ways to do this, each with its own advantages and disadvantages: 1. Make two separate scenes, one to turn the device set on and one to turn them off. Advantage: Very simple to implement for on/off control. Activated only when needed. Disadvantage: Clutters the system with too many scenes. Tricky to achieve value control (but can be done by setting a global variable) 2. Make one scene which performs both desired actions. To dictate whether to turn on or off, either check the current status of the unit or have a global variable which toggles between On and Off each time the scene is run. Advantage: Fewer scenes than option 1. Activated only when needed. Disadvantage: Still messy to perform value control 3. Make a virtual device, with push buttons for on/off or a slider for value control. Advantage: Very intuitive and simple interface Disadvantage: The VD is run every 3 seconds, which is unnecessary as there is no data harvesting involved. I lean towards doing this as a VD, and could include a long fibaro:sleep command in the LUA code to avoid the code (which would essentially be empty) being run every three seconds. Question: Will a sleeping VD respond immediately to buttons or sliders being used, or only after the sleep period ends? Or more generally: How do you prefer to manually control a set of devices, through scenes or VDs?
  11. The title says it all. It would be nice if we could choose the color of the virtual device button so it is easier to the eye and change the color of the text inside. Thank you!
  12. Dear forum readers, I wanted to make HTTP request to an IP device of mine. to make it possible to send a body to a Url so that the variables wil change. i have 4 buttons in my virual device and each have to send its one variables to the ip device the Data of the body has to go to this link and de body variables are : <"eec0c0b41b4c43119d33e2bdafe1fc08"><name>Woonkamer</name><type>livingroom</type><preset>asleep</preset></location></locations> I know that i have to use the put command but i don't know how i exactly will put all the variables in the body. plugwise = Net.FHttp("ip", 80) plugwise:setBasicAuthentication("Username", "pass") fibaro:log(response) Can someone help me. on how i can do this on the best way.
  13. Hi! I have a Home Center LITE (without LUA support) and I am trying the creat a Virtual Device that can control my Synology NAS music player (AudioStation). It has a good webapi kit, that I can use with HTTP commands, but can't solve it. For example my ip addresses: - Fibaro HCL: 192.168.1.10 - NAS: 192.168.1.20:5000 - NAS l/p: admin:admin This is 3 command to the NAS (login / start music / pause music / etc.): LOGIN: http://192.168.1.20:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=1&account=admin&passwd=admin START MUSIC: http://192.168.1.20:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&method=control&action=play&id=__SYNO_USB_PLAYER__&version=2 PAUSE MUSIC: http://192.168.1.20:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&method=control&action=play&id=__SYNO_USB_PLAYER__&version=2 I can transform to GET HTTP request as a virtual device button, but doesn't work (e.g.. Pause): GET /webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&method=control&action=pause&id=__SYNO_USB_PLAYER__&version=2 HTTP/1.1 Host: 192.168.1.20:5000 Authorization: Basic admin:admin(Base64EncodedForm) I think it is ok, but what about Virtual Device advanced settings fields? - Name - Room - IP Address - TCP Port Is these IP Address and TCP Port the HCL's address or NAS's address? Don't working nether Can somebody help me, I fell I am so close! Thanks, Balage
  14. Hi, I am looking for some good Virtual device reference, which has intutive interface. Show in attched image. Thanks
  15. I try to build a scene that can search by the ip address of VD and return the device id. I have the following code just to display all the VDs that have IP but I do get nothing.... any help? --[[ %% properties %% events %% globals --]] local devs = api.get('/devices') for k,v in ipairs (devs) do -- fibaro:debug("01") local v2 =api.get("/devices/"..v.id) -- fibaro:debug(v2.id) for m,n in ipairs (v2.properties) do fibaro:debug(n.ip) if n.ip=="192.168.13.12" then fibaro:debug("device IP found") else fibaro:debug("Not Found!") end end end
  16. Perhaps not the right place for this question, but figured since it's related to beta testing of a new version, it's close enough. Please move otherwise! I am a happy fibaro user with some 40 different devices, and something I've been missing is the possibility to add virtual devices as a widget. Over the last years the app has evolved and more widget options has been added, but not VD. Maybe it's not that common to use VDs as much, or some other technical reason for not supporting it. But for me I don't see a need to have individual switches and dimmers as a widget, then I would have 10s of them.. With that kind of "desktop" I might as well get an iPhone So, is i possible to add this for a coming version of the Android app? Now I use third-party (imperihome) on the side only for the VD widgets.. And would love to get rid of that app and have all I need with the fibaro app.
  17. 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
  18. 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>
  19. Hi, I am wondering about the properties of a Virtual Device and how they can be accessed and changed. For instance, if you want to change the icon of a VD you can use a statement like this: fibaro:call(100, "setProperty", "currentIcon", 200); If you want to update a label text you would do: fibaro:call(100, "setProperty", "ui.label1.value", "Label text" ); To my question then: Does anyone know of a complete list of properties applicable to a Virtual Device? For instance: devices which report power consumption use the footer area to display current power usage. Can this area be accessed in a VD too? Someting along the lines of: fibaro:call(100, "setProperty", "ui.footer.value", "Footer text" ); I am reading in Fibaro's documentation of the REST API about how to extract a list of all VDs and their properties/data. There are apparently properties like "caption", and "buttonIcon". The question is if and how these can be set via LUA code. Thanks for any tips and hints. /Per
  20. Hello to all, I implemented to my HC2: IP Smartphone Presence Check V2.2 (http://www.domotique-fibaro.fr/index.php/topic/2613-detection-de-présence/) including some small changes but I identify one problem with data presentation on PC and on iPhone. Three way to view and three differents view:-( code are very simply: function Label(color, message) if color ~= "" then fibaro:call(selfId, "setProperty", "ui.Message.value", '<font color="'..color..'">'..message..'</font>') else fibaro:call(selfId, "setProperty", "ui.Message.value", message) end end Label ("green", os.date("On %d/%m/%y at %H:%M : ", timeVariable).."WIFI ON.") When I watch for this VD in Device/Advanced I see: When I watch for this VD in list of devices: And when I watch for this VD in mobile I see: Do you know how to apply text formatting "color" for viewing correct on iphone? Or how I code different view for mobile app and PC view? THX Peter
  21. Version 1.0.1

    114 downloads

    Here's a virtual device I created to control my Volumio Music Player, which is running on a Rasbperry Pi. Volumio comes with an own built-in ReST API that I use for the this virtual device. You must have your Volumio connected to your local area network (the same as Fibaro HC). After importing the virtual device, set the IP address and the port (default port 80) to point at your Volumio. Offical site of Volumio: www.volumio.org Volumio ReST API documentation: www.volumio.github.io/docs/API/REST_API.html Note: Tested on Fibaro HC2 4.180 Enjoy.
  22. Hi folks, I have some VD's which works great most of the time, but sometimes they seem to stop working and need to be kick-started again. How can I automatically trigger "wake up" of the VD's? I presume there are no way of force them to be active, self activation by the HC2, or? Regards, JP
  23. If a temperature sensor is installed in a room, that one is selected as temperature for the room (displayed at several places on the UI and used in heat control or so). Is is possible to have a value of virtual device defined as temperature of the room? Sorry, I found another item about this subject. This can be closed.
  24. I've seen a couple of times now that it seems like the virtual device is running an older version together with the new one. The reason I think so is that I see debug messages no longer in the main loop in the log when I test the latest changes. Anyone seen this before with version 4.510? How can I see what is actually running?
  25. Hi, I need to set a cookie in a VD Is it possible to modify the headers in a net.fhttp call ? Thanks
×
×
  • Create New...