Skip to content

Commit

Permalink
Fixed the intermediate level reported during device dimming
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongming6 committed Feb 21, 2024
1 parent ad2d4cd commit 2ee8c40
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local clusters = require "st.zigbee.zcl.clusters"
local cluster_base = require "st.zigbee.cluster_base"
local data_types = require "st.zigbee.data_types"
local capabilities = require "st.capabilities"

local OnOff = clusters.OnOff
local Level = clusters.Level
Expand Down Expand Up @@ -44,12 +45,24 @@ local function device_added(driver, device, event)
device:send(Level.attributes.OffTransitionTime:write(device, 0))
end

local function set_level_handler(driver, device, cmd)
local level = math.floor(cmd.args.level / 100.0 * 254)
local dimming_rate = 0x0000

device:send(Level.commands.MoveToLevelWithOnOff(device, level, dimming_rate))
end

local aqara_light_handler = {
NAME = "Aqara Light Handler",
lifecycle_handlers = {
added = device_added,
doConfigure = do_configure
},
capability_handlers = {
[capabilities.switchLevel.ID] = {
[capabilities.switchLevel.commands.setLevel.NAME] = set_level_handler
}
},
can_handle = is_aqara_products
}

Expand Down

0 comments on commit 2ee8c40

Please sign in to comment.