Skip to content

Commit

Permalink
Migrate Transmission to new entity naming (#95436)
Browse files Browse the repository at this point in the history
  • Loading branch information
avee87 authored Jun 28, 2023
1 parent 103375e commit 6c2c4c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/transmission/const.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
17 changes: 9 additions & 8 deletions homeassistant/components/transmission/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
),
]

Expand All @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/transmission/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c2c4c9

Please sign in to comment.