Skip to content

Commit b13bde7

Browse files
committed
add emit_event_if_latest_state_missing check code
1 parent c92c0cc commit b13bde7

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
@@ -49,7 +49,7 @@ local function device_added(driver, device, event)
4949

5050
local value = { minimum = 2700, maximum = 6000 }
5151
if device:get_model() == "lumi.light.cwacn1" then
52-
value = { minimum = 2700, maximum = 6500 }
52+
value.maximum = 6500
5353
end
5454
emit_event_if_latest_state_missing(device, "main", capabilities.colorTemperature, capabilities.colorTemperature.colorTemperatureRange.NAME, capabilities.colorTemperature.colorTemperatureRange(value))
5555
end
@@ -71,13 +71,11 @@ local function set_level_handler(driver, device, cmd)
7171
end
7272

7373
local function init(self, device)
74-
local min = 2700
75-
local max = 6000
76-
74+
local value = { minimum = 2700, maximum = 6000 }
7775
if device:get_model() == "lumi.light.cwacn1" then
78-
max = 6500
76+
value.maximum = 6500
7977
end
80-
device:emit_event(capabilities.colorTemperature.colorTemperatureRange({ minimum = min, maximum = max }))
78+
emit_event_if_latest_state_missing(device, "main", capabilities.colorTemperature, capabilities.colorTemperature.colorTemperatureRange.NAME, capabilities.colorTemperature.colorTemperatureRange(value))
8179
end
8280

8381
local aqara_light_handler = {

0 commit comments

Comments
 (0)