mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Motion blind type list (#139590)
* Add blind_type_list * fix * styling * fix typing * Bump motionblinds to 0.6.26
This commit is contained in:
parent
5ac3fe6ee1
commit
0c803520a3
@ -12,6 +12,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
CONF_BLIND_TYPE_LIST,
|
||||||
CONF_INTERFACE,
|
CONF_INTERFACE,
|
||||||
CONF_WAIT_FOR_PUSH,
|
CONF_WAIT_FOR_PUSH,
|
||||||
DEFAULT_INTERFACE,
|
DEFAULT_INTERFACE,
|
||||||
@ -39,6 +40,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
key = entry.data[CONF_API_KEY]
|
key = entry.data[CONF_API_KEY]
|
||||||
multicast_interface = entry.data.get(CONF_INTERFACE, DEFAULT_INTERFACE)
|
multicast_interface = entry.data.get(CONF_INTERFACE, DEFAULT_INTERFACE)
|
||||||
wait_for_push = entry.options.get(CONF_WAIT_FOR_PUSH, DEFAULT_WAIT_FOR_PUSH)
|
wait_for_push = entry.options.get(CONF_WAIT_FOR_PUSH, DEFAULT_WAIT_FOR_PUSH)
|
||||||
|
blind_type_list = entry.data.get(CONF_BLIND_TYPE_LIST)
|
||||||
|
|
||||||
# Create multicast Listener
|
# Create multicast Listener
|
||||||
async with setup_lock:
|
async with setup_lock:
|
||||||
@ -81,7 +83,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
# Connect to motion gateway
|
# Connect to motion gateway
|
||||||
multicast = hass.data[DOMAIN][KEY_MULTICAST_LISTENER]
|
multicast = hass.data[DOMAIN][KEY_MULTICAST_LISTENER]
|
||||||
connect_gateway_class = ConnectMotionGateway(hass, multicast)
|
connect_gateway_class = ConnectMotionGateway(hass, multicast)
|
||||||
if not await connect_gateway_class.async_connect_gateway(host, key):
|
if not await connect_gateway_class.async_connect_gateway(
|
||||||
|
host, key, blind_type_list
|
||||||
|
):
|
||||||
raise ConfigEntryNotReady
|
raise ConfigEntryNotReady
|
||||||
motion_gateway = connect_gateway_class.gateway_device
|
motion_gateway = connect_gateway_class.gateway_device
|
||||||
api_lock = asyncio.Lock()
|
api_lock = asyncio.Lock()
|
||||||
@ -95,6 +99,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass, entry, _LOGGER, coordinator_info
|
hass, entry, _LOGGER, coordinator_info
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# store blind type list for next time
|
||||||
|
if entry.data.get(CONF_BLIND_TYPE_LIST) != motion_gateway.blind_type_list:
|
||||||
|
data = {
|
||||||
|
**entry.data,
|
||||||
|
CONF_BLIND_TYPE_LIST: motion_gateway.blind_type_list,
|
||||||
|
}
|
||||||
|
hass.config_entries.async_update_entry(entry, data=data)
|
||||||
|
|
||||||
# Fetch initial data so we have data when entities subscribe
|
# Fetch initial data so we have data when entities subscribe
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ class MotionBlindsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
key = user_input[CONF_API_KEY]
|
key = user_input[CONF_API_KEY]
|
||||||
|
assert self._host
|
||||||
|
|
||||||
connect_gateway_class = ConnectMotionGateway(self.hass)
|
connect_gateway_class = ConnectMotionGateway(self.hass)
|
||||||
if not await connect_gateway_class.async_connect_gateway(self._host, key):
|
if not await connect_gateway_class.async_connect_gateway(self._host, key):
|
||||||
|
@ -8,6 +8,7 @@ DEFAULT_GATEWAY_NAME = "Motionblinds Gateway"
|
|||||||
|
|
||||||
PLATFORMS = [Platform.BUTTON, Platform.COVER, Platform.SENSOR]
|
PLATFORMS = [Platform.BUTTON, Platform.COVER, Platform.SENSOR]
|
||||||
|
|
||||||
|
CONF_BLIND_TYPE_LIST = "blind_type_list"
|
||||||
CONF_WAIT_FOR_PUSH = "wait_for_push"
|
CONF_WAIT_FOR_PUSH = "wait_for_push"
|
||||||
CONF_INTERFACE = "interface"
|
CONF_INTERFACE = "interface"
|
||||||
DEFAULT_WAIT_FOR_PUSH = False
|
DEFAULT_WAIT_FOR_PUSH = False
|
||||||
|
@ -42,11 +42,16 @@ class ConnectMotionGateway:
|
|||||||
for blind in self.gateway_device.device_list.values():
|
for blind in self.gateway_device.device_list.values():
|
||||||
blind.Update_from_cache()
|
blind.Update_from_cache()
|
||||||
|
|
||||||
async def async_connect_gateway(self, host, key):
|
async def async_connect_gateway(
|
||||||
|
self,
|
||||||
|
host: str,
|
||||||
|
key: str,
|
||||||
|
blind_type_list: dict[str, int] | None = None,
|
||||||
|
) -> bool:
|
||||||
"""Connect to the Motion Gateway."""
|
"""Connect to the Motion Gateway."""
|
||||||
_LOGGER.debug("Initializing with host %s (key %s)", host, key[:3])
|
_LOGGER.debug("Initializing with host %s (key %s)", host, key[:3])
|
||||||
self._gateway_device = MotionGateway(
|
self._gateway_device = MotionGateway(
|
||||||
ip=host, key=key, multicast=self._multicast
|
ip=host, key=key, multicast=self._multicast, blind_type_list=blind_type_list
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
# update device info and get the connected sub devices
|
# update device info and get the connected sub devices
|
||||||
|
Loading…
x
Reference in New Issue
Block a user