Dimmer function

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

Post Reply
sschouten
Posts: 9
Joined: Thursday 23 April 2015 13:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Dimmer function

Post by sschouten »

Hello,


i have a ikea dimmer, connectd with zigbee to domoticz,

now i want to dim a ligth in domoticz, i cant find out how.

kind regards
Wous
Posts: 4
Joined: Friday 05 January 2018 9:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dimmer function

Post by Wous »

Same issue here. I've found several solutions, which can't compete the functionality of the hue bridge for example.
1st. Domoticz recognize the dimmer and gives the tradfi a selector switch. For each button you can give a json command. But for a dimmer, you want a relative dimlevel changed from the current position.
2nd. I've found a script which uses the lasting time of holding the button and uses that time for setting a dimlevel. Nice, but still not answering my need.
3rd. I've found a script for the hue dimmer switch https://domoticz.com/forum/viewtopic.php?f=59&t=33589. Because I haven't got a good interaction between Zigbee2Mqtt and the dimmer switch I haven't been able to evaluate this script.

Finally I am doubting using Domoticz to manage my Zigbee devices....
User avatar
waltervl
Posts: 5154
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Dimmer function

Post by waltervl »

I have no Ikea dimmer but a aqara switch with single click, double click, long click and 4 click function.
I switch a dimmable bulb with a long click by first getting the current dimlevel with dz.devices(id).level and then add 25 percent.
A double click always goes to dimlevel 25%
a 4-click always goes to 100%
See my dzVents script below.

Code: Select all

return {
   on = { devices = { 102 }},  -- Switch
   execute = function(dz, device )
        EKDimlevel = 0
        if dz.devices(102).state == 'Click' then -- 1 Click
            dz.devices(93).toggleSwitch()    -- Zigate Lamp
        end
        if dz.devices(102).state == 'Double Click' then -- 2 Click
            dz.devices(93).dimTo(25)     -- Zigate Lamp
        end
        if dz.devices(102).state == 'Long Click' then -- Long Click
            EKDimlevel = dz.devices(93).level
            dz.devices(93).dimTo(EKDimlevel+25)     -- Zigate Lamp
        end
        if dz.devices(102).state == '4 Click' then -- 4 Click
            dz.devices(93).dimTo(100)    -- Zigate Lamp
        end 

   end
}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
klaasvaak
Posts: 5
Joined: Thursday 03 October 2019 16:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Dimmer function

Post by klaasvaak »

I created the following script for Hue selector switch, could be updated to ikea dimmer.
I'm an amateur in coding, so can be improved probably

Code: Select all

return {
	on = {
		devices = {
			503 --Hue selector switch
		}
	},
        --States selector switch:
        --  off-press
        --  off-press-double
        --  off-press-triple
        --  off-hold
        --  off-hold-release
        --  down-press
        --  down-press-double
        --  down-press-triple
        --  down-hold
        --  down-hold-release
        --  up-press
        --  up-press-double
        --  up-press-triple
        --  up-hold
        --  up-hold-release
        --  on-press
        --  on-press-double
        --  on-press-triple
        --  on-hold
        --  on-hold-release
    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'Philips switch',
    },
	
    execute = function(domoticz, device)
		     -- variables change settings
		     knopid = 503 -- id of the selector switch IMPORTANT! Also change @devices
		     lampl = 'keukengroep' -- lamp you want to control
		     delta = 33 -- percentage to increase / decrease lamp brightness
		     min = 1 -- minimal brightness
		     max = 100 -- maximum brightness
		     -- end vairables
		     lampdim = domoticz.devices(lampl).level
              if domoticz.devices(knopid).state == 'on-press' then
                     -- turn light on last state
                     domoticz.devices(lampl).switchOn()	      
              elseif domoticz.devices(knopid).state == 'up-press' then
                     -- turn light on to last state if off or increase brightness with delta
                     if domoticz.devices(lampl).state == 'Off'
                        then domoticz.devices(lampl).switchOn()
                        else domoticz.devices(lampl).dimTo(domoticz.devices(lampl).level + delta)
                     end
              elseif domoticz.devices(knopid).state == 'up-hold' or domoticz.devices(knopid).state == 'up-press-double' then
                     -- turn light on to max brightness
                     domoticz.devices(lampl).dimTo(max)
              elseif domoticz.devices(knopid).state == 'down-press' then
                     -- turn on to minimal if off or decrease brightness with delta
                     lampdim = lampdim - delta
                     if lampdim < min then
                        lampdim = min
                     end
                     domoticz.devices(lampl).dimTo(lampdim)
		      elseif domoticz.devices(knopid).state == 'down-hold' or domoticz.devices(knopid).state == 'down-press-double' then
                     -- decrease brightness to minimal
                     domoticz.devices(lampl).dimTo(min)  
		      elseif domoticz.devices(knopid).state == 'off-press' or domoticz.devices(knopid).state == 'off-hold' then
                     -- turn of light
                     domoticz.devices(lampl).dimTo(0)    
              end
	end
}
Zigbee2MQTT, LAUNCHXL-CC26X2R1
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest