@@ -242,7 +242,9 @@ local function device_init(driver, device)
242242 local preset_position = device .preferences .presetPosition or DEFAULT_PRESET_LEVEL
243243 device :emit_event (capabilities .windowShadePreset .position (preset_position , {visibility = {displayed = false }}))
244244 end
245- device :subscribe ()
245+ if device .network_type ~= device_lib .NETWORK_TYPE_CHILD then
246+ device :subscribe ()
247+ end
246248end
247249
248250local function do_configure (driver , device )
@@ -298,8 +300,7 @@ local function handle_preset(driver, device, cmd)
298300end
299301
300302local function handle_set_preset (driver , device , cmd )
301- local endpoint_id = device :component_to_endpoint (cmd .component )
302- device :emit_event_for_endpoint (endpoint_id , capabilities .windowShadePreset .position (cmd .args .position ))
303+ device :emit_event (capabilities .windowShadePreset .position (cmd .args .position ))
303304end
304305
305306local function handle_close (driver , device , cmd )
399400local function target_position_lift_percent_100ths_handler (driver , device , ib , response )
400401 if type (ib .data .value ) == " number" then
401402 local target_lift_percent = 100 - math.floor (ib .data .value / 100 )
402- local latest_lift_percentage = device :get_latest_state (
403+ local state_device = find_child (device , ib .endpoint_id ) or device
404+ local latest_lift_percentage = state_device :get_latest_state (
403405 " main" ,
404406 capabilities .windowShadeLevel .ID ,
405407 capabilities .windowShadeLevel .shadeLevel .NAME
416418local function target_position_tilt_percent_100ths_handler (driver , device , ib , response )
417419 if type (ib .data .value ) == " number" then
418420 local target_tilt_percent = 100 - math.floor (ib .data .value / 100 )
419- local latest_tilt_percent = device :get_latest_state (
421+ local state_device = find_child (device , ib .endpoint_id ) or device
422+ local latest_tilt_percent = state_device :get_latest_state (
420423 " main" ,
421424 capabilities .windowShadeTiltLevel .ID ,
422425 capabilities .windowShadeTiltLevel .shadeTiltLevel .NAME
434437local function operational_status_handler (driver , device , ib , response )
435438 if not ib .data .value then return end
436439 local global_op_status = ib .data .value & clusters .WindowCovering .types .OperationalStatus .GLOBAL
437- local reverse = device .preferences .reverse
440+ local reverse = ( find_child ( device , ib . endpoint_id ) or device ) .preferences .reverse
438441 local windowShade = capabilities .windowShade .windowShade
439442 local status_event
440443 if global_op_status == OP_STATUS_BITMAP .idle then
0 commit comments