From d6f9f861e1412741d8c4bdf417f8fc5d70455640 Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Wed, 25 Oct 2023 18:59:43 +0200 Subject: [PATCH] prevent using the new tuyaTS0601 path, when the model do not provide any datapoint definition --- Modules/paramDevice.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/Modules/paramDevice.py b/Modules/paramDevice.py index d9ad3ba38..0ed5db5de 100644 --- a/Modules/paramDevice.py +++ b/Modules/paramDevice.py @@ -74,7 +74,8 @@ tuya_trv_set_opened_window_temp, tuya_trv_thermostat_sensor_mode, tuya_trv_window_detection) -from Modules.tuyaTS0601 import TS0601_COMMANDS, ts0601_actuator +from Modules.tuyaTS0601 import (TS0601_COMMANDS, ts0601_actuator, + ts0601_extract_data_point_infos) def Ballast_max_level(self, nwkid, max_level): @@ -308,20 +309,14 @@ def ias_sensitivity(self, nwkid, sensitivity): } def sanity_check_of_param(self, NwkId): - if "Param" not in self.ListOfDevices[NwkId]: - return - - for param in self.ListOfDevices[NwkId]["Param"]: - if param in TS0601_COMMANDS: - # We a Tuya TS0601 devices - value = self.ListOfDevices[NwkId]["Param"][param] - ts0601_actuator( self, NwkId, param, value) - continue - - if param in DEVICE_PARAMETERS: - func = DEVICE_PARAMETERS[param] - value = self.ListOfDevices[NwkId]["Param"][param] - func(self, NwkId, value) + param_data = self.ListOfDevices.get(NwkId, {}).get("Param", {}) + model_name = self.ListOfDevices.get(NwkId, {}).get("Model", "") + + for param, value in param_data.items(): + if ts0601_extract_data_point_infos(self, model_name) and param in TS0601_COMMANDS: + ts0601_actuator(self, NwkId, param, value) + elif param in DEVICE_PARAMETERS: + DEVICE_PARAMETERS[param](self, NwkId, value) def get_device_config_param( self, NwkId, config_parameter):