Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Apr 22, 2023
2 parents b05fcd7 + d58f62c commit cdbdf1b
Show file tree
Hide file tree
Showing 26 changed files with 1,027 additions and 373 deletions.
1 change: 0 additions & 1 deletion homeassistant/components/calendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ def _validate_rrule(value: Any) -> str:
},
_has_same_type("start", "end"),
_has_timezone("start", "end"),
_has_consistent_timezone("start", "end"),
_as_local_timezone("start", "end"),
_has_min_duration("start", "end", MIN_EVENT_DURATION),
),
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/edl21/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"integration_type": "hub",
"iot_class": "local_push",
"loggers": ["sml"],
"requirements": ["pysml==0.0.9"]
"requirements": ["pysml==0.0.10"]
}
25 changes: 19 additions & 6 deletions homeassistant/components/homewizard/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from homewizard_energy import HomeWizardEnergy
from homewizard_energy.const import SUPPORTS_IDENTIFY, SUPPORTS_STATE, SUPPORTS_SYSTEM
from homewizard_energy.errors import DisabledError, RequestError
from homewizard_energy.errors import DisabledError, RequestError, UnsupportedError
from homewizard_energy.models import Device

from homeassistant.config_entries import ConfigEntry
Expand All @@ -24,6 +24,8 @@ class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]
api: HomeWizardEnergy
api_disabled: bool = False

_unsupported_error: bool = False

def __init__(
self,
hass: HomeAssistant,
Expand All @@ -43,11 +45,22 @@ async def _async_update_data(self) -> DeviceResponseEntry:
data=await self.api.data(),
)

if self.supports_state(data.device):
data.state = await self.api.state()

if self.supports_system(data.device):
data.system = await self.api.system()
try:
if self.supports_state(data.device):
data.state = await self.api.state()

if self.supports_system(data.device):
data.system = await self.api.system()

except UnsupportedError as ex:
# Old firmware, ignore
if not self._unsupported_error:
self._unsupported_error = True
_LOGGER.warning(
"%s is running an outdated firmware version (%s). Contact HomeWizard support to update your device",
self.entry.title,
ex,
)

except RequestError as ex:
raise UpdateFailed(ex) from ex
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/insteon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"iot_class": "local_push",
"loggers": ["pyinsteon", "pypubsub"],
"requirements": [
"pyinsteon==1.4.1",
"pyinsteon==1.4.2",
"insteon-frontend-home-assistant==0.3.4"
],
"usb": [
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/litterrobot/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"integration_type": "hub",
"iot_class": "cloud_push",
"loggers": ["pylitterbot"],
"requirements": ["pylitterbot==2023.1.2"]
"requirements": ["pylitterbot==2023.4.0"]
}
8 changes: 7 additions & 1 deletion homeassistant/components/media_source/local_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def __init__(self, hass: HomeAssistant) -> None:
@callback
def async_full_path(self, source_dir_id: str, location: str) -> Path:
"""Return full path."""
return Path(self.hass.config.media_dirs[source_dir_id], location)
base_path = self.hass.config.media_dirs[source_dir_id]
full_path = Path(base_path, location)
full_path.relative_to(base_path)
return full_path

@callback
def async_parse_identifier(self, item: MediaSourceItem) -> tuple[str, str]:
Expand All @@ -65,6 +68,9 @@ def async_parse_identifier(self, item: MediaSourceItem) -> tuple[str, str]:
except ValueError as err:
raise Unresolvable("Invalid path.") from err

if Path(location).is_absolute():
raise Unresolvable("Invalid path.")

return source_dir_id, location

async def async_resolve_media(self, item: MediaSourceItem) -> PlayMedia:
Expand Down
9 changes: 0 additions & 9 deletions homeassistant/components/mqtt_statestream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@

async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the MQTT state feed."""
# Make sure MQTT is available and the entry is loaded
if not hass.config_entries.async_entries(
mqtt.DOMAIN
) or not await hass.config_entries.async_wait_component(
hass.config_entries.async_entries(mqtt.DOMAIN)[0]
):
_LOGGER.error("MQTT integration is not available")
return False

conf: ConfigType = config[DOMAIN]
publish_filter = convert_include_exclude_filter(conf)
base_topic: str = conf[CONF_BASE_TOPIC]
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/recorder/history/modern.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ def state_changes_during_period(
if entity_id:
instance = recorder.get_instance(hass)
metadata_id = instance.states_meta_manager.get(entity_id, session, False)
if metadata_id is None:
return {}
entity_id_to_metadata_id = {entity_id: metadata_id}
stmt = _state_changed_during_period_stmt(
start_time,
Expand All @@ -394,7 +396,7 @@ def state_changes_during_period(
states,
start_time,
entity_ids,
entity_id_to_metadata_id,
entity_id_to_metadata_id, # type: ignore[arg-type]
include_start_time_state=include_start_time_state,
),
)
Expand Down
22 changes: 14 additions & 8 deletions homeassistant/components/recorder/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from dataclasses import dataclass, replace as dataclass_replace
from datetime import timedelta
import logging
from time import time
from typing import TYPE_CHECKING, cast
from uuid import UUID

Expand All @@ -26,7 +27,7 @@

from homeassistant.core import HomeAssistant
from homeassistant.util.enum import try_parse_enum
from homeassistant.util.ulid import ulid_to_bytes
from homeassistant.util.ulid import ulid_at_time, ulid_to_bytes

from .auto_repairs.events.schema import (
correct_db_schema as events_correct_db_schema,
Expand Down Expand Up @@ -92,7 +93,6 @@
from . import Recorder

LIVE_MIGRATION_MIN_SCHEMA_VERSION = 0
_EMPTY_CONTEXT_ID = b"\x00" * 16
_EMPTY_ENTITY_ID = "missing.entity_id"
_EMPTY_EVENT_TYPE = "missing_event_type"

Expand Down Expand Up @@ -1364,13 +1364,17 @@ def _context_id_to_bytes(context_id: str | None) -> bytes | None:
# ULIDs that filled the column to the max length
# so we need to catch the ValueError and return
# None if it happens
if len(context_id) == 32:
return UUID(context_id).bytes
if len(context_id) == 26:
return ulid_to_bytes(context_id)
return UUID(context_id).bytes
return None


def _generate_ulid_bytes_at_time(timestamp: float | None) -> bytes:
"""Generate a ulid with a specific timestamp."""
return ulid_to_bytes(ulid_at_time(timestamp or time()))


@retryable_database_job("migrate states context_ids to binary format")
def migrate_states_context_ids(instance: Recorder) -> bool:
"""Migrate states context_ids to use binary format."""
Expand All @@ -1385,13 +1389,14 @@ def migrate_states_context_ids(instance: Recorder) -> bool:
{
"state_id": state_id,
"context_id": None,
"context_id_bin": _to_bytes(context_id) or _EMPTY_CONTEXT_ID,
"context_id_bin": _to_bytes(context_id)
or _generate_ulid_bytes_at_time(last_updated_ts),
"context_user_id": None,
"context_user_id_bin": _to_bytes(context_user_id),
"context_parent_id": None,
"context_parent_id_bin": _to_bytes(context_parent_id),
}
for state_id, context_id, context_user_id, context_parent_id in states
for state_id, last_updated_ts, context_id, context_user_id, context_parent_id in states
],
)
# If there is more work to do return False
Expand Down Expand Up @@ -1419,13 +1424,14 @@ def migrate_events_context_ids(instance: Recorder) -> bool:
{
"event_id": event_id,
"context_id": None,
"context_id_bin": _to_bytes(context_id) or _EMPTY_CONTEXT_ID,
"context_id_bin": _to_bytes(context_id)
or _generate_ulid_bytes_at_time(time_fired_ts),
"context_user_id": None,
"context_user_id_bin": _to_bytes(context_user_id),
"context_parent_id": None,
"context_parent_id_bin": _to_bytes(context_parent_id),
}
for event_id, context_id, context_user_id, context_parent_id in events
for event_id, time_fired_ts, context_id, context_user_id, context_parent_id in events
],
)
# If there is more work to do return False
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/recorder/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ def find_events_context_ids_to_migrate() -> StatementLambdaElement:
return lambda_stmt(
lambda: select(
Events.event_id,
Events.time_fired_ts,
Events.context_id,
Events.context_user_id,
Events.context_parent_id,
Expand Down Expand Up @@ -788,6 +789,7 @@ def find_states_context_ids_to_migrate() -> StatementLambdaElement:
return lambda_stmt(
lambda: select(
States.state_id,
States.last_updated_ts,
States.context_id,
States.context_user_id,
States.context_parent_id,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/renault/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"loggers": ["renault_api"],
"quality_scale": "platinum",
"requirements": ["renault-api==0.1.12"]
"requirements": ["renault-api==0.1.13"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/shelly/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"iot_class": "local_push",
"loggers": ["aioshelly"],
"quality_scale": "platinum",
"requirements": ["aioshelly==5.3.1"],
"requirements": ["aioshelly==5.3.2"],
"zeroconf": [
{
"type": "_http._tcp.local.",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/songpal/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"iot_class": "local_push",
"loggers": ["songpal"],
"quality_scale": "gold",
"requirements": ["python-songpal==0.15.1"],
"requirements": ["python-songpal==0.15.2"],
"ssdp": [
{
"st": "urn:schemas-sony-com:service:ScalarWebAPI:1",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/todoist/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def create_todoist_task(self, data: Task):
LABELS: [],
OVERDUE: False,
PRIORITY: data.priority,
START: dt.utcnow(),
START: dt.now(),
SUMMARY: data.content,
}

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 = 4
PATCH_VERSION: Final = "5"
PATCH_VERSION: Final = "6"
__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
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.4.5"
version = "2023.4.6"
license = {text = "Apache-2.0"}
description = "Open-source home automation platform running on Python 3."
readme = "README.rst"
Expand Down
12 changes: 6 additions & 6 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ aiosenseme==0.6.1
aiosenz==1.0.0

# homeassistant.components.shelly
aioshelly==5.3.1
aioshelly==5.3.2

# homeassistant.components.skybell
aioskybell==22.7.0
Expand Down Expand Up @@ -1684,7 +1684,7 @@ pyialarm==2.2.0
pyicloud==1.0.0

# homeassistant.components.insteon
pyinsteon==1.4.1
pyinsteon==1.4.2

# homeassistant.components.intesishome
pyintesishome==1.8.0
Expand Down Expand Up @@ -1753,7 +1753,7 @@ pylibrespot-java==0.1.1
pylitejet==0.5.0

# homeassistant.components.litterrobot
pylitterbot==2023.1.2
pylitterbot==2023.4.0

# homeassistant.components.lutron_caseta
pylutron-caseta==0.18.1
Expand Down Expand Up @@ -1976,7 +1976,7 @@ pysmartthings==0.7.6
pysmarty==0.8

# homeassistant.components.edl21
pysml==0.0.9
pysml==0.0.10

# homeassistant.components.snmp
pysnmplib==5.0.21
Expand Down Expand Up @@ -2106,7 +2106,7 @@ python-ripple-api==0.0.3
python-smarttub==0.0.33

# homeassistant.components.songpal
python-songpal==0.15.1
python-songpal==0.15.2

# homeassistant.components.tado
python-tado==0.12.0
Expand Down Expand Up @@ -2228,7 +2228,7 @@ raspyrfm-client==1.2.8
regenmaschine==2022.11.0

# homeassistant.components.renault
renault-api==0.1.12
renault-api==0.1.13

# homeassistant.components.reolink
reolink-aio==0.5.10
Expand Down
12 changes: 6 additions & 6 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ aiosenseme==0.6.1
aiosenz==1.0.0

# homeassistant.components.shelly
aioshelly==5.3.1
aioshelly==5.3.2

# homeassistant.components.skybell
aioskybell==22.7.0
Expand Down Expand Up @@ -1218,7 +1218,7 @@ pyialarm==2.2.0
pyicloud==1.0.0

# homeassistant.components.insteon
pyinsteon==1.4.1
pyinsteon==1.4.2

# homeassistant.components.ipma
pyipma==3.0.6
Expand Down Expand Up @@ -1269,7 +1269,7 @@ pylibrespot-java==0.1.1
pylitejet==0.5.0

# homeassistant.components.litterrobot
pylitterbot==2023.1.2
pylitterbot==2023.4.0

# homeassistant.components.lutron_caseta
pylutron-caseta==0.18.1
Expand Down Expand Up @@ -1438,7 +1438,7 @@ pysmartapp==0.3.3
pysmartthings==0.7.6

# homeassistant.components.edl21
pysml==0.0.9
pysml==0.0.10

# homeassistant.components.snmp
pysnmplib==5.0.21
Expand Down Expand Up @@ -1508,7 +1508,7 @@ python-picnic-api==1.1.0
python-smarttub==0.0.33

# homeassistant.components.songpal
python-songpal==0.15.1
python-songpal==0.15.2

# homeassistant.components.tado
python-tado==0.12.0
Expand Down Expand Up @@ -1591,7 +1591,7 @@ radiotherm==2.1.0
regenmaschine==2022.11.0

# homeassistant.components.renault
renault-api==0.1.12
renault-api==0.1.13

# homeassistant.components.reolink
reolink-aio==0.5.10
Expand Down
Loading

0 comments on commit cdbdf1b

Please sign in to comment.