mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add motion_blinds VerticalBlind and cleanup (#55774)
This commit is contained in:
parent
e671ad41ec
commit
2634949999
@ -3,8 +3,7 @@ from datetime import timedelta
|
|||||||
import logging
|
import logging
|
||||||
from socket import timeout
|
from socket import timeout
|
||||||
|
|
||||||
from motionblinds import MotionMulticast
|
from motionblinds import MotionMulticast, ParseException
|
||||||
from motionblinds.motion_blinds import ParseException
|
|
||||||
|
|
||||||
from homeassistant import config_entries, core
|
from homeassistant import config_entries, core
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_API_KEY, CONF_HOST, EVENT_HOMEASSISTANT_STOP
|
||||||
@ -40,7 +39,7 @@ class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator):
|
|||||||
name,
|
name,
|
||||||
update_interval=None,
|
update_interval=None,
|
||||||
update_method=None,
|
update_method=None,
|
||||||
):
|
) -> None:
|
||||||
"""Initialize global data updater."""
|
"""Initialize global data updater."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
@ -137,6 +136,11 @@ async def async_setup_entry(
|
|||||||
KEY_COORDINATOR: coordinator,
|
KEY_COORDINATOR: coordinator,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if motion_gateway.firmware is not None:
|
||||||
|
version = f"{motion_gateway.firmware}, protocol: {motion_gateway.protocol}"
|
||||||
|
else:
|
||||||
|
version = f"Protocol: {motion_gateway.protocol}"
|
||||||
|
|
||||||
device_registry = await dr.async_get_registry(hass)
|
device_registry = await dr.async_get_registry(hass)
|
||||||
device_registry.async_get_or_create(
|
device_registry.async_get_or_create(
|
||||||
config_entry_id=entry.entry_id,
|
config_entry_id=entry.entry_id,
|
||||||
@ -145,7 +149,7 @@ async def async_setup_entry(
|
|||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
name=entry.title,
|
name=entry.title,
|
||||||
model="Wi-Fi bridge",
|
model="Wi-Fi bridge",
|
||||||
sw_version=motion_gateway.protocol,
|
sw_version=version,
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
|
@ -52,6 +52,7 @@ TILT_DEVICE_MAP = {
|
|||||||
BlindType.VenetianBlind: DEVICE_CLASS_BLIND,
|
BlindType.VenetianBlind: DEVICE_CLASS_BLIND,
|
||||||
BlindType.ShangriLaBlind: DEVICE_CLASS_BLIND,
|
BlindType.ShangriLaBlind: DEVICE_CLASS_BLIND,
|
||||||
BlindType.DoubleRoller: DEVICE_CLASS_SHADE,
|
BlindType.DoubleRoller: DEVICE_CLASS_SHADE,
|
||||||
|
BlindType.VerticalBlind: DEVICE_CLASS_BLIND,
|
||||||
}
|
}
|
||||||
|
|
||||||
TDBU_DEVICE_MAP = {
|
TDBU_DEVICE_MAP = {
|
||||||
|
@ -40,11 +40,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
|
|
||||||
|
|
||||||
class MotionBatterySensor(CoordinatorEntity, SensorEntity):
|
class MotionBatterySensor(CoordinatorEntity, SensorEntity):
|
||||||
"""
|
"""Representation of a Motion Battery Sensor."""
|
||||||
Representation of a Motion Battery Sensor.
|
|
||||||
|
|
||||||
Updates are done by the cover platform.
|
|
||||||
"""
|
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_BATTERY
|
_attr_device_class = DEVICE_CLASS_BATTERY
|
||||||
_attr_native_unit_of_measurement = PERCENTAGE
|
_attr_native_unit_of_measurement = PERCENTAGE
|
||||||
@ -91,11 +87,7 @@ class MotionBatterySensor(CoordinatorEntity, SensorEntity):
|
|||||||
|
|
||||||
|
|
||||||
class MotionTDBUBatterySensor(MotionBatterySensor):
|
class MotionTDBUBatterySensor(MotionBatterySensor):
|
||||||
"""
|
"""Representation of a Motion Battery Sensor for a Top Down Bottom Up blind."""
|
||||||
Representation of a Motion Battery Sensor for a Top Down Bottom Up blind.
|
|
||||||
|
|
||||||
Updates are done by the cover platform.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, coordinator, blind, motor):
|
def __init__(self, coordinator, blind, motor):
|
||||||
"""Initialize the Motion Battery Sensor."""
|
"""Initialize the Motion Battery Sensor."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user