From 6c2c4c989f278b97e91c9367ca54dd95bf6b8b7b Mon Sep 17 00:00:00 2001 From: avee87 <6134677+avee87@users.noreply.github.com> Date: Wed, 28 Jun 2023 13:00:06 +0100 Subject: [PATCH] Migrate Transmission to new entity naming (#95436) --- homeassistant/components/transmission/const.py | 2 +- homeassistant/components/transmission/sensor.py | 17 +++++++++-------- homeassistant/components/transmission/switch.py | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/transmission/const.py b/homeassistant/components/transmission/const.py index 0e29bbbff5f..da861d2698c 100644 --- a/homeassistant/components/transmission/const.py +++ b/homeassistant/components/transmission/const.py @@ -1,7 +1,7 @@ """Constants for the Transmission Bittorent Client component.""" DOMAIN = "transmission" -SWITCH_TYPES = {"on_off": "Switch", "turtle_mode": "Turtle Mode"} +SWITCH_TYPES = {"on_off": "Switch", "turtle_mode": "Turtle mode"} ORDER_NEWEST_FIRST = "newest_first" ORDER_OLDEST_FIRST = "oldest_first" diff --git a/homeassistant/components/transmission/sensor.py b/homeassistant/components/transmission/sensor.py index 946ff42f59b..3cee556044f 100644 --- a/homeassistant/components/transmission/sensor.py +++ b/homeassistant/components/transmission/sensor.py @@ -38,21 +38,21 @@ async def async_setup_entry( name = config_entry.data[CONF_NAME] dev = [ - TransmissionSpeedSensor(tm_client, name, "Down Speed", "download"), - TransmissionSpeedSensor(tm_client, name, "Up Speed", "upload"), + TransmissionSpeedSensor(tm_client, name, "Down speed", "download"), + TransmissionSpeedSensor(tm_client, name, "Up speed", "upload"), TransmissionStatusSensor(tm_client, name, "Status", "status"), TransmissionTorrentsSensor( - tm_client, name, "Active Torrents", "active_torrents" + tm_client, name, "Active torrents", "active_torrents" ), TransmissionTorrentsSensor( - tm_client, name, "Paused Torrents", "paused_torrents" + tm_client, name, "Paused torrents", "paused_torrents" ), - TransmissionTorrentsSensor(tm_client, name, "Total Torrents", "total_torrents"), + TransmissionTorrentsSensor(tm_client, name, "Total torrents", "total_torrents"), TransmissionTorrentsSensor( - tm_client, name, "Completed Torrents", "completed_torrents" + tm_client, name, "Completed torrents", "completed_torrents" ), TransmissionTorrentsSensor( - tm_client, name, "Started Torrents", "started_torrents" + tm_client, name, "Started torrents", "started_torrents" ), ] @@ -62,12 +62,13 @@ async def async_setup_entry( class TransmissionSensor(SensorEntity): """A base class for all Transmission sensors.""" + _attr_has_entity_name = True _attr_should_poll = False def __init__(self, tm_client, client_name, sensor_name, key): """Initialize the sensor.""" self._tm_client: TransmissionClient = tm_client - self._attr_name = f"{client_name} {sensor_name}" + self._attr_name = sensor_name self._key = key self._state = None self._attr_unique_id = f"{tm_client.config_entry.entry_id}-{key}" diff --git a/homeassistant/components/transmission/switch.py b/homeassistant/components/transmission/switch.py index d60a992e791..89f89e079fa 100644 --- a/homeassistant/components/transmission/switch.py +++ b/homeassistant/components/transmission/switch.py @@ -36,11 +36,12 @@ async def async_setup_entry( class TransmissionSwitch(SwitchEntity): """Representation of a Transmission switch.""" + _attr_has_entity_name = True _attr_should_poll = False def __init__(self, switch_type, switch_name, tm_client, client_name): """Initialize the Transmission switch.""" - self._attr_name = f"{client_name} {switch_name}" + self._attr_name = switch_name self.type = switch_type self._tm_client = tm_client self._state = STATE_OFF