Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Caius-Bonus authored Oct 2, 2023
2 parents 6849291 + 4e4b8de commit ae937dd
Show file tree
Hide file tree
Showing 88 changed files with 2,093 additions and 940 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
name: requirements_diff

- name: Build wheels
uses: home-assistant/wheels@2023.09.1
uses: home-assistant/wheels@2023.10.1
with:
abi: ${{ matrix.abi }}
tag: musllinux_1_2
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
sed -i "/numpy/d" homeassistant/package_constraints.txt
- name: Build wheels (part 1)
uses: home-assistant/wheels@2023.09.1
uses: home-assistant/wheels@2023.10.1
with:
abi: ${{ matrix.abi }}
tag: musllinux_1_2
Expand All @@ -194,7 +194,7 @@ jobs:
requirements: "requirements_all.txtaa"

- name: Build wheels (part 2)
uses: home-assistant/wheels@2023.09.1
uses: home-assistant/wheels@2023.10.1
with:
abi: ${{ matrix.abi }}
tag: musllinux_1_2
Expand All @@ -208,7 +208,7 @@ jobs:
requirements: "requirements_all.txtab"

- name: Build wheels (part 3)
uses: home-assistant/wheels@2023.09.1
uses: home-assistant/wheels@2023.10.1
with:
abi: ${{ matrix.abi }}
tag: musllinux_1_2
Expand Down
16 changes: 0 additions & 16 deletions docs/source/api/util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ homeassistant.util.decorator
:undoc-members:
:show-inheritance:

homeassistant.util.distance
---------------------------

.. automodule:: homeassistant.util.distance
:members:
:undoc-members:
:show-inheritance:

homeassistant.util.dt
---------------------

Expand Down Expand Up @@ -141,11 +133,3 @@ homeassistant.util.unit\_system
:members:
:undoc-members:
:show-inheritance:

homeassistant.util.volume
-------------------------

.. automodule:: homeassistant.util.volume
:members:
:undoc-members:
:show-inheritance:
14 changes: 7 additions & 7 deletions homeassistant/components/abode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Support for the Abode Security System."""
from __future__ import annotations

from dataclasses import dataclass, field
from functools import partial

from jaraco.abode.automation import Automation as AbodeAuto
Expand All @@ -25,7 +26,7 @@
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import Event, HomeAssistant, ServiceCall
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, ServiceCall
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv, entity
from homeassistant.helpers.device_registry import DeviceInfo
Expand Down Expand Up @@ -71,15 +72,14 @@
]


@dataclass
class AbodeSystem:
"""Abode System class."""

def __init__(self, abode: Abode, polling: bool) -> None:
"""Initialize the system."""
self.abode = abode
self.polling = polling
self.entity_ids: set[str | None] = set()
self.logout_listener = None
abode: Abode
polling: bool
entity_ids: set[str | None] = field(default_factory=set)
logout_listener: CALLBACK_TYPE | None = None


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
10 changes: 10 additions & 0 deletions homeassistant/components/calendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ def async_write_ha_state(self) -> None:

for unsub in self._alarm_unsubs:
unsub()
self._alarm_unsubs.clear()

now = dt_util.now()
event = self.event
Expand All @@ -540,6 +541,7 @@ def async_write_ha_state(self) -> None:
@callback
def update(_: datetime.datetime) -> None:
"""Run when the active or upcoming event starts or ends."""
_LOGGER.debug("Running %s update", self.entity_id)
self._async_write_ha_state()

if now < event.start_datetime_local:
Expand All @@ -553,6 +555,13 @@ def update(_: datetime.datetime) -> None:
self._alarm_unsubs.append(
async_track_point_in_time(self.hass, update, event.end_datetime_local)
)
_LOGGER.debug(
"Scheduled %d updates for %s (%s, %s)",
len(self._alarm_unsubs),
self.entity_id,
event.start_datetime_local,
event.end_datetime_local,
)

async def async_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass.
Expand All @@ -561,6 +570,7 @@ async def async_will_remove_from_hass(self) -> None:
"""
for unsub in self._alarm_unsubs:
unsub()
self._alarm_unsubs.clear()

async def async_get_events(
self,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/co2signal/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

from collections.abc import Mapping
from datetime import timedelta
from json import JSONDecodeError
import logging
from typing import Any, cast

import CO2Signal
from requests.exceptions import JSONDecodeError

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
Expand Down
41 changes: 33 additions & 8 deletions homeassistant/components/comelit/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from aiocomelit import ComelitSerialBridgeObject
from aiocomelit.const import COVER, COVER_CLOSE, COVER_OPEN, COVER_STATUS

from homeassistant.components.cover import CoverDeviceClass, CoverEntity
from homeassistant.components.cover import STATE_CLOSED, CoverDeviceClass, CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import DOMAIN
Expand All @@ -32,7 +33,9 @@ async def async_setup_entry(
)


class ComelitCoverEntity(CoordinatorEntity[ComelitSerialBridge], CoverEntity):
class ComelitCoverEntity(
CoordinatorEntity[ComelitSerialBridge], RestoreEntity, CoverEntity
):
"""Cover device."""

_attr_device_class = CoverDeviceClass.SHUTTER
Expand All @@ -51,8 +54,9 @@ def __init__(
super().__init__(coordinator)
self._attr_unique_id = f"{config_entry_entry_id}-{device.index}"
self._attr_device_info = coordinator.platform_device_info(device, COVER)
# Device doesn't provide a status so we assume CLOSE at startup
self._last_action = COVER_STATUS.index("closing")
# Device doesn't provide a status so we assume UNKNOWN at first startup
self._last_action: int | None = None
self._last_state: str | None = None

def _current_action(self, action: str) -> bool:
"""Return the current cover action."""
Expand All @@ -67,12 +71,19 @@ def device_status(self) -> int:
return self.coordinator.data[COVER][self._device.index].status

@property
def is_closed(self) -> bool:
"""Return True if cover is closed."""
def is_closed(self) -> bool | None:
"""Return if the cover is closed."""

if self._last_state in [None, "unknown"]:
return None

if self.device_status != COVER_STATUS.index("stopped"):
return False

return bool(self._last_action == COVER_STATUS.index("closing"))
if self._last_action:
return self._last_action == COVER_STATUS.index("closing")

return self._last_state == STATE_CLOSED

@property
def is_closing(self) -> bool:
Expand All @@ -99,3 +110,17 @@ async def async_stop_cover(self, **_kwargs: Any) -> None:

action = COVER_OPEN if self.is_closing else COVER_CLOSE
await self._api.cover_move(self._device.index, action)

@callback
def _handle_coordinator_update(self) -> None:
"""Handle device update."""
self._last_state = self.state
self.async_write_ha_state()

async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""

await super().async_added_to_hass()

if last_state := await self.async_get_last_state():
self._last_state = last_state.state
2 changes: 2 additions & 0 deletions homeassistant/components/command_line/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
{
vol.Required(CONF_COMMAND): cv.string,
vol.Optional(CONF_NAME, default=BINARY_SENSOR_DEFAULT_NAME): cv.string,
vol.Optional(CONF_ICON): cv.template,
vol.Optional(CONF_PAYLOAD_OFF, default=DEFAULT_PAYLOAD_OFF): cv.string,
vol.Optional(CONF_PAYLOAD_ON, default=DEFAULT_PAYLOAD_ON): cv.string,
vol.Optional(CONF_DEVICE_CLASS): BINARY_SENSOR_DEVICE_CLASSES_SCHEMA,
Expand Down Expand Up @@ -119,6 +120,7 @@
vol.Optional(CONF_COMMAND_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
vol.Optional(CONF_JSON_ATTRIBUTES): cv.ensure_list_csv,
vol.Optional(CONF_NAME, default=SENSOR_DEFAULT_NAME): cv.string,
vol.Optional(CONF_ICON): cv.template,
vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string,
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
vol.Optional(CONF_UNIQUE_ID): cv.string,
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/command_line/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from homeassistant.const import (
CONF_COMMAND,
CONF_DEVICE_CLASS,
CONF_ICON,
CONF_NAME,
CONF_PAYLOAD_OFF,
CONF_PAYLOAD_ON,
Expand Down Expand Up @@ -86,6 +87,7 @@ async def async_setup_platform(
device_class: BinarySensorDeviceClass | None = binary_sensor_config.get(
CONF_DEVICE_CLASS
)
icon: Template | None = binary_sensor_config.get(CONF_ICON)
value_template: Template | None = binary_sensor_config.get(CONF_VALUE_TEMPLATE)
command_timeout: int = binary_sensor_config[CONF_COMMAND_TIMEOUT]
unique_id: str | None = binary_sensor_config.get(CONF_UNIQUE_ID)
Expand All @@ -100,6 +102,7 @@ async def async_setup_platform(
CONF_UNIQUE_ID: unique_id,
CONF_NAME: Template(name, hass),
CONF_DEVICE_CLASS: device_class,
CONF_ICON: icon,
}

async_add_entities(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/denonavr/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"documentation": "https://www.home-assistant.io/integrations/denonavr",
"iot_class": "local_push",
"loggers": ["denonavr"],
"requirements": ["denonavr==0.11.3"],
"requirements": ["denonavr==0.11.4"],
"ssdp": [
{
"manufacturer": "Denon",
Expand Down
35 changes: 31 additions & 4 deletions homeassistant/components/denonavr/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
from typing import Any, Concatenate, ParamSpec, TypeVar

from denonavr import DenonAVR
from denonavr.const import POWER_ON, STATE_OFF, STATE_ON, STATE_PAUSED, STATE_PLAYING
from denonavr.const import (
ALL_TELNET_EVENTS,
ALL_ZONES,
POWER_ON,
STATE_OFF,
STATE_ON,
STATE_PAUSED,
STATE_PLAYING,
)
from denonavr.exceptions import (
AvrCommandError,
AvrForbiddenError,
Expand Down Expand Up @@ -73,6 +81,23 @@
SERVICE_SET_DYNAMIC_EQ = "set_dynamic_eq"
SERVICE_UPDATE_AUDYSSEY = "update_audyssey"

# HA Telnet events
TELNET_EVENTS = {
"HD",
"MS",
"MU",
"MV",
"NS",
"NSE",
"PS",
"SI",
"SS",
"TF",
"ZM",
"Z2",
"Z3",
}

_DenonDeviceT = TypeVar("_DenonDeviceT", bound="DenonDevice")
_R = TypeVar("_R")
_P = ParamSpec("_P")
Expand Down Expand Up @@ -254,7 +279,9 @@ def __init__(
async def _telnet_callback(self, zone, event, parameter) -> None:
"""Process a telnet command callback."""
# There are multiple checks implemented which reduce unnecessary updates of the ha state machine
if zone != self._receiver.zone:
if zone not in (self._receiver.zone, ALL_ZONES):
return
if event not in TELNET_EVENTS:
return
# Some updates trigger multiple events like one for artist and one for title for one change
# We skip every event except the last one
Expand All @@ -268,11 +295,11 @@ async def _telnet_callback(self, zone, event, parameter) -> None:

async def async_added_to_hass(self) -> None:
"""Register for telnet events."""
self._receiver.register_callback("ALL", self._telnet_callback)
self._receiver.register_callback(ALL_TELNET_EVENTS, self._telnet_callback)

async def async_will_remove_from_hass(self) -> None:
"""Clean up the entity."""
self._receiver.unregister_callback("ALL", self._telnet_callback)
self._receiver.unregister_callback(ALL_TELNET_EVENTS, self._telnet_callback)

@async_log_errors
async def async_update(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/esphome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"loggers": ["aioesphomeapi", "noiseprotocol"],
"requirements": [
"async-interrupt==1.1.1",
"aioesphomeapi==17.0.0",
"aioesphomeapi==17.0.1",
"bluetooth-data-tools==1.12.0",
"esphome-dashboard-api==1.2.3"
],
Expand Down
Loading

0 comments on commit ae937dd

Please sign in to comment.