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

copy state of Hue Lamp, and set another to that exact state.


ppeterr

Question

Hi, It's been a while since I made a topic here on the forum. Everything works smoothly as it should.
That's why I haven't touched my HC3 or made scenes for it for quite a while, and so not sure how to do the next thing.

 

All my lights are Phillips Hue, i only have one quickapp turning some lamps off with a motion sensor.
The rest is all controlled by a i-casa wall controller. This controller works with touch link. So "outside" of the homecenter.
This works perfect for me, since i can set the status of all lamps, and long press a wall button and it will remember the state of them all.

 

I have ordered a LED strip with zigbee controller. This one comes in today. But i just found out that touchlink won't work with this thing at all.

So I can't control this LED strip with the i-casa touchlink in-wall controller.
I can send it back and buy a Hue strip three times the price.

 

Or I can ask for your help :)

 

This LED strip will register as a Hue integration in the HC3 via the Hue hub. Just like the rest of the lamps. (or at least i hope so)

 

What I want to achieve:

 

When "kitchen lamp" turns on, the LED strip copies the status. So on or off AND the color state.

Below is the status output of the lamp i would like the led strip status to follow. (when turning on)

Quote

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_MAIN_139]: [HG] QA:188 Change in QA Woonkamer-Keuken

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_MAIN_139]: QA:188 any_on: false -> true

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_MAIN_139]: QA:188 Last Update: 27.07.2022 09:20:16

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: [L] Setting label value to lblState 2 - Partially On

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: [L] Setting value to sldBrightness 32

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: [L] Setting value to sldHue 78

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: [L] Setting value to sldSaturation 76

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: [L] Setting value to sldCt 100

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: [L] Setting label value to lblLastUpdate 27.07.2022 09:20:16[

27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: [L] updateInfo:

[27.07.2022] [09:20:16] [DEBUG] [QA_HUE_LIGHT_188]: Off 2.5W


 

Please login or register to see this code.

Can someone help me with that?
 

Edited by ppeterr
Link to comment
Share on other sites

Recommended Posts

  • 0
  • Inquirer
  • 8 minutes ago, SmartHomeEddy said:

    Does the colors variable has a value?

     

    (fibaro.debug)

     

    I am rebooting, and then i will try again. But what do you mean with fibaro.debug

    I dont see anything show up in the console. But it crashed again :P

     

    fibaro.debug("Scene101", "")
    local colors = fibaro.getValue(416,"color")
    fibaro.call(418, "setColor", colors[1],colors[2],colors[3],colors[4])
     
     
    [28.07.2022] [18:05:38] [DEBUG] [SCENE101]:
     
    Edited by ppeterr
    Link to comment
    Share on other sites

    • 0

    This will do to get the color codes from the api:

     

    local colors = api.get("/devices/416")
    fibaro.debug("colors: " , colors.properties.color)

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 26 minutes ago, SmartHomeEddy said:

    This will do to get the color codes from the api:

     

    local colors = api.get("/devices/416")
    fibaro.debug("colors: " , colors.properties.color)

     

     

    Thanks Ed, i will look into it tommorow!

    Edited by ppeterr
    dutch -> english
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • This works, and outputs: [29.07.2022] [07:00:05] [DEBUG] [COLORS: ]: 1,255,25,0

     

    local colors = api.get("/devices/416")
    fibaro.debug("colors: " , colors.properties.color)

     

     

    When i add the setColor line, the HC3 (only the lamp) becomes inresponsive.

     

    local colors = api.get("/devices/416")
    fibaro.debug("colors: " , colors.properties.color)
    fibaro.call(418, "setColor", colors[1],colors[2],colors[3],colors[4])

     

     

    When i do this, alone - the color changes correctly, and the lamp stays working

     

    fibaro.call(418, "setColor", 1,255,25,0)
    Edited by ppeterr
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 21 minutes ago, SmartHomeEddy said:

    I think this can work

     

    fibaro.call(418, "setColor", colors)

     

    Good morning, it gives the same effect. It gets the rgb value's correct.

    And then freezes the lamp in the HC3. 

     

     

    local colors = api.get("/devices/416")
    fibaro.debug("colors: " , colors.properties.color)
    fibaro.call(418, "setColor", colors)
    Edited by ppeterr
    Link to comment
    Share on other sites

    • 0
    30 minutes ago, ppeterr said:

    Good morning, it gives the same effect. It gets the rgb value's correct.

    And then freezes the lamp in the HC3. 

    local colors = api.get("/devices/416")
    fibaro.debug("colors: " , colors.properties.color)
    fibaro.call(418, "setColor", colors)

    Is there any log for QUICKAPP418 ? or the main Hue QA ?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 14 minutes ago, jgab said:

    Is there any log for QUICKAPP418 ? or the main Hue QA ?

     

    No nothing, i dont see that entry for 418 in the dropdown menu.

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 6 minutes ago, SmartHomeEddy said:

    418 is a quickapp, not the hue light?

     

    418 is a hue light

     

    {"id":418,"name":"strip keuken","roomID":220,"view":[{"assetsPath":"","name":"com.fibaro.colorController","translatesPath":"/assets/i18n/com.fibaro.colorController","type":"ts"},{"assetsPath":"","name":"level-change","translatesPath":"/assets/i18n/level-change","type":"ts"},{"type":"json"}],"type":"com.fibaro.philipsHueLight","baseType":"com.fibaro.colorController","enabled":true,"visible":true,"isPlugin":true,"parentId":34,"viewXml":true,"hasUIView":false,"configXml":false,"interfaces":["levelChange","light"],"properties":{"alert":0,"brightness":254,"categories":["lights"],"color":"17,55,255,0","colorComponents":{},"colormode":"xy","currentProgram":0,"dead":false,"deadReason":"","deviceControlType":51,"deviceIcon":15,"deviceRole":"Rgb","effect":0,"hue":41984,"icon":{"path":"plugins/com.fibaro.philipsHueLight/img/icon.png","source":"HC"},"isLight":true,"lightId":19,"log":"","logTemp":"","manufacturer":"","model":"","on":true,"reachable":true,"saturation":238,"saveLogs":true,"state":true,"supportedDeviceRoles":["Rgb","Rgbw"],"userDescription":"","value":100},"actions":{"setColor":1,"setColorComponents":1,"setValue":1,"startColorEnhancement":1,"startColorFade":1,"startLevelDecrease":0,"startLevelIncrease":0,"stopColorChange":1,"stopLevelChange":0,"toggle":0,"turnOff":0,"turnOn":0},"created":1658924548,"modified":1659077688,"sortOrder":130}

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • It might be a bit confusing. But the above made me think.

    I added the light into the Huemain quickapp. It created a new device.

    Now it gives some errors. (see the last line)

     

    [29.07.2022] [09:48:22] [DEBUG] [COLORS: ]: 234,125,255,0[29.07.2022] [09:48:22] [DEBUG] [QA_HUE_LIGHT_421]: [L] Direct color set to: {"properties":{"brightness":254,"colormode":"xy","currentProgram":0,"colorComponents":{},"isLight":true,"deviceIcon":15,"color":"234,125,255,0","logTemp":"","dead":false,"hue":52824,"categories":["lights"],"saturation":131,"alert":0,"model":"","state":true,"deviceRole":"Rgb","reachable":true,"manufacturer":"","deadReason":"","lightId":17,"deviceControlType":51,"log":"","saveLogs":true,"userDescription":"","icon":{"path":"plugins\/com.fibaro.philipsHueLight\/img\/icon.png","source":"HC"},"on":true,"value":100,"supportedDeviceRoles":["Rgb","Rgbw"],"effect":0},"sortOrder":128,"interfaces":["levelChange","light"],"viewXml":true,"baseType":"com.fibaro.colorController","type":"com.fibaro.philipsHueLight","view":[{"name":"com.fibaro.colorController","translatesPath":"\/assets\/i18n\/com.fibaro.colorController","type":"ts","assetsPath":""},{"name":"level-change","translatesPath":"\/assets\/i18n\/level-change","type":"ts","assetsPath":""},{"type":"json"}],"modified":1659077688,"roomID":220,"name":"afzuigkap rechts","enabled":true,"hasUIView":false,"isPlugin":true,"actions":{"stopLevelChange":0,"startColorEnhancement":1,"turnOff":0,"startLevelDecrease":0,"setColorComponents":1,"setColor":1,"stopColorChange":1,"startColorFade":1,"toggle":0,"startLevelIncrease":0,"setValue":1,"turnOn":0},"id":416,"created":1658853619,"parentId":34,"visible":true,"configXml":false},nil,nil,nil[29.07.2022] [09:48:22] [TRACE] [QA_HUE_MAIN_139]: [TRACE] HueCommands args={"value":81,"action":"colorRGB","colorR":{"sortOrder":128,"created":1658853619,"visible":true,"baseType":"com.fibaro.colorController","hasUIView":false,"properties":{"icon":{"source":"HC","path":"plugins\/com.fibaro.philipsHueLight\/img\/icon.png"},"deviceControlType":51,"deviceIcon":15,"deviceRole":"Rgb","logTemp":"","dead":false,"colormode":"xy","log":"","saveLogs":true,"userDescription":"","categories":["lights"],"value":100,"deadReason":"","alert":0,"state":true,"isLight":true,"hue":52824,"color":"234,125,255,0","model":"","brightness":254,"lightId":17,"saturation":131,"supportedDeviceRoles":["Rgb","Rgbw"],"effect":0,"currentProgram":0,"reachable":true,"colorComponents":{},"manufacturer":"","on":true},"name":"afzuigkap rechts","roomID":220,"viewXml":true,"enabled":true,"configXml":false,"actions":{"startLevelDecrease":0,"toggle":0,"setColorComponents":1,"setColor":1,"turnOff":0,"startLevelIncrease":0,"stopLevelChange":0,"startColorFade":1,"stopColorChange":1,"turnOn":0,"setValue":1,"startColorEnhancement":1},"view":[{"assetsPath":"","name":"com.fibaro.colorController","type":"ts","translatesPath":"\/assets\/i18n\/com.fibaro.colorController"},{"assetsPath":"","name":"level-change","type":"ts","translatesPath":"\/assets\/i18n\/level-change"},{"type":"json"}],"parentId":34,"modified":1659077688,"interfaces":["levelChange","light"],"id":416,"type":"com.fibaro.philipsHueLight","isPlugin":true},"time":1659080902,"deviceID":421,"type":"Hue","transitiontime":0} - Delivered: 0s

     

    [29.07.2022] [09:48:22] [ERROR] [QA_HUE_MAIN_139]: [ERROR] Error in fibaro.setTimeout: ./include/HueTools.lua:25: attempt to perform arithmetic on a nil value (local 'a4')

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Lets see if i understand the problem. (i have 2 options)

     

    option 1

     

    I have the Hue integration from fibaro.

    That gives a child device (lightstrip with ID 418)

    And another lamp where i want to use the color value's from (ID 416)

     

    The following code reads out the rgb from ID416, and should set 418 to that.

    But it makes 418 unresponsive

     

    local colors = api.get("/devices/416")

    fibaro.debug("colors: " , colors.properties.color)

    fibaro.call(418, "setColor", colors)

     

    option 2

     

    I added the lightstrip in the Huemain quickapp

    That gives a child device with ID  421 controlled with the quickapp.

    The same code, only then i call 421 gives an error.

     

    local colors = api.get("/devices/416")

    fibaro.debug("colors: " , colors.properties.color)

    fibaro.call(421, "setColor", colors)

     

    [29.07.2022] [09:48:22] [ERROR] [QA_HUE_MAIN_139]: [ERROR] Error in fibaro.setTimeout: ./include/HueTools.lua:25: attempt to perform arithmetic on a nil value (local 'a4')

     

    I think i need @petrkl12 for that

     

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Well i found out that for the Huemain quickapp i need:

     

    fibaro.call(139, "HueCommands", json.encode{type='Hue', action='colorRGB', deviceID=421, colorR=10, colorG=200, colorB=100, value=100})

     

    That should set the color. And this actually works.

     

    So, next up. Make a variable that reads out: local colors = api.get("/devices/416")

    And sets the digits for colorR colorG and colorB

     

     

     

     

    Edited by ppeterr
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • A few days later ?

     

    local colors = api.get("/devices/416")
     
    fibaro.debug("colors: " , colors.properties.color)
    fibaro.call(139, "HueCommands", json.encode{type='Hue', action='colorRGB', deviceID=421, colorR=colors[1], colorG=colors[2], colorB=colors[3]})

     

     

    [31.07.2022] [12:27:18] [DEBUG] [COLORS: ]: 222,232,255,0

    [31.07.2022] [12:27:18] [DEBUG] [QA_HUE_MAIN_139]: [L] HueCommands args={"action":"colorRGB","deviceID":421,"type":"Hue"}

    [31.07.2022] [12:27:18] [ERROR] [QA_HUE_MAIN_139]: [ERROR] Error in fibaro.setTimeout: ./include/main.lua:90: attempt to perform arithmetic on a nil value (local 'aD')

    Link to comment
    Share on other sites

    • 0

    The variable colors now contains all device properties. I changed that a bit. 
     

    I am not into encode and decode that much. Mostly I do some trail and error. Maybe someone else can help you with that. You are almost there, maybe this will help. 
     

    local deviceproperties = api.get("/devices/416")

    local colors = {}

    colors = deviceproperties.properties.color

     

    fibaro.debug("colors: " , colors.properties.color)

    fibaro.call(139, "HueCommands", json.encode{type='Hue', action='colorRGB', deviceID=421, colorR=colors[1], colorG=colors[2], colorB=colors[3]})

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I stripped it a bit down, since it gives an error.

     

    local deviceproperties = api.get("/devices/416")
    colors = deviceproperties.properties.color
    fibaro.debug("colors: " , colors.properties.color)

     

    [31.07.2022] [13:50:49] [ERROR] [SCENE101]: (load):4: attempt to index a nil value (field 'properties')

    Link to comment
    Share on other sites

    • 0

    Loose the debug line or change it from

     

    fibaro.debug("colors: " , colors.properties.color)

     

    to

     

    fibaro.debug("colors: " , colors)

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • That results in an error for the Huemain qa. 

    Time for some f1, and max action now :) thanks eddy.

     

    local deviceproperties = api.get("/devices/416")
    colors = deviceproperties.properties.color
    fibaro.debug("colors: " , colors)fibaro.call(139, "HueCommands", json.encode{type='Hue', action='colorRGB', deviceID=421, colorR=colors[1], colorG=colors[2], colorB=colors[3], value=100})
     
     
    [31.07.2022] [14:34:23] [DEBUG] [QA_HUE_MAIN_139]: [L] HueCommands args={"value":100,"action":"colorRGB","deviceID":421,"type":"Hue"}
    [31.07.2022] [14:34:23] [ERROR] [QA_HUE_MAIN_139]: [ERROR] Error in fibaro.setTimeout: ./include/HueTools.lua:25: attempt to perform arithmetic on a nil value (local 'a4')
     
    Link to comment
    Share on other sites

    • 0
    3 hours ago, ppeterr said:

    Time for some f1, and max action now :) thanks eddy.


    Max did the impossible, Hungaro Ring impossible to takeover. No more Micky Mouse Circuit. 

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