This commit is contained in:
Franck Nijhof 2023-08-24 13:47:32 +02:00 committed by GitHub
commit 7548c4aced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 79 additions and 62 deletions

View File

@ -8,6 +8,6 @@
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["androidtvremote2"], "loggers": ["androidtvremote2"],
"quality_scale": "platinum", "quality_scale": "platinum",
"requirements": ["androidtvremote2==0.0.13"], "requirements": ["androidtvremote2==0.0.14"],
"zeroconf": ["_androidtvremote2._tcp.local."] "zeroconf": ["_androidtvremote2._tcp.local."]
} }

View File

@ -72,6 +72,7 @@ class FreeboxRouter:
self.devices: dict[str, dict[str, Any]] = {} self.devices: dict[str, dict[str, Any]] = {}
self.disks: dict[int, dict[str, Any]] = {} self.disks: dict[int, dict[str, Any]] = {}
self.supports_raid = True
self.raids: dict[int, dict[str, Any]] = {} self.raids: dict[int, dict[str, Any]] = {}
self.sensors_temperature: dict[str, int] = {} self.sensors_temperature: dict[str, int] = {}
self.sensors_connection: dict[str, float] = {} self.sensors_connection: dict[str, float] = {}
@ -160,14 +161,21 @@ class FreeboxRouter:
async def _update_raids_sensors(self) -> None: async def _update_raids_sensors(self) -> None:
"""Update Freebox raids.""" """Update Freebox raids."""
# None at first request if not self.supports_raid:
return
try: try:
fbx_raids: list[dict[str, Any]] = await self._api.storage.get_raids() or [] fbx_raids: list[dict[str, Any]] = await self._api.storage.get_raids() or []
except HttpRequestError: except HttpRequestError:
_LOGGER.warning("Unable to enumerate raid disks") self.supports_raid = False
else: _LOGGER.info(
for fbx_raid in fbx_raids: "Router %s API does not support RAID",
self.raids[fbx_raid["id"]] = fbx_raid self.name,
)
return
for fbx_raid in fbx_raids:
self.raids[fbx_raid["id"]] = fbx_raid
async def update_home_devices(self) -> None: async def update_home_devices(self) -> None:
"""Update Home devices (alarm, light, sensor, switch, remote ...).""" """Update Home devices (alarm, light, sensor, switch, remote ...)."""

View File

@ -12,5 +12,5 @@
"integration_type": "hub", "integration_type": "hub",
"iot_class": "cloud_push", "iot_class": "cloud_push",
"loggers": ["pylitterbot"], "loggers": ["pylitterbot"],
"requirements": ["pylitterbot==2023.4.2"] "requirements": ["pylitterbot==2023.4.5"]
} }

View File

@ -65,7 +65,6 @@ def struct_validator(config: dict[str, Any]) -> dict[str, Any]:
name = config[CONF_NAME] name = config[CONF_NAME]
structure = config.get(CONF_STRUCTURE) structure = config.get(CONF_STRUCTURE)
slave_count = config.get(CONF_SLAVE_COUNT, 0) + 1 slave_count = config.get(CONF_SLAVE_COUNT, 0) + 1
slave = config.get(CONF_SLAVE, 0)
swap_type = config.get(CONF_SWAP, CONF_SWAP_NONE) swap_type = config.get(CONF_SWAP, CONF_SWAP_NONE)
if ( if (
slave_count > 1 slave_count > 1
@ -79,7 +78,7 @@ def struct_validator(config: dict[str, Any]) -> dict[str, Any]:
error = f"{name} structure: cannot be mixed with {data_type}" error = f"{name} structure: cannot be mixed with {data_type}"
if config[CONF_DATA_TYPE] == DataType.CUSTOM: if config[CONF_DATA_TYPE] == DataType.CUSTOM:
if slave or slave_count > 1: if slave_count > 1:
error = f"{name}: `{CONF_STRUCTURE}` illegal with `{CONF_SLAVE_COUNT}` / `{CONF_SLAVE}`" error = f"{name}: `{CONF_STRUCTURE}` illegal with `{CONF_SLAVE_COUNT}` / `{CONF_SLAVE}`"
raise vol.Invalid(error) raise vol.Invalid(error)
if swap_type != CONF_SWAP_NONE: if swap_type != CONF_SWAP_NONE:
@ -125,8 +124,7 @@ def struct_validator(config: dict[str, Any]) -> dict[str, Any]:
if count < regs_needed or (count % regs_needed) != 0: if count < regs_needed or (count % regs_needed) != 0:
raise vol.Invalid( raise vol.Invalid(
f"Error in sensor {name} swap({swap_type}) " f"Error in sensor {name} swap({swap_type}) "
"not possible due to the registers " f"impossible because datatype({data_type}) is too small"
f"count: {count}, needed: {regs_needed}"
) )
structure = f">{DEFAULT_STRUCT_FORMAT[data_type].struct_id}" structure = f">{DEFAULT_STRUCT_FORMAT[data_type].struct_id}"
if slave_count > 1: if slave_count > 1:

View File

@ -1144,11 +1144,8 @@ class MqttEntity(
) )
elif (device_name := config[CONF_DEVICE][CONF_NAME]) == entity_name: elif (device_name := config[CONF_DEVICE][CONF_NAME]) == entity_name:
self._attr_name = None self._attr_name = None
self._issue_key = ( if not self._discovery:
"entity_name_is_device_name_discovery" self._issue_key = "entity_name_is_device_name_yaml"
if self._discovery
else "entity_name_is_device_name_yaml"
)
_LOGGER.warning( _LOGGER.warning(
"MQTT device name is equal to entity name in your config %s, " "MQTT device name is equal to entity name in your config %s, "
"this is not expected. Please correct your configuration. " "this is not expected. Please correct your configuration. "
@ -1162,11 +1159,8 @@ class MqttEntity(
if device_name[:1].isupper(): if device_name[:1].isupper():
# Ensure a capital if the device name first char is a capital # Ensure a capital if the device name first char is a capital
new_entity_name = new_entity_name[:1].upper() + new_entity_name[1:] new_entity_name = new_entity_name[:1].upper() + new_entity_name[1:]
self._issue_key = ( if not self._discovery:
"entity_name_startswith_device_name_discovery" self._issue_key = "entity_name_startswith_device_name_yaml"
if self._discovery
else "entity_name_startswith_device_name_yaml"
)
_LOGGER.warning( _LOGGER.warning(
"MQTT entity name starts with the device name in your config %s, " "MQTT entity name starts with the device name in your config %s, "
"this is not expected. Please correct your configuration. " "this is not expected. Please correct your configuration. "

View File

@ -14,15 +14,7 @@
}, },
"entity_name_startswith_device_name_yaml": { "entity_name_startswith_device_name_yaml": {
"title": "Manual configured MQTT entities with a name that starts with the device name", "title": "Manual configured MQTT entities with a name that starts with the device name",
"description": "Some MQTT entities have an entity name that starts with the device name. This is not expected. To avoid a duplicate name the device name prefix is stripped of the entity name as a work-a-round. Please update your configuration and restart Home Assistant to fix this issue. \n\nList of affected entities:\n\n{config}" "description": "Some MQTT entities have an entity name that starts with the device name. This is not expected. To avoid a duplicate name the device name prefix is stripped off the entity name as a work-a-round. Please update your configuration and restart Home Assistant to fix this issue. \n\nList of affected entities:\n\n{config}"
},
"entity_name_is_device_name_discovery": {
"title": "Discovered MQTT entities with a name that is equal to the device name",
"description": "Some MQTT entities have an entity name equal to the device name. This is not expected. The entity name is set to `null` as a work-a-round to avoid a duplicate name. Please inform the maintainer of the software application that supplies the affected entities to fix this issue.\n\nList of affected entities:\n\n{config}"
},
"entity_name_startswith_device_name_discovery": {
"title": "Discovered entities with a name that starts with the device name",
"description": "Some MQTT entities have an entity name that starts with the device name. This is not expected. To avoid a duplicate name the device name prefix is stripped of the entity name as a work-a-round. Please inform the maintainer of the software application that supplies the affected entities to fix this issue. \n\nList of affected entities:\n\n{config}"
} }
}, },
"config": { "config": {

View File

@ -5,6 +5,7 @@ from datetime import timedelta
import logging import logging
from typing import cast from typing import cast
import aiohttp
from pyoctoprintapi import ApiError, OctoprintClient, PrinterOffline from pyoctoprintapi import ApiError, OctoprintClient, PrinterOffline
from pyoctoprintapi.exceptions import UnauthorizedException from pyoctoprintapi.exceptions import UnauthorizedException
import voluptuous as vol import voluptuous as vol
@ -22,11 +23,11 @@ from homeassistant.const import (
CONF_SENSORS, CONF_SENSORS,
CONF_SSL, CONF_SSL,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
EVENT_HOMEASSISTANT_STOP,
Platform, Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryAuthFailed from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -163,14 +164,25 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
data = {**entry.data, CONF_VERIFY_SSL: True} data = {**entry.data, CONF_VERIFY_SSL: True}
hass.config_entries.async_update_entry(entry, data=data) hass.config_entries.async_update_entry(entry, data=data)
verify_ssl = entry.data[CONF_VERIFY_SSL] connector = aiohttp.TCPConnector(
websession = async_get_clientsession(hass, verify_ssl=verify_ssl) force_close=True,
ssl=False if not entry.data[CONF_VERIFY_SSL] else None,
)
session = aiohttp.ClientSession(connector=connector)
@callback
def _async_close_websession(event: Event) -> None:
"""Close websession."""
session.detach()
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_close_websession)
client = OctoprintClient( client = OctoprintClient(
entry.data[CONF_HOST], host=entry.data[CONF_HOST],
websession, session=session,
entry.data[CONF_PORT], port=entry.data[CONF_PORT],
entry.data[CONF_SSL], ssl=entry.data[CONF_SSL],
entry.data[CONF_PATH], path=entry.data[CONF_PATH],
) )
client.set_api_key(entry.data[CONF_API_KEY]) client.set_api_key(entry.data[CONF_API_KEY])

View File

@ -6,6 +6,7 @@ from collections.abc import Mapping
import logging import logging
from typing import Any from typing import Any
import aiohttp
from pyoctoprintapi import ApiError, OctoprintClient, OctoprintException from pyoctoprintapi import ApiError, OctoprintClient, OctoprintException
import voluptuous as vol import voluptuous as vol
from yarl import URL from yarl import URL
@ -22,7 +23,6 @@ from homeassistant.const import (
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.data_entry_flow import FlowResult from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from .const import DOMAIN from .const import DOMAIN
@ -58,6 +58,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for OctoPrint.""" """Handle a config flow for OctoPrint."""
self.discovery_schema = None self.discovery_schema = None
self._user_input = None self._user_input = None
self._sessions: list[aiohttp.ClientSession] = []
async def async_step_user(self, user_input=None): async def async_step_user(self, user_input=None):
"""Handle the initial step.""" """Handle the initial step."""
@ -260,14 +261,26 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
def _get_octoprint_client(self, user_input: dict) -> OctoprintClient: def _get_octoprint_client(self, user_input: dict) -> OctoprintClient:
"""Build an octoprint client from the user_input.""" """Build an octoprint client from the user_input."""
verify_ssl = user_input.get(CONF_VERIFY_SSL, True) verify_ssl = user_input.get(CONF_VERIFY_SSL, True)
session = async_get_clientsession(self.hass, verify_ssl=verify_ssl)
return OctoprintClient( connector = aiohttp.TCPConnector(
user_input[CONF_HOST], force_close=True,
session, ssl=False if not verify_ssl else None,
user_input[CONF_PORT],
user_input[CONF_SSL],
user_input[CONF_PATH],
) )
session = aiohttp.ClientSession(connector=connector)
self._sessions.append(session)
return OctoprintClient(
host=user_input[CONF_HOST],
session=session,
port=user_input[CONF_PORT],
ssl=user_input[CONF_SSL],
path=user_input[CONF_PATH],
)
def async_remove(self):
"""Detach the session."""
for session in self._sessions:
session.detach()
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(exceptions.HomeAssistantError):

View File

@ -6,7 +6,7 @@
"documentation": "https://www.home-assistant.io/integrations/octoprint", "documentation": "https://www.home-assistant.io/integrations/octoprint",
"iot_class": "local_polling", "iot_class": "local_polling",
"loggers": ["pyoctoprintapi"], "loggers": ["pyoctoprintapi"],
"requirements": ["pyoctoprintapi==0.1.11"], "requirements": ["pyoctoprintapi==0.1.12"],
"ssdp": [ "ssdp": [
{ {
"manufacturer": "The OctoPrint Project", "manufacturer": "The OctoPrint Project",

View File

@ -6,5 +6,5 @@
"dependencies": ["recorder"], "dependencies": ["recorder"],
"documentation": "https://www.home-assistant.io/integrations/opower", "documentation": "https://www.home-assistant.io/integrations/opower",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"requirements": ["opower==0.0.29"] "requirements": ["opower==0.0.31"]
} }

View File

@ -18,5 +18,5 @@
"documentation": "https://www.home-assistant.io/integrations/reolink", "documentation": "https://www.home-assistant.io/integrations/reolink",
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["reolink_aio"], "loggers": ["reolink_aio"],
"requirements": ["reolink-aio==0.7.7"] "requirements": ["reolink-aio==0.7.8"]
} }

View File

@ -7,7 +7,7 @@ from typing import Final
APPLICATION_NAME: Final = "HomeAssistant" APPLICATION_NAME: Final = "HomeAssistant"
MAJOR_VERSION: Final = 2023 MAJOR_VERSION: Final = 2023
MINOR_VERSION: Final = 8 MINOR_VERSION: Final = 8
PATCH_VERSION: Final = "3" PATCH_VERSION: Final = "4"
__short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}" __short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__: Final = f"{__short_version__}.{PATCH_VERSION}" __version__: Final = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 11, 0) REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 11, 0)

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "homeassistant" name = "homeassistant"
version = "2023.8.3" version = "2023.8.4"
license = {text = "Apache-2.0"} license = {text = "Apache-2.0"}
description = "Open-source home automation platform running on Python 3." description = "Open-source home automation platform running on Python 3."
readme = "README.rst" readme = "README.rst"

View File

@ -399,7 +399,7 @@ amcrest==1.9.7
androidtv[async]==0.0.70 androidtv[async]==0.0.70
# homeassistant.components.androidtv_remote # homeassistant.components.androidtv_remote
androidtvremote2==0.0.13 androidtvremote2==0.0.14
# homeassistant.components.anel_pwrctrl # homeassistant.components.anel_pwrctrl
anel-pwrctrl-homeassistant==0.0.1.dev2 anel-pwrctrl-homeassistant==0.0.1.dev2
@ -1368,7 +1368,7 @@ openwrt-luci-rpc==1.1.16
openwrt-ubus-rpc==0.0.2 openwrt-ubus-rpc==0.0.2
# homeassistant.components.opower # homeassistant.components.opower
opower==0.0.29 opower==0.0.31
# homeassistant.components.oralb # homeassistant.components.oralb
oralb-ble==0.17.6 oralb-ble==0.17.6
@ -1809,7 +1809,7 @@ pylibrespot-java==0.1.1
pylitejet==0.5.0 pylitejet==0.5.0
# homeassistant.components.litterrobot # homeassistant.components.litterrobot
pylitterbot==2023.4.2 pylitterbot==2023.4.5
# homeassistant.components.lutron_caseta # homeassistant.components.lutron_caseta
pylutron-caseta==0.18.1 pylutron-caseta==0.18.1
@ -1884,7 +1884,7 @@ pynzbgetapi==0.2.0
pyobihai==1.4.2 pyobihai==1.4.2
# homeassistant.components.octoprint # homeassistant.components.octoprint
pyoctoprintapi==0.1.11 pyoctoprintapi==0.1.12
# homeassistant.components.ombi # homeassistant.components.ombi
pyombi==0.1.10 pyombi==0.1.10
@ -2278,7 +2278,7 @@ renault-api==0.1.13
renson-endura-delta==1.5.0 renson-endura-delta==1.5.0
# homeassistant.components.reolink # homeassistant.components.reolink
reolink-aio==0.7.7 reolink-aio==0.7.8
# homeassistant.components.idteck_prox # homeassistant.components.idteck_prox
rfk101py==0.0.1 rfk101py==0.0.1

View File

@ -368,7 +368,7 @@ amberelectric==1.0.4
androidtv[async]==0.0.70 androidtv[async]==0.0.70
# homeassistant.components.androidtv_remote # homeassistant.components.androidtv_remote
androidtvremote2==0.0.13 androidtvremote2==0.0.14
# homeassistant.components.anova # homeassistant.components.anova
anova-wifi==0.10.0 anova-wifi==0.10.0
@ -1037,7 +1037,7 @@ openerz-api==0.2.0
openhomedevice==2.2.0 openhomedevice==2.2.0
# homeassistant.components.opower # homeassistant.components.opower
opower==0.0.29 opower==0.0.31
# homeassistant.components.oralb # homeassistant.components.oralb
oralb-ble==0.17.6 oralb-ble==0.17.6
@ -1340,7 +1340,7 @@ pylibrespot-java==0.1.1
pylitejet==0.5.0 pylitejet==0.5.0
# homeassistant.components.litterrobot # homeassistant.components.litterrobot
pylitterbot==2023.4.2 pylitterbot==2023.4.5
# homeassistant.components.lutron_caseta # homeassistant.components.lutron_caseta
pylutron-caseta==0.18.1 pylutron-caseta==0.18.1
@ -1400,7 +1400,7 @@ pynzbgetapi==0.2.0
pyobihai==1.4.2 pyobihai==1.4.2
# homeassistant.components.octoprint # homeassistant.components.octoprint
pyoctoprintapi==0.1.11 pyoctoprintapi==0.1.12
# homeassistant.components.openuv # homeassistant.components.openuv
pyopenuv==2023.02.0 pyopenuv==2023.02.0
@ -1674,7 +1674,7 @@ renault-api==0.1.13
renson-endura-delta==1.5.0 renson-endura-delta==1.5.0
# homeassistant.components.reolink # homeassistant.components.reolink
reolink-aio==0.7.7 reolink-aio==0.7.8
# homeassistant.components.rflink # homeassistant.components.rflink
rflink==0.0.65 rflink==0.0.65