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


Recommended Posts

Posted (edited)

Hello,

 

I'm struggling to create a scene or module to store hue light information in a global variable.

The purpose of it is that i want to signal some status changes through lights alerts (alarm activation/disactivation, move detection...).

The issue is that when the signalisation of the event is finished, i want to come back to my initial lights settings.

 

I don't want to get the information from fibaro HC2 but directly from the Hue Bridge, HC2 not being always updated with latest configuration.

My first ideas were:

  • to get devices list from HC2 and filter hue lights
  • get hue lightId from this
  • access the hue bridge and GET, lightId per lightId all configuration information
  • store this in a global variable.

 

I"m only starting in coding, LUA and so on and don't manage to get out of all the successive challenges it represent for me :)

 

At the moment, i'm trying to do a VD that looks appropriate for APIs usage with hue bridge and some other benefit.

 

 

    -- Getting all device information from HC2 

 

    local Device = api.get("/devices")

        for     i = 1, #Device do
                if         Device.parentId and Device.type == "com.fibaro.philipsHueLight"

                then

                local fibaroId     = Device.id
                local lightId    = fibaro:getValue(fibaroId, "lightId")
                local on         = fibaro:getValue(fibaroId, "on")    
                local bri        = fibaro:getValue(fibaroId, "bri")
                local sat        = fibaro:getValue(fibaroId, "sat")
                local hue        = fibaro:getValue(fibaroId, "hue")
                local power        = fibaro:getValue(fibaroId, "power")
                local reachable    = fibaro:getValue(fibaroId, "reachable")
                local name        = fibaro:getName(fibaroId)
                local room        = fibaro:getRoomID(fibaroId)
           
                fibaroLightState ={}
                table.insert (fibaroLightState,1,name)
                table.insert (fibaroLightState,2,fibaroId)
                table.insert (fibaroLightState,3,lightId)
                table.insert (fibaroLightState,4,power)
                table.insert (fibaroLightState,5,on)
                table.insert (fibaroLightState,6,bri)
                table.insert (fibaroLightState,7,sat)
                table.insert (fibaroLightState,8,hue)
                table.insert (fibaroLightState,9,reachable)
                
                fibaro:setGlobal("fibaroLightState", json.encode(fibaroLightState))
                
                end
        end

 

I don't manage to check if it's well working and have the feeling that one iteration delete the previous one.

Can someone provide some help ? 

I would like to get an output that then enable me to request the hue bridge for each lightID :)

 

PS: Not doing manually as circ 50 hue lights :)

 

 Thanks in advance for your help :)

Edited by Mateo
Need support
  • Topic Author
  • Posted

    any help?

     

    • 3 weeks later...
  • Topic Author
  • Posted (edited)

    Hello all, 

     

    looks like i've partly found my solution to store in a global variale my hue lights configuration from the bridge (HUE BACKUP Button in a VD below).

    The idea, after an visual alert/alarm (not just blincking .... red, orange, blue... depending on event), being in a position to come back to initial settings with HUE RESTORE (VD below)

    However i'm missing something as it looks that ... it does,'t work... and i don't understand why...

     

    Can an expert have a quick look on this surely basic issue?

    Thanks in advance for any support or idea....

    :)

     

     

    HUE BACKUP VD BUTTON 1

     

    Please login or register to see this code.

     

    HUE RESTORE VD BUTTON 2

     

    Please login or register to see this code.

     

    Edited by Mateo

    Join the conversation

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

    Guest
    Reply to this topic...

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