Philips Hue lights, send "CT" Value

Moderator: leecollings

Post Reply
Sudden81
Posts: 8
Joined: Wednesday 08 February 2017 8:21
Target OS: -
Domoticz version:
Contact:

Philips Hue lights, send "CT" Value

Post by Sudden81 »

Hi all!

I manage to get almost what I wanted, with my newly added Philips Hue lights but I want to send "CT" Value I want one button to send something close to "CT":500 and something close to "CT":180

I want to put it right after: local switchLevel = 30

Is this possible in a simple way?

Code: Select all

local b = require("bakseeda")

local triggerSwitchS1       = 'Vardagsrum S1'
local triggerSwitchS2       = 'Vardagsrum S2'

local varScene              = 'S1_S2 mitt Vardagsrum 1'


commandArray = {}

-- s1 ON logic (MYS)
if (devicechanged[triggerSwitchS1] == 'On') then
    if (b.getVar(varScene) ~= 1) then
        -- turning ON
        
        local switchLight   = 'Vardagsrum'
        local switchLevel   = 30
        if (otherdevices_svalues[switchLight] ~= switchLevel) then 
            commandArray[switchLight] = 'Set Level '..switchLevel
        end
        
        b.setVar(varScene, 1, 0)
    else
        -- turning OFF
        local switchLight   = 'Vardagsrum'
        if (otherdevices_svalues[switchLight] ~= '0') then 
            commandArray[switchLight] = 'Set Level 0'
        end

        
        b.setVar(varScene, 0, 0)
    end
end
 
-- s1 OFF logic (STÄD)
if (devicechanged[triggerSwitchS1] == 'Off') then
    if (b.getVar(varScene) ~= 2) then
        -- turning ON
        
        local switchLight   = 'Hall'
        local switchLevel   = 100
        if (otherdevices_svalues[switchLight] ~= switchLevel) then 
            commandArray[switchLight] = 'Set Level '..switchLevel
        end
        
        local switchLight   = 'Vardagsrum'
        local switchLevel   = 100
        if (otherdevices_svalues[switchLight] ~= switchLevel) then 
            commandArray[switchLight] = 'Set Level '..switchLevel
        end
        
        local switchLight   = 'Köksbänk'
        if (otherdevices[switchLight] == 'Off') then 
            commandArray[switchLight] = 'On'
        end
        
        b.setVar(varScene, 2, 0)

    else
        -- turning OFF
        
        local switchLight   = 'Hall'
        if (otherdevices_svalues[switchLight] ~= '0') then 
            commandArray[switchLight] = 'Set Level 0'
        end
        
        local switchLight   = 'Köksbänk'
        if (otherdevices[switchLight] == 'On') then 
            commandArray[switchLight] = 'Off'
        end
        
        local switchLight   = 'Vardagsrum'
        if (otherdevices_svalues[switchLight] ~= '0') then 
            commandArray[switchLight] = 'Set Level 0'
        end
        
        b.setVar(varScene, 0, 0)
    end
end    

-- s2 ON logic (LÄS)
if (devicechanged[triggerSwitchS2] == 'On') then
    if (b.getVar(varScene) ~= 3) then
        -- turning ON
        
        local switchLight   = 'Vardagsrum'
        local switchLevel   = 100
        if (otherdevices_svalues[switchLight] ~= switchLevel) then 
            commandArray[switchLight] = 'Set Level '..switchLevel
        end
        
        b.setVar(varScene, 3, 0)

    else
        -- turning OFF
        
        local switchLight   = 'Vardagsrum'
        if (otherdevices_svalues[switchLight] ~= '0') then 
            commandArray[switchLight] = 'Set Level 0'
        end
        
        b.setVar(varScene, 0, 0)
    end
end

-- s2 OFF logic (SLÄCK)
if (devicechanged[triggerSwitchS2] == 'Off') then

        local switchLight   = 'Hall'
        if (otherdevices_svalues[switchLight] ~= '0') then 
            commandArray[switchLight] = 'Set Level 0'
        end
        
        local switchLight   = 'Köksbänk'
        if (otherdevices[switchLight] == 'On') then 
            commandArray[switchLight] = 'Off'
        end
        
        local switchLight   = 'Vardagsrum'
        if (otherdevices_svalues[switchLight] ~= '0') then 
            commandArray[switchLight] = 'Set Level 0'
        end
        
        b.setVar(varScene, 4, 0)
end  

return commandArray
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest