Disable scenarios (scenes) for local API in Overkiz (#105153)

This commit is contained in:
Mick Vleeshouwer 2023-12-07 09:33:33 +01:00 committed by GitHub
parent 316776742f
commit e40f486968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View File

@ -1,10 +1,8 @@
"""The Overkiz (by Somfy) integration.""" """The Overkiz (by Somfy) integration."""
from __future__ import annotations from __future__ import annotations
import asyncio
from collections import defaultdict from collections import defaultdict
from dataclasses import dataclass from dataclasses import dataclass
from typing import cast
from aiohttp import ClientError from aiohttp import ClientError
from pyoverkiz.client import OverkizClient from pyoverkiz.client import OverkizClient
@ -16,7 +14,7 @@ from pyoverkiz.exceptions import (
NotSuchTokenException, NotSuchTokenException,
TooManyRequestsException, TooManyRequestsException,
) )
from pyoverkiz.models import Device, OverkizServer, Scenario, Setup from pyoverkiz.models import Device, OverkizServer, Scenario
from pyoverkiz.utils import generate_local_server from pyoverkiz.utils import generate_local_server
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -82,13 +80,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
try: try:
await client.login() await client.login()
setup = await client.get_setup()
setup, scenarios = await asyncio.gather( # Local API does expose scenarios, but they are not functional.
*[ # Tracked in https://github.com/Somfy-Developer/Somfy-TaHoma-Developer-Mode/issues/21
client.get_setup(), if api_type == APIType.CLOUD:
client.get_scenarios(), scenarios = await client.get_scenarios()
] else:
) scenarios = []
except (BadCredentialsException, NotSuchTokenException) as exception: except (BadCredentialsException, NotSuchTokenException) as exception:
raise ConfigEntryAuthFailed("Invalid authentication") from exception raise ConfigEntryAuthFailed("Invalid authentication") from exception
except TooManyRequestsException as exception: except TooManyRequestsException as exception:
@ -98,9 +97,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except MaintenanceException as exception: except MaintenanceException as exception:
raise ConfigEntryNotReady("Server is down for maintenance") from exception raise ConfigEntryNotReady("Server is down for maintenance") from exception
setup = cast(Setup, setup)
scenarios = cast(list[Scenario], scenarios)
coordinator = OverkizDataUpdateCoordinator( coordinator = OverkizDataUpdateCoordinator(
hass, hass,
LOGGER, LOGGER,

View File

@ -9,7 +9,7 @@
} }
}, },
"local_or_cloud": { "local_or_cloud": {
"description": "Choose between local or cloud API. Local API supports TaHoma Connexoon, TaHoma v2, and TaHoma Switch. Climate devices are not supported in local API.", "description": "Choose between local or cloud API. Local API supports TaHoma Connexoon, TaHoma v2, and TaHoma Switch. Climate devices and scenarios are not supported in local API.",
"data": { "data": {
"api_type": "API type" "api_type": "API type"
} }