IKEA Styrbar script

Moderator: leecollings

Post Reply
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

IKEA Styrbar script

Post by DewGew »

I want to share my zigbee IKEA styrbar dimmer script. I use zigbee2MQTT and zigbee2MQTT plugin v3.2.0.
I tryed with MQTT AD but I got alot of on/off devices instead of 1 selector switch.

Code: Select all

-- Settings --
local dimmerIdx = 123 -- change to idx of your IKEA selector / dimmerswitch
local deviceIdx = 45  -- change to idx of you light/switch
local delta = 20      -- level steps for brightness
--
return
{
    on =
    {
        devices =
        {
            dimmerIdx,
        }
    },
    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'IKEA Styrbar / selector',
    },

--[[
    ** IKEA Styrbar Levelnames **
    'on' 
    'off'
    'brightness_move_up'
    'brightness_move_down'
    'brightness_stop'
    'arrow_left_click'
    'arrow_right_click'
    'arrow_left_hold'
    'arrow_right_hold'
    'arrow_left_release'
    'arrow_right_release'
    'Off'
]]--

    execute = function(dz, styrbar)

        local deviceToSwitch = dz.devices(deviceIdx)
        
        dz.log('Device ' .. styrbar.name .. ' updated. Last level was ' .. styrbar.lastLevel .. '; new level is ' .. styrbar.level .. ' (' .. styrbar.state .. ')', dz.LOG_DEBUG)
        
        dimlevel = deviceToSwitch.level

        if styrbar.state == 'on' then
            deviceToSwitch.switchOn()
        end
        if styrbar.state == 'brightness_move_up' then
            deviceToSwitch.dimTo(dimlevel + delta)
        end
        if styrbar.state == 'off' then 
            deviceToSwitch.switchOff()
        end
        if styrbar.state == 'brightness_move_down' then
            deviceToSwitch.dimTo(dimlevel-delta)
        end
    end
}
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: IKEA Styrbar script

Post by waltervl »

Something similar should also work with MQTT AD. You only have to trigger on all those button devices instead of the levels.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: IKEA Styrbar script

Post by DewGew »

waltervl wrote: Thursday 14 March 2024 8:10 Something similar should also work with MQTT AD. You only have to trigger on all those button devices instead of the levels.
Problem is that I have to add 11 dimmerIdx instead of 1
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
BazemanKM
Posts: 33
Joined: Wednesday 22 July 2015 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: IKEA Styrbar script

Post by BazemanKM »

User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: IKEA Styrbar script

Post by waltervl »

DewGew wrote: Friday 15 March 2024 18:21
waltervl wrote: Thursday 14 March 2024 8:10 Something similar should also work with MQTT AD. You only have to trigger on all those button devices instead of the levels.
Problem is that I have to add 11 dimmerIdx instead of 1
To add 11* IDX or 11* levelname in the script seems not a lot of difference....
Only saying that for the users of MQTT AD that that should not be a deal breaker to change to the plugin. Although I like the plugin way of working better too.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest