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


  • 0

Experienced HC User but not LUA coding


Question

Posted (edited)

Hi,

 

I am a total beginner with LUA and was hoping someone could potentially help?

I have created a number of scenes with graphics blocks for all sorts of uses. I've also created Alarm scenes based on activation of devices with delays on entry etc but these have been easy to create with graphics blocks.

 

Here is my current Alarm Activation Scene, which is converted to Lua from graphics blocks.

 

Please login or register to see this code.

 

Over the last months I've expanded my Philips Hue and wish to use these in scenes but if I'm honest, I'm struggling. 

I've recently installed the Philips Hue AIO VD @Sankotronic as previous searches lead me to this. I can get it to work in basic scenes with graphics blocks using the VD button number for flashing lights but it only lasts 10 seconds and activates the last hue bulb I was using, not a specific bulb and for a much longer period of time, until I stop it and I'm not sure what to do.

 

I would like to be able to arm a Door Sensor and if the sensor is breached while armed, a set number of Hue bulbs turn on and flash a colour (or alternate between colours) and trigger a siren and they continue to flash and activate for 15 mins or until I turn it off.

It's the Hue side of things where I am struggling.

 

I managed to write this with "Emergency" being alternate blue and red but as you can see it's super basic.

 

Please login or register to see this image.

/monthly_2020_03/image.png.ef768421a36959bde6975d467ad19823.png" />

 

 

Please login or register to see this code.

 

I don't mind learning and have spent a long time searching and want to develop this more but I need some guidance.

Can anyone help?

 

Thanks.

 

 

 

Edited by MrConstruction

5 answers to this question

Recommended Posts

  • 0
Posted

Hi @MrConstruction ,

 

HUE AIO VD support alert that is built in Philips HUE bulbs, but max duration set by Philips is 15 seconds and HUE AIO VD goes to that duration. In the mean time I have made new set of Philips HUE VDs that can support this native HUE alert up to 10 minutes, but it will be available only with my

Please login or register to see this link.

when is finally released some time this year.

 

With HUE AIO VD it is still possible to get alert to last longer and it is also possible to control group of HUE bulbs. To achieve that you first need to make one zone using HUE original mobile app and add all bulbs to that zone. When you do that just open HUE Preview VD for editing and press Save button so that it gets all new settings from HUE bridge. Now add one HUE AIO VD and set it up to control that zone (group). You can find that zone (group) ID with HUE Preview VD.

 

Now you will need to make either scene or VD  with below code that will setup alert parameters to global variable "HueAlert". Details how to do that are explained in provided User manual on page 25 see chapter 4.3. Here is example how to make that zone to flash in red color at full brightness for 5 minutes:

 

Please login or register to see this code.

I have tested this code and it works as expected. there are small stops every 15 seconds but that should not be a big problem. There is a bug in HUE AIO VD that does not really reset bulbs properly to previous state so I recommend to set hA.hue.rst to false and remember previous state withing your code as in example above.

 

This HUE original alert uses only one color for alert. Still it is possible to modify above code to change color with each single alert duration, eg. to flash in red for 15 seconds then in blue for next 15 seconds and then again in red or other color.

 

Hope this helps a bit.

 

Enjoy coding :-)

 

  • 0
  • Inquirer
  • Posted

    @Sankotronic

     

    First of all, a big thank you for providing the HUE AIO VD in the first place. It looks like it was a lot of work and much appreciated.

    I was actually quite surprised I managed to get the preview working in the first instance but the manual helped a lot :)

    On to the matter at hand, thanks for taking time out to reply.

     

    I added the group and can see in the AIO preview VD that is has a group ID of 8.

     

    For this part 

    3 hours ago, Sankotronic said:

    Now add one HUE AIO VD and set it up to control that zone (group)

     

    Do you mean go to devices and add a VD and import your 'SA_HUE_AIO_v3.1.vfib.json' ?

     

    And then this

    3 hours ago, Sankotronic said:

    Now you will need to make either scene or VD  with below code that will setup alert parameters to global variable "HueAlert". Details how to do that are explained in provided User manual on page 25 see chapter 4.3. Here is example how to make that zone to flash in red color at full brightness for 5 minutes:

     

    I'm completely lost here. Spent a couple of hours trying to figure it out but not getting anywhere fast ?

    I really want to get this and learn LUA a lot more but am out of my depth here.

     

    Any chance you can make it a little easier to understand for a complete novice :)

    • 0
    Posted

    Hi @Mr.Consruction ,

     

    6 hours ago, Mr.Consruction said:

    Do you mean go to devices and add a VD and import your 'SA_HUE_AIO_v3.1.vfib.json' ?

     

    Yes, sorry, proper word is import SA_HUE_AIO_v3.1.vfib.json. How to import and set it up is explained in user manual chapter 3.8

     

    6 hours ago, Mr.Consruction said:

    And then this

    10 hours ago, Sankotronic said:

    Now you will need to make either scene or VD  with below code that will setup alert parameters to global variable "HueAlert". Details how to do that are explained in provided User manual on page 25 see chapter 4.3. Here is example how to make that zone to flash in red color at full brightness for 5 minutes:

     

    I'm completely lost here. Spent a couple of hours trying to figure it out but not getting anywhere fast ?

    I really want to get this and learn LUA a lot more but am out of my depth here.

     

    LUA code that I provided in my previous post you can, for example, put under the Emergency button of your Philips HUE Test 01 VD. Just copy and paste complete code to that button. in code after pasting it to button you need to setup hueID by replacing "69" with ID number of HUE AIO VD that you previously imported and setup to control  zone (group) of HUE bulbs. Don't forget to save VD after pasting code. Then click on the button and code should run.

     

    Adding HUE bulbs, groups and zones to HUE bridge can be done only with original HUE mobile app. After doing any changes on HUE bridge (adding/deleting/moving bulbs, groups, zones) all you have to do is to restart HUE Preview VD by opening it for editing and then saving it with Save button on HC2. It will then get all new changes from HUE bridge and you can then continue setting up HUE on HC2.

     

    Sorry for my bad English or bad way of explaining. I'm trying my best.

     

    Since you are new user I do recommend that you go to

    Please login or register to see this link.

      where you can find lots of knowledge about HC2 and LUA.

    On the top of this page there are also links to Fibaro knowledge.

     

    • 0
  • Inquirer
  • Posted

    @Sankotronic

    Thank you once again for posting such a detailed response. I’ll certainly give that a go later this evening and let you know how I go on. 
     

    I have spent some time on the knowledge base. I’m sure in time it’ll become much easier ?

    • 0
  • Inquirer
  • Posted

    @Sankotronic I got it to work ?

    I’ve then managed to create a number of block scenes based not the VD buttons. 
    Really appreciate your help on this. Now I can explore the functionality in more detail and then start building more scenes in Lua. 
     

    Thanks again

     

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...