mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Migrate Sensibo to new entity naming style (#75212)
This commit is contained in:
parent
911402e747
commit
cba3c8cf65
@ -55,7 +55,7 @@ class SensiboDeviceBinarySensorEntityDescription(
|
||||
FILTER_CLEAN_REQUIRED_DESCRIPTION = SensiboDeviceBinarySensorEntityDescription(
|
||||
key="filter_clean",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
name="Filter Clean Required",
|
||||
name="Filter clean required",
|
||||
value_fn=lambda data: data.filter_clean,
|
||||
)
|
||||
|
||||
@ -71,7 +71,7 @@ MOTION_SENSOR_TYPES: tuple[SensiboMotionBinarySensorEntityDescription, ...] = (
|
||||
SensiboMotionBinarySensorEntityDescription(
|
||||
key="is_main_sensor",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
name="Main Sensor",
|
||||
name="Main sensor",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.is_main_sensor,
|
||||
),
|
||||
@ -88,7 +88,7 @@ MOTION_DEVICE_SENSOR_TYPES: tuple[SensiboDeviceBinarySensorEntityDescription, ..
|
||||
SensiboDeviceBinarySensorEntityDescription(
|
||||
key="room_occupied",
|
||||
device_class=BinarySensorDeviceClass.MOTION,
|
||||
name="Room Occupied",
|
||||
name="Room occupied",
|
||||
icon="mdi:motion-sensor",
|
||||
value_fn=lambda data: data.room_occupied,
|
||||
),
|
||||
@ -111,7 +111,7 @@ PURE_SENSOR_TYPES: tuple[SensiboDeviceBinarySensorEntityDescription, ...] = (
|
||||
key="pure_geo_integration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
name="Pure Boost linked with Presence",
|
||||
name="Pure Boost linked with presence",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.pure_geo_integration,
|
||||
),
|
||||
@ -119,7 +119,7 @@ PURE_SENSOR_TYPES: tuple[SensiboDeviceBinarySensorEntityDescription, ...] = (
|
||||
key="pure_measure_integration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
name="Pure Boost linked with Indoor Air Quality",
|
||||
name="Pure Boost linked with indoor air quality",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.pure_measure_integration,
|
||||
),
|
||||
@ -127,7 +127,7 @@ PURE_SENSOR_TYPES: tuple[SensiboDeviceBinarySensorEntityDescription, ...] = (
|
||||
key="pure_prime_integration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
name="Pure Boost linked with Outdoor Air Quality",
|
||||
name="Pure Boost linked with outdoor air quality",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.pure_prime_integration,
|
||||
),
|
||||
@ -194,13 +194,9 @@ class SensiboMotionSensor(SensiboMotionBaseEntity, BinarySensorEntity):
|
||||
device_id,
|
||||
sensor_id,
|
||||
sensor_data,
|
||||
entity_description.name,
|
||||
)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{sensor_id}-{entity_description.key}"
|
||||
self._attr_name = (
|
||||
f"{self.device_data.name} Motion Sensor {entity_description.name}"
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
@ -228,7 +224,6 @@ class SensiboDeviceSensor(SensiboDeviceBaseEntity, BinarySensorEntity):
|
||||
)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{device_id}-{entity_description.key}"
|
||||
self._attr_name = f"{self.device_data.name} {entity_description.name}"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
|
@ -16,7 +16,7 @@ PARALLEL_UPDATES = 0
|
||||
|
||||
DEVICE_BUTTON_TYPES: ButtonEntityDescription = ButtonEntityDescription(
|
||||
key="reset_filter",
|
||||
name="Reset Filter",
|
||||
name="Reset filter",
|
||||
icon="mdi:air-filter",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
)
|
||||
@ -57,7 +57,6 @@ class SensiboDeviceButton(SensiboDeviceBaseEntity, ButtonEntity):
|
||||
)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{device_id}-{entity_description.key}"
|
||||
self._attr_name = f"{self.device_data.name} {entity_description.name}"
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
|
@ -126,7 +126,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
||||
"""Initiate SensiboClimate."""
|
||||
super().__init__(coordinator, device_id)
|
||||
self._attr_unique_id = device_id
|
||||
self._attr_name = self.device_data.name
|
||||
self._attr_temperature_unit = (
|
||||
TEMP_CELSIUS if self.device_data.temp_unit == "C" else TEMP_FAHRENHEIT
|
||||
)
|
||||
|
@ -37,6 +37,8 @@ class SensiboBaseEntity(CoordinatorEntity[SensiboDataUpdateCoordinator]):
|
||||
class SensiboDeviceBaseEntity(SensiboBaseEntity):
|
||||
"""Representation of a Sensibo device."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: SensiboDataUpdateCoordinator,
|
||||
@ -114,21 +116,21 @@ class SensiboDeviceBaseEntity(SensiboBaseEntity):
|
||||
class SensiboMotionBaseEntity(SensiboBaseEntity):
|
||||
"""Representation of a Sensibo motion entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: SensiboDataUpdateCoordinator,
|
||||
device_id: str,
|
||||
sensor_id: str,
|
||||
sensor_data: MotionSensor,
|
||||
name: str | None,
|
||||
) -> None:
|
||||
"""Initiate Sensibo Number."""
|
||||
super().__init__(coordinator, device_id)
|
||||
self._sensor_id = sensor_id
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, sensor_id)},
|
||||
name=f"{self.device_data.name} Motion Sensor {name}",
|
||||
name=f"{self.device_data.name} Motion Sensor",
|
||||
via_device=(DOMAIN, device_id),
|
||||
manufacturer="Sensibo",
|
||||
configuration_url="https://home.sensibo.com/",
|
||||
|
@ -86,7 +86,6 @@ class SensiboNumber(SensiboDeviceBaseEntity, NumberEntity):
|
||||
super().__init__(coordinator, device_id)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{device_id}-{entity_description.key}"
|
||||
self._attr_name = f"{self.device_data.name} {entity_description.name}"
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
|
@ -36,7 +36,7 @@ DEVICE_SELECT_TYPES = (
|
||||
key="horizontalSwing",
|
||||
remote_key="horizontal_swing_mode",
|
||||
remote_options="horizontal_swing_modes",
|
||||
name="Horizontal Swing",
|
||||
name="Horizontal swing",
|
||||
icon="mdi:air-conditioner",
|
||||
),
|
||||
SensiboSelectEntityDescription(
|
||||
@ -79,7 +79,6 @@ class SensiboSelect(SensiboDeviceBaseEntity, SelectEntity):
|
||||
super().__init__(coordinator, device_id)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{device_id}-{entity_description.key}"
|
||||
self._attr_name = f"{self.device_data.name} {entity_description.name}"
|
||||
|
||||
@property
|
||||
def current_option(self) -> str | None:
|
||||
|
@ -69,7 +69,7 @@ class SensiboDeviceSensorEntityDescription(
|
||||
FILTER_LAST_RESET_DESCRIPTION = SensiboDeviceSensorEntityDescription(
|
||||
key="filter_last_reset",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
name="Filter Last Reset",
|
||||
name="Filter last reset",
|
||||
icon="mdi:timer",
|
||||
value_fn=lambda data: data.filter_last_reset,
|
||||
extra_fn=None,
|
||||
@ -93,7 +93,7 @@ MOTION_SENSOR_TYPES: tuple[SensiboMotionSensorEntityDescription, ...] = (
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
name="Battery Voltage",
|
||||
name="Battery voltage",
|
||||
icon="mdi:battery",
|
||||
value_fn=lambda data: data.battery_voltage,
|
||||
),
|
||||
@ -128,7 +128,7 @@ PURE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
),
|
||||
SensiboDeviceSensorEntityDescription(
|
||||
key="pure_sensitivity",
|
||||
name="Pure Sensitivity",
|
||||
name="Pure sensitivity",
|
||||
icon="mdi:air-filter",
|
||||
value_fn=lambda data: data.pure_sensitivity,
|
||||
extra_fn=None,
|
||||
@ -140,7 +140,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
SensiboDeviceSensorEntityDescription(
|
||||
key="timer_time",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
name="Timer End Time",
|
||||
name="Timer end time",
|
||||
icon="mdi:timer",
|
||||
value_fn=lambda data: data.timer_time,
|
||||
extra_fn=lambda data: {"id": data.timer_id, "turn_on": data.timer_state_on},
|
||||
@ -149,7 +149,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
key="feels_like",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
name="Temperature Feels Like",
|
||||
name="Temperature feels like",
|
||||
value_fn=lambda data: data.feelslike,
|
||||
extra_fn=None,
|
||||
entity_registry_enabled_default=False,
|
||||
@ -237,13 +237,10 @@ class SensiboMotionSensor(SensiboMotionBaseEntity, SensorEntity):
|
||||
device_id,
|
||||
sensor_id,
|
||||
sensor_data,
|
||||
entity_description.name,
|
||||
)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{sensor_id}-{entity_description.key}"
|
||||
self._attr_name = (
|
||||
f"{self.device_data.name} Motion Sensor {entity_description.name}"
|
||||
)
|
||||
self._attr_name = entity_description.name
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self) -> str | None:
|
||||
@ -280,7 +277,6 @@ class SensiboDeviceSensor(SensiboDeviceBaseEntity, SensorEntity):
|
||||
)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{device_id}-{entity_description.key}"
|
||||
self._attr_name = f"{self.device_data.name} {entity_description.name}"
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self) -> str | None:
|
||||
|
@ -135,7 +135,6 @@ class SensiboDeviceSwitch(SensiboDeviceBaseEntity, SwitchEntity):
|
||||
)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{device_id}-{entity_description.key}"
|
||||
self._attr_name = f"{self.device_data.name} {entity_description.name}"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
|
@ -43,7 +43,7 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceUpdateEntityDescription, ...] = (
|
||||
key="fw_ver_available",
|
||||
device_class=UpdateDeviceClass.FIRMWARE,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
name="Update Available",
|
||||
name="Update available",
|
||||
icon="mdi:rocket-launch",
|
||||
value_version=lambda data: data.fw_ver,
|
||||
value_available=lambda data: data.fw_ver_available,
|
||||
@ -81,7 +81,6 @@ class SensiboDeviceUpdate(SensiboDeviceBaseEntity, UpdateEntity):
|
||||
super().__init__(coordinator, device_id)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{device_id}-{entity_description.key}"
|
||||
self._attr_name = f"{self.device_data.name} {entity_description.name}"
|
||||
self._attr_title = self.device_data.model
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user