mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Migrate Soma to entity naming (#96158)
This commit is contained in:
parent
6f880ec837
commit
a2495f494b
@ -108,6 +108,8 @@ def soma_api_call(api_call):
|
|||||||
class SomaEntity(Entity):
|
class SomaEntity(Entity):
|
||||||
"""Representation of a generic Soma device."""
|
"""Representation of a generic Soma device."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, device, api):
|
def __init__(self, device, api):
|
||||||
"""Initialize the Soma device."""
|
"""Initialize the Soma device."""
|
||||||
self.device = device
|
self.device = device
|
||||||
@ -127,11 +129,6 @@ class SomaEntity(Entity):
|
|||||||
"""Return the unique id base on the id returned by pysoma API."""
|
"""Return the unique id base on the id returned by pysoma API."""
|
||||||
return self.device["mac"]
|
return self.device["mac"]
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self.device["name"]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device specific attributes.
|
"""Return device specific attributes.
|
||||||
@ -141,7 +138,7 @@ class SomaEntity(Entity):
|
|||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.unique_id)},
|
identifiers={(DOMAIN, self.unique_id)},
|
||||||
manufacturer="Wazombi Labs",
|
manufacturer="Wazombi Labs",
|
||||||
name=self.name,
|
name=self.device["name"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_position(self, position: int) -> None:
|
def set_position(self, position: int) -> None:
|
||||||
|
@ -43,6 +43,7 @@ async def async_setup_entry(
|
|||||||
class SomaTilt(SomaEntity, CoverEntity):
|
class SomaTilt(SomaEntity, CoverEntity):
|
||||||
"""Representation of a Soma Tilt device."""
|
"""Representation of a Soma Tilt device."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
_attr_device_class = CoverDeviceClass.BLIND
|
_attr_device_class = CoverDeviceClass.BLIND
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
CoverEntityFeature.OPEN_TILT
|
CoverEntityFeature.OPEN_TILT
|
||||||
@ -118,6 +119,7 @@ class SomaTilt(SomaEntity, CoverEntity):
|
|||||||
class SomaShade(SomaEntity, CoverEntity):
|
class SomaShade(SomaEntity, CoverEntity):
|
||||||
"""Representation of a Soma Shade device."""
|
"""Representation of a Soma Shade device."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
_attr_device_class = CoverDeviceClass.SHADE
|
_attr_device_class = CoverDeviceClass.SHADE
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
CoverEntityFeature.OPEN
|
CoverEntityFeature.OPEN
|
||||||
|
@ -34,11 +34,6 @@ class SomaSensor(SomaEntity, SensorEntity):
|
|||||||
_attr_device_class = SensorDeviceClass.BATTERY
|
_attr_device_class = SensorDeviceClass.BATTERY
|
||||||
_attr_native_unit_of_measurement = PERCENTAGE
|
_attr_native_unit_of_measurement = PERCENTAGE
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self.device["name"] + " battery level"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user