From 3f220973cf091ffb68e2a90ebd10f391971ada82 Mon Sep 17 00:00:00 2001 From: Junyang Date: Sat, 26 Aug 2023 11:10:50 +0200 Subject: [PATCH] fix ha 2023.8 mqtt entity naming warning (#126) --- app/sensors/Alarm.py | 2 +- app/sensors/Boiler.py | 14 ++++++++------ app/sensors/Cover.py | 2 +- app/sensors/Light.py | 2 +- app/sensors/Sensor.py | 4 +--- app/sensors/ShHvac.py | 4 ++-- app/sensors/Switch.py | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/sensors/Alarm.py b/app/sensors/Alarm.py index 463f9de..66d2c84 100644 --- a/app/sensors/Alarm.py +++ b/app/sensors/Alarm.py @@ -35,7 +35,7 @@ async def setup(self): 'identifiers': self.id } self.config = { - 'name': self.name, + 'name': None, # set an MQTT entity's name to None to mark it as the main feature of a device 'unique_id': self.id, 'device': self.device, 'command_topic': alarm_command_topic.format(id=self.id), diff --git a/app/sensors/Boiler.py b/app/sensors/Boiler.py index db7bb9d..0c78c65 100644 --- a/app/sensors/Boiler.py +++ b/app/sensors/Boiler.py @@ -15,8 +15,8 @@ preset_mode_command_topic = "climate/tydom/{id}/set_thermicLevel" out_temperature_state_topic = "sensor/tydom/{id}/temperature" -#temperature = current_temperature_topic -#setpoint= temperature_command_topic +# temperature = current_temperature_topic +# setpoint= temperature_command_topic # temperature_unit=C # "modes": ["STOP", "ANTI-FROST","ECO", "COMFORT"], ##################################### @@ -27,8 +27,8 @@ # thermicLevel STOP ECO ... # auhorisation HEATING # hvacMode NORMAL None (si off) -#timeDelay : 0 -#tempoOn : False +# timeDelay : 0 +# tempoOn : False # antifrost True False # openingdetected False # presenceDetected False @@ -78,7 +78,8 @@ async def setup(self): # Check if device is a heater with thermostat sensor else: - self.config['name'] = self.name + # set an MQTT entity's name to None to mark it as the main feature of a device + self.config['name'] = None self.device['model'] = 'Climate' self.config_topic = climate_config_topic.format(id=self.id) self.config['temperature_command_topic'] = temperature_command_topic.format( @@ -153,5 +154,6 @@ async def put_hvac_mode(tydom_client, device_id, boiler_id, set_hvac_mode): @staticmethod async def put_thermic_level(tydom_client, device_id, boiler_id, set_thermic_level): if not (set_thermic_level == ''): - logger.info("Set thermic level (device=%s, level=%s)", device_id, set_thermic_level) + logger.info("Set thermic level (device=%s, level=%s)", + device_id, set_thermic_level) await tydom_client.put_devices_data(device_id, boiler_id, 'thermicLevel', set_thermic_level) diff --git a/app/sensors/Cover.py b/app/sensors/Cover.py index 09202da..b360761 100644 --- a/app/sensors/Cover.py +++ b/app/sensors/Cover.py @@ -40,7 +40,7 @@ async def setup(self): 'identifiers': self.id} self.config_topic = cover_config_topic.format(id=self.id) self.config = { - 'name': self.name, + 'name': None, # set an MQTT entity's name to None to mark it as the main feature of a device 'unique_id': self.id, 'command_topic': cover_command_topic.format( id=self.id), diff --git a/app/sensors/Light.py b/app/sensors/Light.py index 0ea7d48..91e8e30 100644 --- a/app/sensors/Light.py +++ b/app/sensors/Light.py @@ -37,7 +37,7 @@ async def setup(self): 'identifiers': self.id} self.config_topic = light_config_topic.format(id=self.id) self.config = { - 'name': self.name, + 'name': None, # set an MQTT entity's name to None to mark it as the main feature of a device 'brightness_scale': 100, 'unique_id': self.id, 'optimistic': True, diff --git a/app/sensors/Sensor.py b/app/sensors/Sensor.py index 6df3804..ae470f3 100644 --- a/app/sensors/Sensor.py +++ b/app/sensors/Sensor.py @@ -27,7 +27,6 @@ def __init__(self, elem_name, tydom_attributes_payload, mqtt=None): # extracted from json, but it will make sensor not in payload to be # considered offline.... self.parent_device_id = str(tydom_attributes_payload['id']) - self.parent_device_name = str(tydom_attributes_payload['name']) self.id = elem_name + '_tydom_' + str(tydom_attributes_payload['id']) self.name = elem_name if 'device_class' in tydom_attributes_payload.keys(): @@ -106,12 +105,11 @@ def __init__(self, elem_name, tydom_attributes_payload, mqtt=None): async def setup(self): self.device = { 'manufacturer': 'Delta Dore', - 'name': self.parent_device_name, 'identifiers': self.parent_device_id} self.config_sensor_topic = sensor_config_topic.format(id=self.id) - self.config = {'name': self.parent_device_name + ' ' + self.name, + self.config = {'name': self.name, 'unique_id': self.id} try: self.config['device_class'] = self.device_class diff --git a/app/sensors/ShHvac.py b/app/sensors/ShHvac.py index 71e1693..ef9e0ec 100644 --- a/app/sensors/ShHvac.py +++ b/app/sensors/ShHvac.py @@ -43,7 +43,7 @@ async def setup(self): self.config_topic = thermostat_config_topic.format(id=self.id) self.config = { - 'name': self.name, + 'name': None, # set an MQTT entity's name to None to mark it as the main feature of a device 'unique_id': self.id, 'device': self.device, 'temperature_unit ': 'C', @@ -64,7 +64,7 @@ async def setup(self): self.switch_config_topic = thermpstat_boost_config_topic.format( id=self.id) self.switch_config = { - 'name': self.name + ' Boost', + 'name': 'Boost', 'unique_id': self.id + '_boost', 'device': self.device, 'payload_on': 'ON', diff --git a/app/sensors/Switch.py b/app/sensors/Switch.py index 8371f44..7996f37 100644 --- a/app/sensors/Switch.py +++ b/app/sensors/Switch.py @@ -39,7 +39,7 @@ async def setup(self): 'identifiers': self.id} self.config_topic = switch_config_topic.format(id=self.id) self.config = { - 'name': self.name, + 'name': None, # set an MQTT entity's name to None to mark it as the main feature of a device 'unique_id': self.id, 'command_topic': switch_command_topic.format( id=self.id),