From 4a39087fe7be56b463ff9d67360531554bc2a1c4 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Mon, 11 Jul 2022 18:14:17 +0200 Subject: [PATCH] Migrate Verisure to new entity naming style (#74997) --- .../verisure/alarm_control_panel.py | 2 +- .../components/verisure/binary_sensor.py | 5 ++-- homeassistant/components/verisure/camera.py | 3 ++- homeassistant/components/verisure/lock.py | 4 ++-- homeassistant/components/verisure/sensor.py | 24 +++++-------------- homeassistant/components/verisure/switch.py | 4 ++-- 6 files changed, 16 insertions(+), 26 deletions(-) diff --git a/homeassistant/components/verisure/alarm_control_panel.py b/homeassistant/components/verisure/alarm_control_panel.py index 8f92ee0a5dd..5030e01c8b1 100644 --- a/homeassistant/components/verisure/alarm_control_panel.py +++ b/homeassistant/components/verisure/alarm_control_panel.py @@ -33,7 +33,7 @@ class VerisureAlarm( """Representation of a Verisure alarm status.""" _attr_code_format = CodeFormat.NUMBER - _attr_name = "Verisure Alarm" + _attr_has_entity_name = True _attr_supported_features = ( AlarmControlPanelEntityFeature.ARM_HOME | AlarmControlPanelEntityFeature.ARM_AWAY diff --git a/homeassistant/components/verisure/binary_sensor.py b/homeassistant/components/verisure/binary_sensor.py index 217890b8a01..45e29cfa5f1 100644 --- a/homeassistant/components/verisure/binary_sensor.py +++ b/homeassistant/components/verisure/binary_sensor.py @@ -39,13 +39,13 @@ class VerisureDoorWindowSensor( """Representation of a Verisure door window sensor.""" _attr_device_class = BinarySensorDeviceClass.OPENING + _attr_has_entity_name = True def __init__( self, coordinator: VerisureDataUpdateCoordinator, serial_number: str ) -> None: """Initialize the Verisure door window sensor.""" super().__init__(coordinator) - self._attr_name = coordinator.data["door_window"][serial_number]["area"] self._attr_unique_id = f"{serial_number}_door_window" self.serial_number = serial_number @@ -84,9 +84,10 @@ class VerisureEthernetStatus( ): """Representation of a Verisure VBOX internet status.""" - _attr_name = "Verisure Ethernet status" _attr_device_class = BinarySensorDeviceClass.CONNECTIVITY _attr_entity_category = EntityCategory.DIAGNOSTIC + _attr_has_entity_name = True + _attr_name = "Ethernet status" @property def unique_id(self) -> str: diff --git a/homeassistant/components/verisure/camera.py b/homeassistant/components/verisure/camera.py index c753bf2c5dc..98ed41c5b9f 100644 --- a/homeassistant/components/verisure/camera.py +++ b/homeassistant/components/verisure/camera.py @@ -46,6 +46,8 @@ async def async_setup_entry( class VerisureSmartcam(CoordinatorEntity[VerisureDataUpdateCoordinator], Camera): """Representation of a Verisure camera.""" + _attr_has_entity_name = True + def __init__( self, coordinator: VerisureDataUpdateCoordinator, @@ -56,7 +58,6 @@ class VerisureSmartcam(CoordinatorEntity[VerisureDataUpdateCoordinator], Camera) super().__init__(coordinator) Camera.__init__(self) - self._attr_name = coordinator.data["cameras"][serial_number]["area"] self._attr_unique_id = serial_number self.serial_number = serial_number diff --git a/homeassistant/components/verisure/lock.py b/homeassistant/components/verisure/lock.py index 8074cf28f32..02cdad158ca 100644 --- a/homeassistant/components/verisure/lock.py +++ b/homeassistant/components/verisure/lock.py @@ -59,13 +59,13 @@ async def async_setup_entry( class VerisureDoorlock(CoordinatorEntity[VerisureDataUpdateCoordinator], LockEntity): """Representation of a Verisure doorlock.""" + _attr_has_entity_name = True + def __init__( self, coordinator: VerisureDataUpdateCoordinator, serial_number: str ) -> None: """Initialize the Verisure lock.""" super().__init__(coordinator) - - self._attr_name = coordinator.data["locks"][serial_number]["area"] self._attr_unique_id = serial_number self.serial_number = serial_number diff --git a/homeassistant/components/verisure/sensor.py b/homeassistant/components/verisure/sensor.py index 3b8f722c6f7..676082e4cda 100644 --- a/homeassistant/components/verisure/sensor.py +++ b/homeassistant/components/verisure/sensor.py @@ -51,6 +51,8 @@ class VerisureThermometer( """Representation of a Verisure thermometer.""" _attr_device_class = SensorDeviceClass.TEMPERATURE + _attr_has_entity_name = True + _attr_name = "Temperature" _attr_native_unit_of_measurement = TEMP_CELSIUS _attr_state_class = SensorStateClass.MEASUREMENT @@ -62,12 +64,6 @@ class VerisureThermometer( self._attr_unique_id = f"{serial_number}_temperature" self.serial_number = serial_number - @property - def name(self) -> str: - """Return the name of the entity.""" - name = self.coordinator.data["climate"][self.serial_number]["deviceArea"] - return f"{name} Temperature" - @property def device_info(self) -> DeviceInfo: """Return device information about this entity.""" @@ -106,6 +102,8 @@ class VerisureHygrometer( """Representation of a Verisure hygrometer.""" _attr_device_class = SensorDeviceClass.HUMIDITY + _attr_has_entity_name = True + _attr_name = "Humidity" _attr_native_unit_of_measurement = PERCENTAGE _attr_state_class = SensorStateClass.MEASUREMENT @@ -117,12 +115,6 @@ class VerisureHygrometer( self._attr_unique_id = f"{serial_number}_humidity" self.serial_number = serial_number - @property - def name(self) -> str: - """Return the name of the entity.""" - name = self.coordinator.data["climate"][self.serial_number]["deviceArea"] - return f"{name} Humidity" - @property def device_info(self) -> DeviceInfo: """Return device information about this entity.""" @@ -160,6 +152,8 @@ class VerisureMouseDetection( ): """Representation of a Verisure mouse detector.""" + _attr_name = "Mouse" + _attr_has_entity_name = True _attr_native_unit_of_measurement = "Mice" def __init__( @@ -170,12 +164,6 @@ class VerisureMouseDetection( self._attr_unique_id = f"{serial_number}_mice" self.serial_number = serial_number - @property - def name(self) -> str: - """Return the name of the entity.""" - name = self.coordinator.data["mice"][self.serial_number]["area"] - return f"{name} Mouse" - @property def device_info(self) -> DeviceInfo: """Return device information about this entity.""" diff --git a/homeassistant/components/verisure/switch.py b/homeassistant/components/verisure/switch.py index 5d1fd728f4a..177beb4272b 100644 --- a/homeassistant/components/verisure/switch.py +++ b/homeassistant/components/verisure/switch.py @@ -30,13 +30,13 @@ async def async_setup_entry( class VerisureSmartplug(CoordinatorEntity[VerisureDataUpdateCoordinator], SwitchEntity): """Representation of a Verisure smartplug.""" + _attr_has_entity_name = True + def __init__( self, coordinator: VerisureDataUpdateCoordinator, serial_number: str ) -> None: """Initialize the Verisure device.""" super().__init__(coordinator) - - self._attr_name = coordinator.data["smart_plugs"][serial_number]["area"] self._attr_unique_id = serial_number self.serial_number = serial_number