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!



Smart Home Forum by FIBARO Team

Search the Community

Showing results for tags 'basics'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start






Website URL





Found 2 results

  1. Hi, I know that when I started working with the HC2 I struggled with some of the simpler stuff. In some case it was down to a lack of understanding of the concepts rather than the code. I decided to put together this Virtual Devices 101 for new people starting out. I put some of this together to answer a few posts but decided to bring it into one post here to make it easier for newer users to find, I am starting from the basics and if anybody has ideas on how to make it better please let me know Some Virtual device basics LABELS - enable the user to display a title and a value. A label with no value entered can act as a divider BUTTONS - enable a user to execute an action, button can be manually pressed or through code. A VD can press one of its own buttons MAIN LOOP - Code here runs continuously in a loop - you can add fibaro:sleep code to slow down how fast the main loop code executes. Variables that are defined in the MAIN LOOP cannot be reused in the buttons. Seperate declarations are required DEBUG - option on Main loop or Button to what is being echo'd back as it executes The easiest way to understand virtual devices is to take apart a very simple one and understand the various parts I've attached a very simple VD. This will run on any HC2 after you have created the following two variables (Panels, Variables) Use the Add button but NOT the save button that is part of the right side vertical menu (as this may corrupt some of your other variable values) Go to "Add New Device" and import the VD (Pump Control) attached to this post. It's a very simple VD that interacts with the two variables you just created. (I don't expect the VD to be any use in real life but hopefully acts as a good learning tool. Press the appropriate set Status buttons to adjust the status displayed and also updates the Last change time to current time that indicates when somebody last changed the status. Send email send the current status and when this status was set I'll step through each part Current Time - label that display the current time from a local variable Pump Status - label that takes the value of a global variable and display appropriate text (1 = Runnnig, 0 = Stopped) Last Change - label that displays the value of a global variable. This global variable is whenever the status is adjusted by the following two buttons (#4, #5) Set Status to Running - Button that adjust a global variable to 1 value of 1. This also updates the global variable that holds the Last Change time to the current time. Set Status to Stopped - Button that adjust a global variable to 1 value of 1. This also updates the global variable that holds the Last Change time to the current time Divider - Label with now label value entered email Pump Status - This reads some global variables and using the Sendemail command sends the email to whatever emaila ccount is associated with HC2 admin role. MAIN LOOP - this keeps the global and local variable values up to date so they can be displayed in the labels Pick your way through the VD code, I think its straightforward enough. I did add some debug lines so you'll see more info in the debug screens Press Button action if you wanted to press one of the on the VD from another scene you need to know two things to use the following command fibaro:call(986, "pressButton",10) The id of the virtual device (986 above) and the button position (10 above) The id can be derived from the browser url when you have either the General or Advanced tab open n my screenshot above it 1870 but when you import it, the id will be different The second is the button position You need to count all elements in the VD so above buttons 4, 5 and 7 are valid PressButton actions These can be activated from within this VD, another VD or a scene using the following commands -- Set Status to Running fibaro:call(1870, "pressButton",4) -- Set Status to Stopped fibaro:call(1870, "pressButton",5) -- email pump status fibaro:call(1870, "pressButton",7) fibaro:log command The fibaro.log command in the VD presents the information on the VD when looked at in the full list of devices Virtual device - Advanced Config Tab In the advanced Tab of a VD you can define an IP address and Port If these are defined then the data can be used throughout the VD as follows. Place this code at the top of the main loop, button or label local device = fibaro:getSelfId(); local zonename = fibaro:getName(device); local ipaddress = fibaro:getValue(device, "IPAddress"); local port = fibaro:getValue(device, "TCPPort"); This takes what was entered as part of the advanced tab and assigns them as local variables (ipaddress and port) This are generally used where a VD is used to execute a http request Some other commands -- display a text value in a VD label fibaro:call(thisId, "setProperty", "ui.label1.value", "offline") -- display a variable value in a VD label fibaro:call(thisId, "setProperty", "ui.downavg.value",downavg.." °C") -- some slightly more complicated examples fibaro:call(thisId, "setProperty", "ui.hall.value",roundit(fibaro:getValue(1974, "value"),1).." °C") fibaro:call(thisId, "setProperty", "ui.hall.value",roundit(fibaro:getValue(hallTemp, "value"),1).." °C") fibaro:call(thisId, "setProperty", "ui.downavg.value",downavg.." °C") -- variable declaration local data = 1 local parameter = 5 local data, parameter = 1, 5 local msg = "1st "..alarmStatus.." alert with "..alertMsg.."." -- press button #1518 is the VD id and 1 is the button or through a local variable called SonosTTS fibaro:call(1518, "pressButton",1) fibaro:call(SonosTTS, "pressButton",5) -- Action to start a scene by either ID or variable that represents a numerical value fibaro:startScene(AlarmSet) fibaro:startScene(284) -- allow user to send email, 2 is the user id ("Alert" is email subject, "Garden sensor.." is the email body) fibaro:call(2, "sendEmail","Alert!", "Garden Sensor triggered") Suggestions to improve welcome -f EDIT : Feb 11 I added one more VD as an attachment from a suggestion from @Jamie mccrostie It's called Rack Temp Mngt It reads and displays the temperature from two probes I have, one is above each of my equipment racks . (The temp probes are 1-wire and use a Fibaro UBS to connect to HC2) I have two fans arrays to the side of the racks and these are switched from the two sides of a Fibaro dual relay This status is displayed as Fan status II then have two ON/OFF buttons to switch the Fans on or off if I see the temp running high. (I plan on automating this with temp threshold and notifications but it's on my long to-do list) It's a simple scene but I thought it was a good scene to help understand how things can setup It does use a HomeTable so the devices are all jT.equipment_rack.XXXX - just replace these with a relay id or equivalent local variable. Pump_Control.vfib Rack_temp_Management (1).vfib
  2. Hi, I’m new to LUA and actually newer did the programing, except the pascal on high school J. However I like to learn the new staff, best way for me is learning by doing. I developed many block scenes and converted them into LUA to understand the way it works, but still have some questions I believe if answered, other users will find useful as well. This topic should be for explanation how LUA works. First question what is tempfunc() for and how to use it?
  • Create New...