Skip to content

Commit ce4156c

Browse files
committed
add emit_event_if_latest_state_missing check code
1 parent b15424e commit ce4156c

File tree

1 file changed

+4
-6
lines changed
  • drivers/SmartThings/zigbee-switch/src/aqara-light

1 file changed

+4
-6
lines changed

drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ local function device_added(driver, device, event)
4646

4747
local value = { minimum = 2700, maximum = 6000 }
4848
if device:get_model() == "lumi.light.cwacn1" then
49-
value = { minimum = 2700, maximum = 6500 }
49+
value.maximum = 6500
5050
end
5151
emit_event_if_latest_state_missing(device, "main", capabilities.colorTemperature, capabilities.colorTemperature.colorTemperatureRange.NAME, capabilities.colorTemperature.colorTemperatureRange(value))
5252
end
@@ -68,13 +68,11 @@ local function set_level_handler(driver, device, cmd)
6868
end
6969

7070
local function init(self, device)
71-
local min = 2700
72-
local max = 6000
73-
71+
local value = { minimum = 2700, maximum = 6000 }
7472
if device:get_model() == "lumi.light.cwacn1" then
75-
max = 6500
73+
value.maximum = 6500
7674
end
77-
device:emit_event(capabilities.colorTemperature.colorTemperatureRange({ minimum = min, maximum = max }))
75+
emit_event_if_latest_state_missing(device, "main", capabilities.colorTemperature, capabilities.colorTemperature.colorTemperatureRange.NAME, capabilities.colorTemperature.colorTemperatureRange(value))
7876
end
7977

8078
local aqara_light_handler = {

0 commit comments

Comments
 (0)