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

Question

Posted

Hi,

I was tidying up my light scenes where I turn on of off batches of lights (at night, going away, etc) and I wanted something simpler and more reliable. 

I created a very simple scene that stores the light ID's (or HomeTable references, as I have)  in a table and you pass the action (turnOn or tunrOff) in the startScene call so no need to use a global variable

The scene code is not really mean to be a solution like Smart message Hub but more of a case of sharing what I put together.

It a small amount of error handling and warnings should ID's be incorrect and should be easy enough to pick through as a learningexercise

 

The scene call is simple

Please login or register to see this code.

I included just two options 

deBug : set to true to see lights as they are checked

delay : this will set a sleep or delay between each light if you find that switching them off too fast is causing some to be missed

Comment out the reference to HomeTable (line 10) is you don't use this method

 

Scene Code is below

 

Please login or register to see this code.

 

PS - This approach could easily be expanded to store a number of groups (table) of lights in the the scene and pass 2 parameters in the startScene call, one parameter could be used to decide which group of lights and the second could be used to selection the action (turnOn, turnOn)

 

Enjoy - Happy Coding

-f

 

 

 

15 answers to this question

Recommended Posts

  • 0
Posted

Hi @AutoFrank,

 

any idea how the memory usae of HC2 behaves, when you're making big, bigger biggest hometable?

 

  • 0
  • Inquirer
  • Posted
    1 minute ago, Bodyart said:

    Hi @AutoFrank,

     

    any idea how the memory usae of HC2 behaves, when you're making big, bigger biggest hometable?

     

     

    @Bodyart

    I'm not a HC2 memory expert but the table is just a variable with text in it.

    I don't expect that making it the size of all your devices is going to make any difference

     

    I have the 'system' tables - Home, State and Network and I don't have any issues

    -f

      

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    • 0
    Posted

    thnx @AutoFrank, I understand, that probable it's only a quite small of memory usage..

    • 0
    Posted

    Very nice scene @AutoFrank!

     

    Just thinking how to go about dimmers, turnOn and if dimmer then setValue 90...

    I need to win a lottery so I can have more spare time to get my head around LUA ;)

     

    Jim

    • 0
  • Inquirer
  • Posted (edited)
    22 minutes ago, jimicr said:

    ust thinking how to go about dimmers, turnOn and if dimmer then setValue 90.

     

    @jimicr

    I think (haven't tested) if you turnOn a dimmer it will turn on at the last set value - CONFIRMED

     

    Two options sprnt to mind....

    Create two tables (one for switch and one for dimmers) and add some extre for when it steps through the dimmer table it setValue to a defined level

    expand existing table with a dimmer 'flag' and add extra code  to either 'turnOn' or 'setValue'

     

    both easy enough to do 

     

    to be honest I use this for batch light instructions and as such it's mostly off 

    The only time I could think about turning pn a lot of lights on a time if is we had an emergency (fire, need max visibility) or security issue ( turn on all lights outside to see who is stealing my carrots :-) )

     

    TBH - the real reason I shared is because it an 'easier to understand' example of passing an argument with a startScene command than the implementation in Smart Message Hub. I've gotten so much form people on this forum that I try and give back when I can.

     

    22 minutes ago, jimicr said:

    win a lottery

     

    I've be trying this for a good while now but the odds seem stacked against me :-)

     

    Edited by AutoFrank
    • Like 1
    • 0
  • Inquirer
  • Posted
    3 hours ago, jimicr said:

    Just thinking how to go about dimmers

     

    Hi @jimicr

     

    Scene modified to cater for dimmers

     

    Table structure is slightly changed

    Please login or register to see this code.

    dim = the predefined value for each light...

     

    Full scene code is below

    It doesn't cater yet for a dimmer light being on to a lesser value than the predefined value in the table, but I#'ll make that change and post again in a few days

     

    Scene call is the same as in the first post

    Please login or register to see this code.

     

     

    • 0
    Posted

    Thanks will play with soon

    • 0
    Posted

    This is good idea how I can solve turning On/Off my outside lighting. They are all HUE bulbs and I'm a simple man so for me it is one brightness setting for all. So I can just pass two arguments when calling scene:

    Please login or register to see this code.

    Since I'm using HUE VD I can actually only pass brightness value since set to 0 will turn them off:

    Please login or register to see this code.

    But then, these are HUE bulbs, the ones with color so I can actually do even better by passing to scene all three arguments brightness, hue and saturation:

    Please login or register to see this code.

    I can do even better if I split bulbs to areas like terrace, pool, arbour and bbq. Then I can send different settings for each area:

    Please login or register to see this code.

    Scene can check number of the arguments passed and act accordingly :) 

    • 0
  • Inquirer
  • Posted
    2 minutes ago, Sankotronic said:

    This is good idea how I can solve turning On/Off my outside lighting. They are all HUE bulbs and I'm a simple man so for me it is one brightness setting for all. So I can just pass two arguments when calling scene:

    Please login or register to see this code.

    Since I'm using HUE VD I can actually only pass brightness value since set to 0 will turn them off:

    Please login or register to see this code.

    But then, these are HUE bulbs, the ones with color so I can actually do even better by passing to scene all three arguments brightness, hue and saturation:

    Please login or register to see this code.

    I can do even better if I split bulbs to areas like terrace, pool, arbour and bbq. Then I can send different settings for each area:

    Please login or register to see this code.

    Scene can check number of the arguments passed and act accordingly :) 

     

    @Sankotronic

     

    I'm glad you can find a use for this...

     

    It got created by accident to be honest ....

    I was looking to improve my own light scenes for turning off the lights

    This morphed into something more generic

    Then I added checks to see if a light was on, so I would only turn those off

    Then I added the ability to turn them on

     

    ...and then the monster above appeared :-)

     

    ------

    Quick question re hue - do you control directly with the HC2 or do you use a bridge ?

    I was thinking about getting a couple to play with...

     

     

     

    • 0
    Posted
    1 minute ago, AutoFrank said:

    Quick question re hue - do you control directly with the HC2 or do you use a bridge ?

    I was thinking about getting a couple to play with...

     

    Hi @AutoFrank,

     

    My Angelina is sending commands to HUE bridge over the LAN. HUE bridge is set to static IP address of course. It is not possible to communicate directly to bulbs since they are using zigbee protocol only.

     

    4 minutes ago, AutoFrank said:

    ...and then the monster above appeared :-)

     

    Ha, ha, ha, I have same approach. First it is simple solution, but then ideas start dropping on my head and soon I have headache and 'monster' code that even I can't follow any more :D 

    • 0
  • Inquirer
  • Posted
    10 minutes ago, Sankotronic said:

    HUE bridge

     

    Thanks @Sankotronic

    What are you hosting Hue bridge on (Pi or something else ?), Is there a good set of 'setup instructions' somewhere simple enough even for me to follow ;-)

    • 0
    Posted
    14 minutes ago, AutoFrank said:

     

    Thanks @Sankotronic

    What are you hosting Hue bridge on (Pi or something else ?), Is there a good set of 'setup instructions' somewhere simple enough even for me to follow ;-)

     

    No need for any hosts. Angelina's HUE VD is sending commands directly to HUE bridge using Net.FHttp. You can download one HUE VD and check.

    • 0
  • Inquirer
  • Posted

    @Sankotronic

     

    So the HUE bridge is actually a VD and not a separate device ?

    • 0
    Posted
    6 minutes ago, AutoFrank said:

    @Sankotronic

     

    So the HUE bridge is actually a VD and not a separate device ?

     

    Hi @AutoFrank,

     

    Philips HUE bridge is separate device that controls HUE bulbs, so it is physical device, real one connected to home network so that HUE bulbs can be controlled by mobile devices even when you are not at home. It is needed even if you have HC2. HC is just sending commands over the home network to bridge and getting back status of the HUE bulbs with HUE VD.

     

    You don't really need HUE VD since you can add Net.FHttp commands to any VD you make. 

     

    • 0
  • Inquirer
  • Posted (edited)

    @Sankotronic

     

    ahhh... thanks

     

    interesting

     

    Do you have any of these 

     

    Please login or register to see this image.

    /monthly_2017_04/Capture.PNG.ca5727d56e836fcb056fbb864df8ae66.PNG" alt="Capture.PNG.ca5727d56e836fcb056fbb864df8ae66.PNG" />

     

    I wonder could I use this with a hue bridge to hijack the commands send by this device to the bridge for another purpose such as control my sonos volume in a room or anything else

    ... must read a bit more on this

     

    thanks

    Edited by AutoFrank

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