@@ -48,11 +48,7 @@ function AttributeHandlers.system_mode_handler(driver, device, ib, response)
4848 return
4949 end
5050
51- local supported_modes = device :get_latest_state (
52- device :endpoint_to_component (ib .endpoint_id ),
53- capabilities .thermostatMode .ID ,
54- capabilities .thermostatMode .supportedThermostatModes .NAME
55- ) or {}
51+ local supported_modes = device :get_latest_state (device :endpoint_to_component (ib .endpoint_id ), capabilities .thermostatMode .ID , capabilities .thermostatMode .supportedThermostatModes .NAME ) or {}
5652 -- check that the given mode was in the supported modes list
5753 if thermostat_utils .tbl_contains (supported_modes , fields .THERMOSTAT_MODE_MAP [ib .data .value ].NAME ) then
5854 device :emit_event_for_endpoint (ib .endpoint_id , fields .THERMOSTAT_MODE_MAP [ib .data .value ]())
@@ -329,19 +325,19 @@ function AttributeHandlers.fan_mode_handler(driver, device, ib, response)
329325end
330326
331327function AttributeHandlers .fan_mode_sequence_handler (driver , device , ib , response )
332- local supported_fan_modes , supported_fan_modes_attribute
328+ local supportedFanModes , supported_fan_modes_attribute
333329 if ib .data .value == clusters .FanControl .attributes .FanModeSequence .OFF_LOW_MED_HIGH then
334- supported_fan_modes = { " off" , " low" , " medium" , " high" }
330+ supportedFanModes = { " off" , " low" , " medium" , " high" }
335331 elseif ib .data .value == clusters .FanControl .attributes .FanModeSequence .OFF_LOW_HIGH then
336- supported_fan_modes = { " off" , " low" , " high" }
332+ supportedFanModes = { " off" , " low" , " high" }
337333 elseif ib .data .value == clusters .FanControl .attributes .FanModeSequence .OFF_LOW_MED_HIGH_AUTO then
338- supported_fan_modes = { " off" , " low" , " medium" , " high" , " auto" }
334+ supportedFanModes = { " off" , " low" , " medium" , " high" , " auto" }
339335 elseif ib .data .value == clusters .FanControl .attributes .FanModeSequence .OFF_LOW_HIGH_AUTO then
340- supported_fan_modes = { " off" , " low" , " high" , " auto" }
336+ supportedFanModes = { " off" , " low" , " high" , " auto" }
341337 elseif ib .data .value == clusters .FanControl .attributes .FanModeSequence .OFF_HIGH_AUTO then
342- supported_fan_modes = { " off" , " high" , " auto" }
338+ supportedFanModes = { " off" , " high" , " auto" }
343339 else
344- supported_fan_modes = { " off" , " high" }
340+ supportedFanModes = { " off" , " high" }
345341 end
346342
347343 if device :supports_capability_by_id (capabilities .airPurifierFanMode .ID ) then
@@ -353,22 +349,16 @@ function AttributeHandlers.fan_mode_sequence_handler(driver, device, ib, respons
353349 -- Our thermostat fan mode control is not granular enough to handle all of the supported modes
354350 if ib .data .value >= clusters .FanControl .attributes .FanModeSequence .OFF_LOW_MED_HIGH_AUTO and
355351 ib .data .value <= clusters .FanControl .attributes .FanModeSequence .OFF_ON_AUTO then
356- supported_fan_modes = { " auto" , " on" }
352+ supportedFanModes = { " auto" , " on" }
357353 else
358- supported_fan_modes = { " on" }
354+ supportedFanModes = { " on" }
359355 end
360356 else
361357 supported_fan_modes_attribute = capabilities .fanMode .supportedFanModes
362358 end
363359
364- -- remove 'off' as a supported fan mode for thermostat device types
365- if thermostat_utils .get_device_type (device ) == fields .THERMOSTAT_DEVICE_TYPE_ID and
366- device :supports_capability_by_id (capabilities .fanMode .ID ) then
367- -- per the definitions set above, the first index always contains "off"
368- table.remove (supported_fan_modes , 1 )
369- end
370-
371- device :emit_event_for_endpoint (ib .endpoint_id , supported_fan_modes_attribute (supported_fan_modes , {visibility = {displayed = false }}))
360+ local event = supported_fan_modes_attribute (supportedFanModes , {visibility = {displayed = false }})
361+ device :emit_event_for_endpoint (ib .endpoint_id , event )
372362end
373363
374364function AttributeHandlers .percent_current_handler (driver , device , ib , response )
0 commit comments