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
}