Migrate Soma to entity naming (#96158)

pull/96872/head
Joost Lekkerkerker 2023-07-18 21:40:20 +02:00 committed by GitHub
parent 6f880ec837
commit a2495f494b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View File

@ -108,6 +108,8 @@ def soma_api_call(api_call):
class SomaEntity(Entity):
"""Representation of a generic Soma device."""
_attr_has_entity_name = True
def __init__(self, device, api):
"""Initialize the Soma device."""
self.device = device
@ -127,11 +129,6 @@ class SomaEntity(Entity):
"""Return the unique id base on the id returned by pysoma API."""
return self.device["mac"]
@property
def name(self):
"""Return the name of the device."""
return self.device["name"]
@property
def device_info(self) -> DeviceInfo:
"""Return device specific attributes.
@ -141,7 +138,7 @@ class SomaEntity(Entity):
return DeviceInfo(
identifiers={(DOMAIN, self.unique_id)},
manufacturer="Wazombi Labs",
name=self.name,
name=self.device["name"],
)
def set_position(self, position: int) -> None:

View File

@ -43,6 +43,7 @@ async def async_setup_entry(
class SomaTilt(SomaEntity, CoverEntity):
"""Representation of a Soma Tilt device."""
_attr_name = None
_attr_device_class = CoverDeviceClass.BLIND
_attr_supported_features = (
CoverEntityFeature.OPEN_TILT
@ -118,6 +119,7 @@ class SomaTilt(SomaEntity, CoverEntity):
class SomaShade(SomaEntity, CoverEntity):
"""Representation of a Soma Shade device."""
_attr_name = None
_attr_device_class = CoverDeviceClass.SHADE
_attr_supported_features = (
CoverEntityFeature.OPEN

View File

@ -34,11 +34,6 @@ class SomaSensor(SomaEntity, SensorEntity):
_attr_device_class = SensorDeviceClass.BATTERY
_attr_native_unit_of_measurement = PERCENTAGE
@property
def name(self):
"""Return the name of the device."""
return self.device["name"] + " battery level"
@property
def native_value(self):
"""Return the state of the entity."""