mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Add update platform for Sensibo (#70180)
This commit is contained in:
parent
f63465bd71
commit
c87992715f
@ -1026,6 +1026,7 @@ omit =
|
|||||||
homeassistant/components/sensibo/number.py
|
homeassistant/components/sensibo/number.py
|
||||||
homeassistant/components/sensibo/select.py
|
homeassistant/components/sensibo/select.py
|
||||||
homeassistant/components/sensibo/sensor.py
|
homeassistant/components/sensibo/sensor.py
|
||||||
|
homeassistant/components/sensibo/update.py
|
||||||
homeassistant/components/senz/__init__.py
|
homeassistant/components/senz/__init__.py
|
||||||
homeassistant/components/senz/api.py
|
homeassistant/components/senz/api.py
|
||||||
homeassistant/components/senz/climate.py
|
homeassistant/components/senz/climate.py
|
||||||
|
@ -82,14 +82,6 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceBinarySensorEntityDescription, ...] = (
|
|||||||
icon="mdi:motion-sensor",
|
icon="mdi:motion-sensor",
|
||||||
value_fn=lambda data: data.room_occupied,
|
value_fn=lambda data: data.room_occupied,
|
||||||
),
|
),
|
||||||
SensiboDeviceBinarySensorEntityDescription(
|
|
||||||
key="update_available",
|
|
||||||
device_class=BinarySensorDeviceClass.UPDATE,
|
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
|
||||||
name="Update Available",
|
|
||||||
icon="mdi:rocket-launch",
|
|
||||||
value_fn=lambda data: data.update_available,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ PLATFORMS = [
|
|||||||
Platform.NUMBER,
|
Platform.NUMBER,
|
||||||
Platform.SELECT,
|
Platform.SELECT,
|
||||||
Platform.SENSOR,
|
Platform.SENSOR,
|
||||||
|
Platform.UPDATE,
|
||||||
]
|
]
|
||||||
DEFAULT_NAME = "Sensibo"
|
DEFAULT_NAME = "Sensibo"
|
||||||
TIMEOUT = 8
|
TIMEOUT = 8
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"domain": "sensibo",
|
"domain": "sensibo",
|
||||||
"name": "Sensibo",
|
"name": "Sensibo",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/sensibo",
|
"documentation": "https://www.home-assistant.io/integrations/sensibo",
|
||||||
"requirements": ["pysensibo==1.0.9"],
|
"requirements": ["pysensibo==1.0.10"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"codeowners": ["@andrey-git", "@gjohansson-ST"],
|
"codeowners": ["@andrey-git", "@gjohansson-ST"],
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
|
93
homeassistant/components/sensibo/update.py
Normal file
93
homeassistant/components/sensibo/update.py
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
"""Update platform for Sensibo integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Callable
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from pysensibo.model import SensiboDevice
|
||||||
|
|
||||||
|
from homeassistant.components.update import (
|
||||||
|
UpdateDeviceClass,
|
||||||
|
UpdateEntity,
|
||||||
|
UpdateEntityDescription,
|
||||||
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
from .coordinator import SensiboDataUpdateCoordinator
|
||||||
|
from .entity import SensiboDeviceBaseEntity
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class DeviceBaseEntityDescriptionMixin:
|
||||||
|
"""Mixin for required Sensibo base description keys."""
|
||||||
|
|
||||||
|
value_version: Callable[[SensiboDevice], str | None]
|
||||||
|
value_available: Callable[[SensiboDevice], str | None]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class SensiboDeviceUpdateEntityDescription(
|
||||||
|
UpdateEntityDescription, DeviceBaseEntityDescriptionMixin
|
||||||
|
):
|
||||||
|
"""Describes Sensibo Update entity."""
|
||||||
|
|
||||||
|
|
||||||
|
DEVICE_SENSOR_TYPES: tuple[SensiboDeviceUpdateEntityDescription, ...] = (
|
||||||
|
SensiboDeviceUpdateEntityDescription(
|
||||||
|
key="fw_ver_available",
|
||||||
|
device_class=UpdateDeviceClass.FIRMWARE,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
name="Update Available",
|
||||||
|
icon="mdi:rocket-launch",
|
||||||
|
value_version=lambda data: data.fw_ver,
|
||||||
|
value_available=lambda data: data.fw_ver_available,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
|
) -> None:
|
||||||
|
"""Set up Sensibo Update platform."""
|
||||||
|
|
||||||
|
coordinator: SensiboDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
|
async_add_entities(
|
||||||
|
SensiboDeviceUpdate(coordinator, device_id, description)
|
||||||
|
for description in DEVICE_SENSOR_TYPES
|
||||||
|
for device_id, device_data in coordinator.data.parsed.items()
|
||||||
|
if description.value_available(device_data) is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SensiboDeviceUpdate(SensiboDeviceBaseEntity, UpdateEntity):
|
||||||
|
"""Representation of a Sensibo Device Update."""
|
||||||
|
|
||||||
|
entity_description: SensiboDeviceUpdateEntityDescription
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
coordinator: SensiboDataUpdateCoordinator,
|
||||||
|
device_id: str,
|
||||||
|
entity_description: SensiboDeviceUpdateEntityDescription,
|
||||||
|
) -> None:
|
||||||
|
"""Initiate Sensibo Device Update."""
|
||||||
|
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
|
||||||
|
def installed_version(self) -> str | None:
|
||||||
|
"""Return version currently installed."""
|
||||||
|
return self.entity_description.value_version(self.device_data)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def latest_version(self) -> str | None:
|
||||||
|
"""Return latest available version."""
|
||||||
|
return self.entity_description.value_available(self.device_data)
|
@ -1777,7 +1777,7 @@ pysaj==0.0.16
|
|||||||
pysdcp==1
|
pysdcp==1
|
||||||
|
|
||||||
# homeassistant.components.sensibo
|
# homeassistant.components.sensibo
|
||||||
pysensibo==1.0.9
|
pysensibo==1.0.10
|
||||||
|
|
||||||
# homeassistant.components.serial
|
# homeassistant.components.serial
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
|
@ -1187,7 +1187,7 @@ pyrituals==0.0.6
|
|||||||
pyruckus==0.12
|
pyruckus==0.12
|
||||||
|
|
||||||
# homeassistant.components.sensibo
|
# homeassistant.components.sensibo
|
||||||
pysensibo==1.0.9
|
pysensibo==1.0.10
|
||||||
|
|
||||||
# homeassistant.components.serial
|
# homeassistant.components.serial
|
||||||
# homeassistant.components.zha
|
# homeassistant.components.zha
|
||||||
|
Loading…
x
Reference in New Issue
Block a user