From 2dd9229dc4f60a7bc573d323547147c6e69db6c5 Mon Sep 17 00:00:00 2001 From: avee87 <6134677+avee87@users.noreply.github.com> Date: Sat, 31 Dec 2022 12:20:44 +0000 Subject: [PATCH] Add device info to transmission (#84660) --- homeassistant/components/transmission/sensor.py | 8 ++++++++ homeassistant/components/transmission/switch.py | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/transmission/sensor.py b/homeassistant/components/transmission/sensor.py index 7f8128e060c..b1ff20627e1 100644 --- a/homeassistant/components/transmission/sensor.py +++ b/homeassistant/components/transmission/sensor.py @@ -9,7 +9,9 @@ from homeassistant.components.sensor import SensorDeviceClass, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME, STATE_IDLE, UnitOfDataRate from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import TransmissionClient @@ -58,6 +60,12 @@ class TransmissionSensor(SensorEntity): self._name = sensor_name self._sub_type = sub_type self._state = None + self._attr_device_info = DeviceInfo( + entry_type=DeviceEntryType.SERVICE, + identifiers={(DOMAIN, tm_client.config_entry.entry_id)}, + manufacturer="Transmission", + name=client_name, + ) @property def name(self): diff --git a/homeassistant/components/transmission/switch.py b/homeassistant/components/transmission/switch.py index 0fd9ffee51e..ed771d24581 100644 --- a/homeassistant/components/transmission/switch.py +++ b/homeassistant/components/transmission/switch.py @@ -6,7 +6,9 @@ from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME, STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from .const import DOMAIN, SWITCH_TYPES @@ -36,15 +38,21 @@ class TransmissionSwitch(SwitchEntity): _attr_should_poll = False - def __init__(self, switch_type, switch_name, tm_client, name): + def __init__(self, switch_type, switch_name, tm_client, client_name): """Initialize the Transmission switch.""" self._name = switch_name - self.client_name = name + self.client_name = client_name self.type = switch_type self._tm_client = tm_client self._state = STATE_OFF self._data = None self.unsub_update = None + self._attr_device_info = DeviceInfo( + entry_type=DeviceEntryType.SERVICE, + identifiers={(DOMAIN, tm_client.config_entry.entry_id)}, + manufacturer="Transmission", + name=client_name, + ) @property def name(self):