Skip to content

Commit

Permalink
2024.5.1 (#116696)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed May 3, 2024
2 parents 2f47668 + 9d2fd82 commit ab8a811
Show file tree
Hide file tree
Showing 37 changed files with 235 additions and 357 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Expand Up @@ -939,6 +939,7 @@ omit =
homeassistant/components/omnilogic/switch.py
homeassistant/components/ondilo_ico/__init__.py
homeassistant/components/ondilo_ico/api.py
homeassistant/components/ondilo_ico/coordinator.py
homeassistant/components/ondilo_ico/sensor.py
homeassistant/components/onkyo/media_player.py
homeassistant/components/onvif/__init__.py
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/airthings_ble/manifest.json
Expand Up @@ -24,5 +24,5 @@
"dependencies": ["bluetooth_adapters"],
"documentation": "https://www.home-assistant.io/integrations/airthings_ble",
"iot_class": "local_polling",
"requirements": ["airthings-ble==0.7.1"]
"requirements": ["airthings-ble==0.8.0"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/airthings_ble/sensor.py
Expand Up @@ -225,7 +225,7 @@ def __init__(
manufacturer=airthings_device.manufacturer,
hw_version=airthings_device.hw_version,
sw_version=airthings_device.sw_version,
model=airthings_device.model.name,
model=airthings_device.model.product_name,
)

@property
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bluetooth/manifest.json
Expand Up @@ -20,6 +20,6 @@
"bluetooth-auto-recovery==1.4.2",
"bluetooth-data-tools==1.19.0",
"dbus-fast==2.21.1",
"habluetooth==2.8.0"
"habluetooth==2.8.1"
]
}
7 changes: 5 additions & 2 deletions homeassistant/components/broadlink/remote.py
Expand Up @@ -373,8 +373,11 @@ async def _async_learn_rf_command(self, command):
start_time = dt_util.utcnow()
while (dt_util.utcnow() - start_time) < LEARNING_TIMEOUT:
await asyncio.sleep(1)
found = await device.async_request(device.api.check_frequency)[0]
if found:
is_found, frequency = await device.async_request(
device.api.check_frequency
)
if is_found:
_LOGGER.info("Radiofrequency detected: %s MHz", frequency)
break
else:
await device.async_request(device.api.cancel_sweep_frequency)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/elkm1/manifest.json
Expand Up @@ -15,5 +15,5 @@
"documentation": "https://www.home-assistant.io/integrations/elkm1",
"iot_class": "local_push",
"loggers": ["elkm1_lib"],
"requirements": ["elkm1-lib==2.2.6"]
"requirements": ["elkm1-lib==2.2.7"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/environment_canada/manifest.json
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/environment_canada",
"iot_class": "cloud_polling",
"loggers": ["env_canada"],
"requirements": ["env-canada==0.6.0"]
"requirements": ["env-canada==0.6.2"]
}
4 changes: 2 additions & 2 deletions homeassistant/components/govee_light_local/light.py
Expand Up @@ -17,7 +17,7 @@
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity

Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(
name=device.sku,
manufacturer=MANUFACTURER,
model=device.sku,
connections={(CONNECTION_NETWORK_MAC, device.fingerprint)},
serial_number=device.fingerprint,
)

@property
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/govee_light_local/manifest.json
Expand Up @@ -6,5 +6,5 @@
"dependencies": ["network"],
"documentation": "https://www.home-assistant.io/integrations/govee_light_local",
"iot_class": "local_push",
"requirements": ["govee-local-api==1.4.4"]
"requirements": ["govee-local-api==1.4.5"]
}
32 changes: 18 additions & 14 deletions homeassistant/components/homekit_controller/connection.py
Expand Up @@ -153,6 +153,7 @@ def __init__(
self._subscriptions: dict[tuple[int, int], set[CALLBACK_TYPE]] = {}
self._pending_subscribes: set[tuple[int, int]] = set()
self._subscribe_timer: CALLBACK_TYPE | None = None
self._load_platforms_lock = asyncio.Lock()

@property
def entity_map(self) -> Accessories:
Expand Down Expand Up @@ -327,7 +328,8 @@ async def async_setup(self) -> None:
)
# BLE devices always get an RSSI sensor as well
if "sensor" not in self.platforms:
await self._async_load_platforms({"sensor"})
async with self._load_platforms_lock:
await self._async_load_platforms({"sensor"})

@callback
def _async_start_polling(self) -> None:
Expand Down Expand Up @@ -804,6 +806,7 @@ def _add_new_entities(self, callbacks: list[AddServiceCb]) -> None:

async def _async_load_platforms(self, platforms: set[str]) -> None:
"""Load a group of platforms."""
assert self._load_platforms_lock.locked(), "Must be called with lock held"
if not (to_load := platforms - self.platforms):
return
self.platforms.update(to_load)
Expand All @@ -813,22 +816,23 @@ async def _async_load_platforms(self, platforms: set[str]) -> None:

async def async_load_platforms(self) -> None:
"""Load any platforms needed by this HomeKit device."""
to_load: set[str] = set()
for accessory in self.entity_map.accessories:
for service in accessory.services:
if service.type in HOMEKIT_ACCESSORY_DISPATCH:
platform = HOMEKIT_ACCESSORY_DISPATCH[service.type]
if platform not in self.platforms:
to_load.add(platform)

for char in service.characteristics:
if char.type in CHARACTERISTIC_PLATFORMS:
platform = CHARACTERISTIC_PLATFORMS[char.type]
async with self._load_platforms_lock:
to_load: set[str] = set()
for accessory in self.entity_map.accessories:
for service in accessory.services:
if service.type in HOMEKIT_ACCESSORY_DISPATCH:
platform = HOMEKIT_ACCESSORY_DISPATCH[service.type]
if platform not in self.platforms:
to_load.add(platform)

if to_load:
await self._async_load_platforms(to_load)
for char in service.characteristics:
if char.type in CHARACTERISTIC_PLATFORMS:
platform = CHARACTERISTIC_PLATFORMS[char.type]
if platform not in self.platforms:
to_load.add(platform)

if to_load:
await self._async_load_platforms(to_load)

@callback
def async_update_available_state(self, *_: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/knx/notify.py
Expand Up @@ -97,7 +97,7 @@ def _create_notification_instance(xknx: XKNX, config: ConfigType) -> XknxNotific
)


class KNXNotify(NotifyEntity, KnxEntity):
class KNXNotify(KnxEntity, NotifyEntity):
"""Representation of a KNX notification entity."""

_device: XknxNotification
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/matter/light.py
Expand Up @@ -398,6 +398,8 @@ def _update_from_device(self) -> None:
def _check_transition_blocklist(self) -> None:
"""Check if this device is reported to have non working transitions."""
device_info = self._endpoint.device_info
if isinstance(device_info, clusters.BridgedDeviceBasicInformation):
return
if (
device_info.vendorID,
device_info.productID,
Expand Down
16 changes: 12 additions & 4 deletions homeassistant/components/mqtt/client.py
Expand Up @@ -83,7 +83,7 @@

_LOGGER = logging.getLogger(__name__)

DISCOVERY_COOLDOWN = 2
DISCOVERY_COOLDOWN = 5
INITIAL_SUBSCRIBE_COOLDOWN = 1.0
SUBSCRIBE_COOLDOWN = 0.1
UNSUBSCRIBE_COOLDOWN = 0.1
Expand Down Expand Up @@ -349,6 +349,12 @@ def _async_execute(self) -> None:
self._task = create_eager_task(self._async_job())
self._task.add_done_callback(self._async_task_done)

async def async_fire(self) -> None:
"""Execute the job immediately."""
if self._task:
await self._task
self._async_execute()

@callback
def _async_cancel_timer(self) -> None:
"""Cancel any pending task."""
Expand Down Expand Up @@ -846,7 +852,7 @@ async def _async_perform_subscriptions(self) -> None:

for topic, qos in subscriptions.items():
_LOGGER.debug("Subscribing to %s, mid: %s, qos: %s", topic, mid, qos)
self._last_subscribe = time.time()
self._last_subscribe = time.monotonic()

if result == 0:
await self._wait_for_mid(mid)
Expand Down Expand Up @@ -876,6 +882,8 @@ async def _async_resubscribe_and_publish_birth_message(
await self._ha_started.wait() # Wait for Home Assistant to start
await self._discovery_cooldown() # Wait for MQTT discovery to cool down
# Update subscribe cooldown period to a shorter time
# and make sure we flush the debouncer
await self._subscribe_debouncer.async_fire()
self._subscribe_debouncer.set_timeout(SUBSCRIBE_COOLDOWN)
await self.async_publish(
topic=birth_message.topic,
Expand Down Expand Up @@ -1121,7 +1129,7 @@ async def _wait_for_mid(self, mid: int) -> None:

async def _discovery_cooldown(self) -> None:
"""Wait until all discovery and subscriptions are processed."""
now = time.time()
now = time.monotonic()
# Reset discovery and subscribe cooldowns
self._mqtt_data.last_discovery = now
self._last_subscribe = now
Expand All @@ -1133,7 +1141,7 @@ async def _discovery_cooldown(self) -> None:
)
while now < wait_until:
await asyncio.sleep(wait_until - now)
now = time.time()
now = time.monotonic()
last_discovery = self._mqtt_data.last_discovery
last_subscribe = (
now if self._pending_subscriptions else self._last_subscribe
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/mqtt/discovery.py
Expand Up @@ -177,7 +177,7 @@ async def _async_component_setup(discovery_payload: MQTTDiscoveryPayload) -> Non
@callback
def async_discovery_message_received(msg: ReceiveMessage) -> None: # noqa: C901
"""Process the received message."""
mqtt_data.last_discovery = time.time()
mqtt_data.last_discovery = time.monotonic()
payload = msg.payload
topic = msg.topic
topic_trimmed = topic.replace(f"{discovery_topic}/", "", 1)
Expand Down Expand Up @@ -370,7 +370,7 @@ def discovery_done(_: Any) -> None:
)
)

mqtt_data.last_discovery = time.time()
mqtt_data.last_discovery = time.monotonic()
mqtt_integrations = await async_get_mqtt(hass)

for integration, topics in mqtt_integrations.items():
Expand Down

0 comments on commit ab8a811

Please sign in to comment.