Add motion_blinds VerticalBlind and cleanup (#55774)

This commit is contained in:
starkillerOG 2021-09-06 16:19:02 +02:00 committed by GitHub
parent e671ad41ec
commit 2634949999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 14 deletions

View File

@ -3,8 +3,7 @@ from datetime import timedelta
import logging
from socket import timeout
from motionblinds import MotionMulticast
from motionblinds.motion_blinds import ParseException
from motionblinds import MotionMulticast, ParseException
from homeassistant import config_entries, core
from homeassistant.const import CONF_API_KEY, CONF_HOST, EVENT_HOMEASSISTANT_STOP
@ -40,7 +39,7 @@ class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator):
name,
update_interval=None,
update_method=None,
):
) -> None:
"""Initialize global data updater."""
super().__init__(
hass,
@ -137,6 +136,11 @@ async def async_setup_entry(
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.async_get_or_create(
config_entry_id=entry.entry_id,
@ -145,7 +149,7 @@ async def async_setup_entry(
manufacturer=MANUFACTURER,
name=entry.title,
model="Wi-Fi bridge",
sw_version=motion_gateway.protocol,
sw_version=version,
)
hass.config_entries.async_setup_platforms(entry, PLATFORMS)

View File

@ -52,6 +52,7 @@ TILT_DEVICE_MAP = {
BlindType.VenetianBlind: DEVICE_CLASS_BLIND,
BlindType.ShangriLaBlind: DEVICE_CLASS_BLIND,
BlindType.DoubleRoller: DEVICE_CLASS_SHADE,
BlindType.VerticalBlind: DEVICE_CLASS_BLIND,
}
TDBU_DEVICE_MAP = {

View File

@ -40,11 +40,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
class MotionBatterySensor(CoordinatorEntity, SensorEntity):
"""
Representation of a Motion Battery Sensor.
Updates are done by the cover platform.
"""
"""Representation of a Motion Battery Sensor."""
_attr_device_class = DEVICE_CLASS_BATTERY
_attr_native_unit_of_measurement = PERCENTAGE
@ -91,11 +87,7 @@ class MotionBatterySensor(CoordinatorEntity, SensorEntity):
class MotionTDBUBatterySensor(MotionBatterySensor):
"""
Representation of a Motion Battery Sensor for a Top Down Bottom Up blind.
Updates are done by the cover platform.
"""
"""Representation of a Motion Battery Sensor for a Top Down Bottom Up blind."""
def __init__(self, coordinator, blind, motor):
"""Initialize the Motion Battery Sensor."""