From 29664d04d069fcb80ca3910572c609add6992830 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 4 Sep 2023 15:31:33 +0200 Subject: [PATCH] Use shorthand attributes in Mutesync (#99600) --- .../components/mutesync/binary_sensor.py | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/mutesync/binary_sensor.py b/homeassistant/components/mutesync/binary_sensor.py index 444643d5333..910f91fc4c6 100644 --- a/homeassistant/components/mutesync/binary_sensor.py +++ b/homeassistant/components/mutesync/binary_sensor.py @@ -36,24 +36,17 @@ class MuteStatus(update_coordinator.CoordinatorEntity, BinarySensorEntity): super().__init__(coordinator) self._sensor_type = sensor_type self._attr_translation_key = sensor_type - - @property - def unique_id(self): - """Return the unique ID of the sensor.""" - return f"{self.coordinator.data['user-id']}-{self._sensor_type}" + user_id = coordinator.data["user-id"] + self._attr_unique_id = f"{user_id}-{sensor_type}" + self._attr_device_info = DeviceInfo( + entry_type=DeviceEntryType.SERVICE, + identifiers={(DOMAIN, user_id)}, + manufacturer="mütesync", + model="mutesync app", + name="mutesync", + ) @property def is_on(self): """Return the state of the sensor.""" return self.coordinator.data[self._sensor_type] - - @property - def device_info(self) -> DeviceInfo: - """Return the device info of the sensor.""" - return DeviceInfo( - entry_type=DeviceEntryType.SERVICE, - identifiers={(DOMAIN, self.coordinator.data["user-id"])}, - manufacturer="mütesync", - model="mutesync app", - name="mutesync", - )