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

Philips Hue: how to get state of lamp?


thijs

Question

I am looking for a way to read the On/Off value of my Philips Hue light to control if they are actually on.

I have managed to get my Philips Hue set working with the help of the following thread:

Please login or register to see this link.

Very nice and helpfull thanks to automationfan

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

For other modules, like sensors from Homewizard, I have managed to read sensor values with decoding the json files (json.decode) and assign them to customized variables through the Variable Panel. However for my Philips Hue set this won't work as the On/Off state is a boolean (text) value and I am not able to retrieve that value through the json.decode command.

Please help me to find a way to read out these values and assign them to a variable in order for me to get feedback on whether or not all of my Hues are one.

Hope someone can provide some very usefull tips.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I also tried to get the state of my Hue lights, but did not manage to get it working. My problem was that the 'GET' command did not give a response to HC2 in most cases. It seems that there are similar problems with Arduino, see the Everyhue forum:

Please login or register to see this link.

I only control my Hue lights with my HC2 by means of motion sensors and wall switches with Fibaro dimmers with scene activation enabled (not with the Hue app). As a workaround I use a global variable to store the state of my Hue lights:

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • I've managed to solve this issue. Please see lua script below the 2 options that I use to control if my Hue lights are on. Debugging a boolean value in lua can be done with "fibaro:debug(tostring(state))"

    Basic LUA script:

    HueGtw = Net.FHttp("",80)

    -- geting info from your Personal Weather Station

    response = HueGtw:GET("/api/automation1/lights/2")

    -- decoding json file

    jsonTable = json.decode(response)

    Option 1):

    -- debugging specific data

    local state = jsonTable.state.on

    --debugging boolean value of ‘state’

    fibaro:debug(tostring(state))

    --set Global variable

    fibaro:setGlobal("Hue2_state_on", tostring(state))

    --set label value for virtual device #153

    fibaro:call(153,"setProperty","ui.Label1.value",tostring(state))

    Option 2):

    --create local variable

    local state = jsonTable.state.on

    --then setup compare function with followup command

    if state == true

    then fibaro:debug("on")

    fibaro:log("WK on")

    fibaro:setGlobal("Hue2_state", "On")

    fibaro:call(153,"setProperty","ui.Label1.value","On")

    else fibaro:debug("off")

    fibaro:log("WK off")

    fibaro:setGlobal("Hue2_state", "Off")

    fibaro:call(153,"setProperty","ui.Label1.value","Off")

    end

    Link to comment
    Share on other sites

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