|
492 | 492 |
|
493 | 493 | local function device_init(driver, device) |
494 | 494 | if device:get_field(SUPPORTED_COMPONENT_CAPABILITIES) then |
495 | | - -- assume that device is using a modular profile, override supports_capability_by_id |
496 | | - -- library function to utilize optional capabilities |
497 | | - device:extend_device("supports_capability_by_id", supports_capability_by_id_modular) |
| 495 | + if version.api >= 15 and version.rpc >= 9 then |
| 496 | + -- the device used this modular profile workaround on 0.57 FW but no longer requires this table with >=0.58 FW |
| 497 | + device:set_field(SUPPORTED_COMPONENT_CAPABILITIES, nil) |
| 498 | + else |
| 499 | + -- assume that device is using a modular profile on 0.57 FW, override supports_capability_by_id |
| 500 | + -- library function to utilize optional capabilities |
| 501 | + device:extend_device("supports_capability_by_id", supports_capability_by_id_modular) |
| 502 | + end |
498 | 503 | end |
499 | 504 | device:subscribe() |
500 | 505 | device:set_component_to_endpoint_fn(component_to_endpoint) |
@@ -985,14 +990,18 @@ local function match_modular_profile_air_purifer(driver, device) |
985 | 990 |
|
986 | 991 | device:try_update_metadata({profile = profile_name, optional_component_capabilities = optional_supported_component_capabilities}) |
987 | 992 |
|
988 | | - -- add mandatory capabilities for subscription |
989 | | - local total_supported_capabilities = optional_supported_component_capabilities |
990 | | - table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.airPurifierFanMode.ID) |
991 | | - table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.fanSpeedPercent.ID) |
992 | | - table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.refresh.ID) |
993 | | - table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.firmwareUpdate.ID) |
| 993 | + -- earlier modular profile gating (min api v14, rpc 8) ensures we are running >= 0.57 FW. |
| 994 | + -- This gating specifies a workaround required only for 0.57 FW, which is not needed for 0.58 and higher. |
| 995 | + if version.api < 15 or version.rpc < 9 then |
| 996 | + -- add mandatory capabilities for subscription |
| 997 | + local total_supported_capabilities = optional_supported_component_capabilities |
| 998 | + table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.airPurifierFanMode.ID) |
| 999 | + table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.fanSpeedPercent.ID) |
| 1000 | + table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.refresh.ID) |
| 1001 | + table.insert(total_supported_capabilities[MAIN_COMPONENT_IDX][CAPABILITIES_LIST_IDX], capabilities.firmwareUpdate.ID) |
994 | 1002 |
|
995 | | - device:set_field(SUPPORTED_COMPONENT_CAPABILITIES, total_supported_capabilities, { persist = true }) |
| 1003 | + device:set_field(SUPPORTED_COMPONENT_CAPABILITIES, total_supported_capabilities, { persist = true }) |
| 1004 | + end |
996 | 1005 | end |
997 | 1006 |
|
998 | 1007 | local function match_modular_profile_thermostat(driver, device) |
@@ -1035,14 +1044,18 @@ local function match_modular_profile_thermostat(driver, device) |
1035 | 1044 | table.insert(optional_supported_component_capabilities, {"main", main_component_capabilities}) |
1036 | 1045 | device:try_update_metadata({profile = profile_name, optional_component_capabilities = optional_supported_component_capabilities}) |
1037 | 1046 |
|
1038 | | - -- add mandatory capabilities for subscription |
1039 | | - local total_supported_capabilities = optional_supported_component_capabilities |
1040 | | - table.insert(main_component_capabilities, capabilities.thermostatMode.ID) |
1041 | | - table.insert(main_component_capabilities, capabilities.temperatureMeasurement.ID) |
1042 | | - table.insert(main_component_capabilities, capabilities.refresh.ID) |
1043 | | - table.insert(main_component_capabilities, capabilities.firmwareUpdate.ID) |
| 1047 | + -- earlier modular profile gating (min api v14, rpc 8) ensures we are running >= 0.57 FW. |
| 1048 | + -- This gating specifies a workaround required only for 0.57 FW, which is not needed for 0.58 and higher. |
| 1049 | + if version.api < 15 or version.rpc < 9 then |
| 1050 | + -- add mandatory capabilities for subscription |
| 1051 | + local total_supported_capabilities = optional_supported_component_capabilities |
| 1052 | + table.insert(main_component_capabilities, capabilities.thermostatMode.ID) |
| 1053 | + table.insert(main_component_capabilities, capabilities.temperatureMeasurement.ID) |
| 1054 | + table.insert(main_component_capabilities, capabilities.refresh.ID) |
| 1055 | + table.insert(main_component_capabilities, capabilities.firmwareUpdate.ID) |
1044 | 1056 |
|
1045 | | - device:set_field(SUPPORTED_COMPONENT_CAPABILITIES, total_supported_capabilities, { persist = true }) |
| 1057 | + device:set_field(SUPPORTED_COMPONENT_CAPABILITIES, total_supported_capabilities, { persist = true }) |
| 1058 | + end |
1046 | 1059 | end |
1047 | 1060 |
|
1048 | 1061 | local function match_modular_profile_room_ac(driver, device) |
@@ -1086,15 +1099,19 @@ local function match_modular_profile_room_ac(driver, device) |
1086 | 1099 | table.insert(optional_supported_component_capabilities, {"main", main_component_capabilities}) |
1087 | 1100 | device:try_update_metadata({profile = profile_name, optional_component_capabilities = optional_supported_component_capabilities}) |
1088 | 1101 |
|
1089 | | - -- add mandatory capabilities for subscription |
1090 | | - local total_supported_capabilities = optional_supported_component_capabilities |
1091 | | - table.insert(main_component_capabilities, capabilities.switch.ID) |
1092 | | - table.insert(main_component_capabilities, capabilities.temperatureMeasurement.ID) |
1093 | | - table.insert(main_component_capabilities, capabilities.thermostatMode.ID) |
1094 | | - table.insert(main_component_capabilities, capabilities.refresh.ID) |
1095 | | - table.insert(main_component_capabilities, capabilities.firmwareUpdate.ID) |
| 1102 | + -- earlier modular profile gating (min api v14, rpc 8) ensures we are running >= 0.57 FW. |
| 1103 | + -- This gating specifies a workaround required only for 0.57 FW, which is not needed for 0.58 and higher. |
| 1104 | + if version.api < 15 or version.rpc < 9 then |
| 1105 | + -- add mandatory capabilities for subscription |
| 1106 | + local total_supported_capabilities = optional_supported_component_capabilities |
| 1107 | + table.insert(main_component_capabilities, capabilities.switch.ID) |
| 1108 | + table.insert(main_component_capabilities, capabilities.temperatureMeasurement.ID) |
| 1109 | + table.insert(main_component_capabilities, capabilities.thermostatMode.ID) |
| 1110 | + table.insert(main_component_capabilities, capabilities.refresh.ID) |
| 1111 | + table.insert(main_component_capabilities, capabilities.firmwareUpdate.ID) |
1096 | 1112 |
|
1097 | | - device:set_field(SUPPORTED_COMPONENT_CAPABILITIES, total_supported_capabilities, { persist = true }) |
| 1113 | + device:set_field(SUPPORTED_COMPONENT_CAPABILITIES, total_supported_capabilities, { persist = true }) |
| 1114 | + end |
1098 | 1115 | end |
1099 | 1116 |
|
1100 | 1117 | local function match_modular_profile(driver, device, device_type) |
|
0 commit comments