Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored May 4, 2023
2 parents c61e297 + eda0731 commit bce18bf
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 103 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/bluetooth/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"bleak==0.20.2",
"bleak-retry-connector==3.0.2",
"bluetooth-adapters==0.15.3",
"bluetooth-auto-recovery==1.1.1",
"bluetooth-auto-recovery==1.1.2",
"bluetooth-data-tools==0.4.0",
"dbus-fast==1.85.0"
]
Expand Down
9 changes: 0 additions & 9 deletions homeassistant/components/cloud/alexa_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from homeassistant.components.homeassistant.exposed_entities import (
async_expose_entity,
async_get_assistant_settings,
async_get_entity_settings,
async_listen_entity_updates,
async_should_expose,
)
Expand Down Expand Up @@ -201,21 +200,13 @@ def _migrate_alexa_entity_settings_v1(self):
return

for state in self.hass.states.async_all():
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, state.entity_id)
if CLOUD_ALEXA in entity_settings:
continue
async_expose_entity(
self.hass,
CLOUD_ALEXA,
state.entity_id,
self._should_expose_legacy(state.entity_id),
)
for entity_id in self._prefs.alexa_entity_configs:
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, entity_id)
if CLOUD_ALEXA in entity_settings:
continue
async_expose_entity(
self.hass,
CLOUD_ALEXA,
Expand Down
9 changes: 0 additions & 9 deletions homeassistant/components/cloud/google_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Google config for Cloud."""
import asyncio
from contextlib import suppress
from http import HTTPStatus
import logging
from typing import Any
Expand Down Expand Up @@ -178,10 +177,6 @@ def _migrate_google_entity_settings_v1(self):

for state in self.hass.states.async_all():
entity_id = state.entity_id
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, entity_id)
if CLOUD_GOOGLE in entity_settings:
continue
async_expose_entity(
self.hass,
CLOUD_GOOGLE,
Expand All @@ -197,10 +192,6 @@ def _migrate_google_entity_settings_v1(self):
_2fa_disabled,
)
for entity_id in self._prefs.google_entity_configs:
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, entity_id)
if CLOUD_GOOGLE in entity_settings:
continue
async_expose_entity(
self.hass,
CLOUD_GOOGLE,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/frontend/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"documentation": "https://www.home-assistant.io/integrations/frontend",
"integration_type": "system",
"quality_scale": "internal",
"requirements": ["home-assistant-frontend==20230503.1"]
"requirements": ["home-assistant-frontend==20230503.2"]
}
13 changes: 10 additions & 3 deletions homeassistant/components/lifx/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,20 @@ async def _async_populate_device_info(self) -> None:
methods, DEFAULT_ATTEMPTS, OVERALL_TIMEOUT
)

def get_number_of_zones(self) -> int:
"""Return the number of zones.
If the number of zones is not yet populated, return 0
"""
return len(self.device.color_zones) if self.device.color_zones else 0

@callback
def _async_build_color_zones_update_requests(self) -> list[Callable]:
"""Build a color zones update request."""
device = self.device
return [
partial(device.get_color_zones, start_index=zone)
for zone in range(0, len(device.color_zones), 8)
for zone in range(0, self.get_number_of_zones(), 8)
]

async def _async_update_data(self) -> None:
Expand All @@ -224,7 +231,7 @@ async def _async_update_data(self) -> None:
):
await self._async_populate_device_info()

num_zones = len(device.color_zones) if device.color_zones is not None else 0
num_zones = self.get_number_of_zones()
features = lifx_features(self.device)
is_extended_multizone = features["extended_multizone"]
is_legacy_multizone = not is_extended_multizone and features["multizone"]
Expand Down Expand Up @@ -256,7 +263,7 @@ async def _async_update_data(self) -> None:

if is_extended_multizone or is_legacy_multizone:
self.active_effect = FirmwareEffect[self.device.effect.get("effect", "OFF")]
if is_legacy_multizone and num_zones != len(device.color_zones):
if is_legacy_multizone and num_zones != self.get_number_of_zones():
# The number of zones has changed so we need
# to update the zones again. This happens rarely.
await self.async_get_color_zones()
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/lifx/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ async def set_color(
"""Send a color change to the bulb."""
bulb = self.bulb
color_zones = bulb.color_zones
num_zones = len(color_zones)
num_zones = self.coordinator.get_number_of_zones()

# Zone brightness is not reported when powered off
if not self.is_on and hsbk[HSBK_BRIGHTNESS] is None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/notion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"integration_type": "hub",
"iot_class": "cloud_polling",
"loggers": ["aionotion"],
"requirements": ["aionotion==2023.04.2"]
"requirements": ["aionotion==2023.05.0"]
}
155 changes: 89 additions & 66 deletions homeassistant/components/onvif/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import onvif
from onvif import ONVIFCamera
from onvif.exceptions import ONVIFError
from zeep.exceptions import Fault, XMLParseError
from zeep.exceptions import Fault, TransportError, XMLParseError, XMLSyntaxError

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand Down Expand Up @@ -203,81 +203,104 @@ async def async_check_date_and_time(self) -> None:
"""Warns if device and system date not synced."""
LOGGER.debug("%s: Setting up the ONVIF device management service", self.name)
device_mgmt = self.device.create_devicemgmt_service()
system_date = dt_util.utcnow()

LOGGER.debug("%s: Retrieving current device date/time", self.name)
try:
system_date = dt_util.utcnow()
device_time = await device_mgmt.GetSystemDateAndTime()
if not device_time:
LOGGER.debug(
"""Couldn't get device '%s' date/time.
GetSystemDateAndTime() return null/empty""",
self.name,
)
return
except RequestError as err:
LOGGER.warning(
"Couldn't get device '%s' date/time. Error: %s", self.name, err
)
return

LOGGER.debug("%s: Device time: %s", self.name, device_time)
if not device_time:
LOGGER.debug(
"""Couldn't get device '%s' date/time.
GetSystemDateAndTime() return null/empty""",
self.name,
)
return

tzone = dt_util.DEFAULT_TIME_ZONE
cdate = device_time.LocalDateTime
if device_time.UTCDateTime:
tzone = dt_util.UTC
cdate = device_time.UTCDateTime
elif device_time.TimeZone:
tzone = dt_util.get_time_zone(device_time.TimeZone.TZ) or tzone
LOGGER.debug("%s: Device time: %s", self.name, device_time)

if cdate is None:
LOGGER.warning(
"%s: Could not retrieve date/time on this camera", self.name
)
else:
cam_date = dt.datetime(
cdate.Date.Year,
cdate.Date.Month,
cdate.Date.Day,
cdate.Time.Hour,
cdate.Time.Minute,
cdate.Time.Second,
0,
tzone,
)
tzone = dt_util.DEFAULT_TIME_ZONE
cdate = device_time.LocalDateTime
if device_time.UTCDateTime:
tzone = dt_util.UTC
cdate = device_time.UTCDateTime
elif device_time.TimeZone:
tzone = dt_util.get_time_zone(device_time.TimeZone.TZ) or tzone

cam_date_utc = cam_date.astimezone(dt_util.UTC)
if cdate is None:
LOGGER.warning("%s: Could not retrieve date/time on this camera", self.name)
return

LOGGER.debug(
"%s: Device date/time: %s | System date/time: %s",
self.name,
cam_date_utc,
system_date,
)
cam_date = dt.datetime(
cdate.Date.Year,
cdate.Date.Month,
cdate.Date.Day,
cdate.Time.Hour,
cdate.Time.Minute,
cdate.Time.Second,
0,
tzone,
)

dt_diff = cam_date - system_date
self._dt_diff_seconds = dt_diff.total_seconds()
cam_date_utc = cam_date.astimezone(dt_util.UTC)

# It could be off either direction, so we need to check the absolute value
if abs(self._dt_diff_seconds) > 5:
LOGGER.warning(
(
"The date/time on %s (UTC) is '%s', "
"which is different from the system '%s', "
"this could lead to authentication issues"
),
self.name,
cam_date_utc,
system_date,
)
if device_time.DateTimeType == "Manual":
# Set Date and Time ourselves if Date and Time is set manually in the camera.
await self.async_manually_set_date_and_time()
except RequestError as err:
LOGGER.warning(
"Couldn't get device '%s' date/time. Error: %s", self.name, err
)
LOGGER.debug(
"%s: Device date/time: %s | System date/time: %s",
self.name,
cam_date_utc,
system_date,
)

dt_diff = cam_date - system_date
self._dt_diff_seconds = dt_diff.total_seconds()

# It could be off either direction, so we need to check the absolute value
if abs(self._dt_diff_seconds) < 5:
return

LOGGER.warning(
(
"The date/time on %s (UTC) is '%s', "
"which is different from the system '%s', "
"this could lead to authentication issues"
),
self.name,
cam_date_utc,
system_date,
)

if device_time.DateTimeType != "Manual":
return

# Set Date and Time ourselves if Date and Time is set manually in the camera.
try:
await self.async_manually_set_date_and_time()
except (RequestError, TransportError):
LOGGER.warning("%s: Could not sync date/time on this camera", self.name)

async def async_get_device_info(self) -> DeviceInfo:
"""Obtain information about this device."""
device_mgmt = self.device.create_devicemgmt_service()
device_info = await device_mgmt.GetDeviceInformation()
manufacturer = None
model = None
firmware_version = None
serial_number = None
try:
device_info = await device_mgmt.GetDeviceInformation()
except (XMLParseError, XMLSyntaxError, TransportError) as ex:
# Some cameras have invalid UTF-8 in their device information (TransportError)
# and others have completely invalid XML (XMLParseError, XMLSyntaxError)
LOGGER.warning("%s: Failed to fetch device information: %s", self.name, ex)
else:
manufacturer = device_info.Manufacturer
model = device_info.Model
firmware_version = device_info.FirmwareVersion
serial_number = device_info.SerialNumber

# Grab the last MAC address for backwards compatibility
mac = None
Expand All @@ -297,10 +320,10 @@ async def async_get_device_info(self) -> DeviceInfo:
)

return DeviceInfo(
device_info.Manufacturer,
device_info.Model,
device_info.FirmwareVersion,
device_info.SerialNumber,
manufacturer,
model,
firmware_version,
serial_number,
mac,
)

Expand Down Expand Up @@ -328,7 +351,7 @@ async def async_start_events(self):
"""Start the event handler."""
with suppress(*GET_CAPABILITIES_EXCEPTIONS, XMLParseError):
onvif_capabilities = self.onvif_capabilities or {}
pull_point_support = onvif_capabilities.get("Events", {}).get(
pull_point_support = (onvif_capabilities.get("Events") or {}).get(
"WSPullPointSupport"
)
LOGGER.debug("%s: WSPullPointSupport: %s", self.name, pull_point_support)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
APPLICATION_NAME: Final = "HomeAssistant"
MAJOR_VERSION: Final = 2023
MINOR_VERSION: Final = 5
PATCH_VERSION: Final = "0"
PATCH_VERSION: Final = "1"
__short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__: Final = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 10, 0)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bcrypt==4.0.1
bleak-retry-connector==3.0.2
bleak==0.20.2
bluetooth-adapters==0.15.3
bluetooth-auto-recovery==1.1.1
bluetooth-auto-recovery==1.1.2
bluetooth-data-tools==0.4.0
certifi>=2021.5.30
ciso8601==2.3.0
Expand All @@ -25,7 +25,7 @@ ha-av==10.0.0
hass-nabucasa==0.66.2
hassil==1.0.6
home-assistant-bluetooth==1.10.0
home-assistant-frontend==20230503.1
home-assistant-frontend==20230503.2
home-assistant-intents==2023.4.26
httpx==0.24.0
ifaddr==0.1.7
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "homeassistant"
version = "2023.5.0"
version = "2023.5.1"
license = {text = "Apache-2.0"}
description = "Open-source home automation platform running on Python 3."
readme = "README.rst"
Expand Down
6 changes: 3 additions & 3 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ aionanoleaf==0.2.1
aionotify==0.2.0

# homeassistant.components.notion
aionotion==2023.04.2
aionotion==2023.05.0

# homeassistant.components.oncue
aiooncue==0.3.4
Expand Down Expand Up @@ -465,7 +465,7 @@ bluemaestro-ble==0.2.3
bluetooth-adapters==0.15.3

# homeassistant.components.bluetooth
bluetooth-auto-recovery==1.1.1
bluetooth-auto-recovery==1.1.2

# homeassistant.components.bluetooth
# homeassistant.components.esphome
Expand Down Expand Up @@ -911,7 +911,7 @@ hole==0.8.0
holidays==0.21.13

# homeassistant.components.frontend
home-assistant-frontend==20230503.1
home-assistant-frontend==20230503.2

# homeassistant.components.conversation
home-assistant-intents==2023.4.26
Expand Down
Loading

0 comments on commit bce18bf

Please sign in to comment.