From 8d1c3ab7f56c52bfbc1c712dbbb2af9d447d0ae4 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 18 Aug 2023 17:41:26 +0200 Subject: [PATCH 1/2] Adapt naming to match Home Assistant has_entity_name --- hatasmota/fan.py | 2 +- hatasmota/sensor.py | 2 +- hatasmota/shutter.py | 2 +- hatasmota/status_sensor.py | 2 +- hatasmota/utils.py | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hatasmota/fan.py b/hatasmota/fan.py index 9738266..f963398 100644 --- a/hatasmota/fan.py +++ b/hatasmota/fan.py @@ -51,7 +51,7 @@ def from_discovery_message(cls, config: dict, platform: str) -> TasmotaFanConfig return cls( endpoint="fan", idx="ifan", - friendly_name=config[CONF_DEVICENAME], + friendly_name=None, mac=config[CONF_MAC], platform=platform, poll_payload="", diff --git a/hatasmota/sensor.py b/hatasmota/sensor.py index 34487f8..4d39524 100644 --- a/hatasmota/sensor.py +++ b/hatasmota/sensor.py @@ -261,7 +261,7 @@ def from_discovery_message( return cls( endpoint="sensor", idx=None, - friendly_name=f"{device_config[CONF_DEVICENAME]} {sensor_name}", + friendly_name=sensor_name, last_reset_path=last_reset_path, mac=device_config[CONF_MAC], platform=platform, diff --git a/hatasmota/shutter.py b/hatasmota/shutter.py index 15f2a37..bb8f9b5 100644 --- a/hatasmota/shutter.py +++ b/hatasmota/shutter.py @@ -70,7 +70,7 @@ def from_discovery_message( return cls( endpoint="shutter", idx=idx, - friendly_name=f"{config[CONF_DEVICENAME]} {platform} {idx+1}", + friendly_name=f"{platform} {idx+1}", mac=config[CONF_MAC], platform=platform, poll_payload="10", diff --git a/hatasmota/status_sensor.py b/hatasmota/status_sensor.py index 28b4153..2bda22d 100644 --- a/hatasmota/status_sensor.py +++ b/hatasmota/status_sensor.py @@ -169,7 +169,7 @@ def from_discovery_message( cls( endpoint="status_sensor", idx=None, - friendly_name=f"{config[CONF_DEVICENAME]} {NAMES[sensor]}", + friendly_name=NAMES[sensor], mac=config[CONF_MAC], platform=platform, poll_payload=str(STATUS_TOPICS.get(sensor)), diff --git a/hatasmota/utils.py b/hatasmota/utils.py index a76f678..f323e5b 100644 --- a/hatasmota/utils.py +++ b/hatasmota/utils.py @@ -207,7 +207,7 @@ def config_get_friendlyname(config: ConfigType, platform: str, idx: int) -> str: friendly_names = config[CONF_FRIENDLYNAME] if idx >= len(friendly_names) or friendly_names[idx] is None: - return f"{config[CONF_DEVICENAME]} {platform} {idx+1}" + return f"{platform} {idx+1}" return friendly_names[idx] @@ -216,7 +216,7 @@ def config_get_switchfriendlyname(config: ConfigType, platform: str, idx: int) - switch_names = config[CONF_SWITCHNAME] if idx >= len(switch_names) or switch_names[idx] is None: - return f"{config[CONF_DEVICENAME]} {platform} {idx+1}" + return f"{platform} {idx+1}" return switch_names[idx] From 6494f7f8da89c71ba341d65dc5f2495d5f305851 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 18 Aug 2023 17:43:16 +0200 Subject: [PATCH 2/2] Clean up unused imports --- hatasmota/fan.py | 1 - hatasmota/sensor.py | 1 - hatasmota/shutter.py | 1 - hatasmota/status_sensor.py | 1 - hatasmota/utils.py | 1 - 5 files changed, 5 deletions(-) diff --git a/hatasmota/fan.py b/hatasmota/fan.py index f963398..bb654f4 100644 --- a/hatasmota/fan.py +++ b/hatasmota/fan.py @@ -7,7 +7,6 @@ from .const import ( COMMAND_FANSPEED, - CONF_DEVICENAME, CONF_MAC, FAN_SPEED_HIGH, FAN_SPEED_LOW, diff --git a/hatasmota/sensor.py b/hatasmota/sensor.py index 4d39524..b3004af 100644 --- a/hatasmota/sensor.py +++ b/hatasmota/sensor.py @@ -9,7 +9,6 @@ CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, - CONF_DEVICENAME, CONF_MAC, CONF_SENSOR, DEGREE, diff --git a/hatasmota/shutter.py b/hatasmota/shutter.py index bb8f9b5..e85dd31 100644 --- a/hatasmota/shutter.py +++ b/hatasmota/shutter.py @@ -11,7 +11,6 @@ COMMAND_SHUTTER_POSITION, COMMAND_SHUTTER_STOP, COMMAND_SHUTTER_TILT, - CONF_DEVICENAME, CONF_MAC, CONF_SHUTTER_OPTIONS, CONF_SHUTTER_TILT, diff --git a/hatasmota/status_sensor.py b/hatasmota/status_sensor.py index 2bda22d..a1a5798 100644 --- a/hatasmota/status_sensor.py +++ b/hatasmota/status_sensor.py @@ -10,7 +10,6 @@ from .const import ( CONF_BATTERY, - CONF_DEVICENAME, CONF_IP, CONF_MAC, PERCENTAGE, diff --git a/hatasmota/utils.py b/hatasmota/utils.py index f323e5b..442e8cb 100644 --- a/hatasmota/utils.py +++ b/hatasmota/utils.py @@ -10,7 +10,6 @@ from typing import Any, cast from .const import ( - CONF_DEVICENAME, CONF_FRIENDLYNAME, CONF_FULLTOPIC, CONF_HOSTNAME,