Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt naming to match Home Assistant has_entity_name #243

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions hatasmota/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from .const import (
COMMAND_FANSPEED,
CONF_DEVICENAME,
CONF_MAC,
FAN_SPEED_HIGH,
FAN_SPEED_LOW,
Expand Down Expand Up @@ -51,7 +50,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="",
Expand Down
3 changes: 1 addition & 2 deletions hatasmota/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
CONF_DEVICENAME,
CONF_MAC,
CONF_SENSOR,
DEGREE,
Expand Down Expand Up @@ -261,7 +260,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,
Expand Down
3 changes: 1 addition & 2 deletions hatasmota/shutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
COMMAND_SHUTTER_POSITION,
COMMAND_SHUTTER_STOP,
COMMAND_SHUTTER_TILT,
CONF_DEVICENAME,
CONF_MAC,
CONF_SHUTTER_OPTIONS,
CONF_SHUTTER_TILT,
Expand Down Expand Up @@ -70,7 +69,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",
Expand Down
3 changes: 1 addition & 2 deletions hatasmota/status_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from .const import (
CONF_BATTERY,
CONF_DEVICENAME,
CONF_IP,
CONF_MAC,
PERCENTAGE,
Expand Down Expand Up @@ -169,7 +168,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)),
Expand Down
5 changes: 2 additions & 3 deletions hatasmota/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from typing import Any, cast

from .const import (
CONF_DEVICENAME,
CONF_FRIENDLYNAME,
CONF_FULLTOPIC,
CONF_HOSTNAME,
Expand Down Expand Up @@ -207,7 +206,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]


Expand All @@ -216,7 +215,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]


Expand Down
Loading