Hue Dimmer actions as separate devices

Moderator: leecollings

Post Reply
WvdM78
Posts: 9
Joined: Wednesday 01 April 2020 14:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: The Netherlands
Contact:

Hue Dimmer actions as separate devices

Post by WvdM78 »

I used to have the hue dimmer from Philips working as a switch with pulldown menu and a DzVents script. The device was added via the zigbee2mqtt module and the Python script.

Since the 2023.1 update I am busy migrating all my zigbee devices via the build-in zigbee2mqtt support. So far so good, but now I have separate devices (as a Push On button) for the several buttons of the Hue dimmer switch. I have tried to make it working again by changing the DzVents script but a cannot get it working. When pressed it updates with an 'Off' signal (all buttons). To check whether it is a recent Off I added lastupdate.SecondsAgo:

Code: Select all

return {
    on = {
        devices =
        {
            'Hue Dimmer1 action_on_press', 'Hue Dimmer1 action_off_press'-- change to name of your Hue selector / dimmerswitch
        }
    },

    execute = function(dz, device)

        deviceToSwitch1 = dz.devices('Woonkamer lamp dressoir') 
        deviceToSwitch2 = dz.devices('Woonkamer leeslamp 1')
        deviceToSwitch3 = dz.devices('Woonkamer staande lamp 1')
        deviceToSwitch4 = dz.devices('Woonkamer staande lamp 2')
  
        Dimmer_onpress = dz.devices('Hue Dimmer1 action_on_press')
        Dimmer_offpress = dz.devices('Hue Dimmer1 action_off_press')
        Dimmer_uppress = dz.devices('Hue Dimmer1 action_up_press')
        Dimmer_downpress = dz.devices('Hue Dimmer1 action_down_press')
        Dimmer_onpress_hold = dz.devices('Hue Dimmer1 action_on_hold')
        dimvalue = deviceToSwitch2.level
        Dimmer_lasttime = tonumber(Dimmer_onpress_hold.lastUpdate.secondsAgo)
        
        dz.log('State dimmer press on:' .. Dimmer_onpress.state .. 'secondsago: ' .. Dimmer_onpress_hold.lastUpdate.secondsAgo )
        dz.log('State dimmer press off:' .. Dimmer_offpress.state .. 'secondsago: ' .. Dimmer_offpress.lastUpdate.secondsAgo )        

        if Dimmer_onpress.state == 'Off' and Dimmer_lasttime < 300 then
            deviceToSwitch1.switchOn()
            deviceToSwitch2.switchOn()
        dz.log('Devices 1+2 started')
        end
        
         if Dimmer_onpress_hold.state == 'Off' and Dimmer_onpress_hold.lastUpdate.secondsAgo < 300  then 
            deviceToSwitch3.switchOn()
            deviceToSwitch4.switchOn()
        dz.log('Devices 3+4 started ')

        end
        
        if Dimmer_offpress.state == 'Off' and Dimmer_offpress.lastUpdate.secondsAgo < 300 then 
            deviceToSwitch1.switchOff()
            deviceToSwitch2.switchOff()
            deviceToSwitch3.switchOff()
            deviceToSwitch4.switchOff()
            dz.log('All devices switched off')
          end
        
if  Dimmer_uppress == 'Off' then 
        dimvalue = dimvalue + 10
elseif  Dimmer_downpress == 'Off' then 
        dimvalue = dimvalue - 10
 
if dimvalue < 5 then 
dimvalue = 5
end
if dimvalue > 100 then 
dimvalue = 100    
end

deviceDimmer.level = dimvalue

deviceToSwitch1.dimTo(dimvalue)
deviceToSwitch2.dimTo(dimvalue)
end


end


}
The lastupdate.secondsago doesn't give logical reading (after press it states >50 s as last update).

Is it possible to add the Hue dimmer as a single device with pulldown menu or does anyone know how to get this working?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest