Using Xiaomi Cube for dimming LED strip.  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using Xiaomi Cube for dimming LED strip.

Post by waaren »

Mayki wrote: Friday 02 August 2019 16:01 I need help with the script for dimming LED strip using Xiaomi Cube. Cube has states Rotate Left and Rotate Right. I wrote this script, but it doesn't work. Can you help me?
Can you try this ?

Code: Select all

return {
    on = {
        devices = {
            'Zigbee - Cube'
        }
    },
    execute = function(domoticz, device)
        local HW = domoticz.devices('Hyperion Wall - RGB Light')
        domoticz.log('Current dim level of ' .. HW.name .. ' = ' .. HW.level .. ' ; Cube action = ' .. device.state)
        if device.state == 'Rotate Right' then
            HW.dimTo(math.max((HW.level-10),0))
        elseif device.state == 'Rotate Left' then
            HW.dimTo(math.min((HW.level+10),100))
        end
    end    
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest