Bump aioesphomeapi to 19.0.0 (#104512)

pull/103960/head
J. Nick Koston 2023-11-25 14:00:04 -06:00 committed by GitHub
parent 837f34c40c
commit fc5ae50e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 5 deletions

View File

@ -27,7 +27,12 @@ import voluptuous as vol
from homeassistant.components import tag, zeroconf
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_DEVICE_ID, CONF_MODE, EVENT_HOMEASSISTANT_STOP
from homeassistant.const import (
ATTR_DEVICE_ID,
CONF_MODE,
EVENT_HOMEASSISTANT_STOP,
EVENT_LOGGING_CHANGED,
)
from homeassistant.core import (
CALLBACK_TYPE,
Event,
@ -545,6 +550,11 @@ class ESPHomeManager:
):
self.entry.async_start_reauth(self.hass)
@callback
def _async_handle_logging_changed(self, _event: Event) -> None:
"""Handle when the logging level changes."""
self.cli.set_debug(_LOGGER.isEnabledFor(logging.DEBUG))
async def async_start(self) -> None:
"""Start the esphome connection manager."""
hass = self.hass
@ -561,6 +571,11 @@ class ESPHomeManager:
entry_data.cleanup_callbacks.append(
hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, self.on_stop)
)
entry_data.cleanup_callbacks.append(
hass.bus.async_listen(
EVENT_LOGGING_CHANGED, self._async_handle_logging_changed
)
)
reconnect_logic = ReconnectLogic(
client=self.cli,

View File

@ -16,7 +16,7 @@
"loggers": ["aioesphomeapi", "noiseprotocol"],
"requirements": [
"async-interrupt==1.1.1",
"aioesphomeapi==18.5.9",
"aioesphomeapi==19.0.0",
"bluetooth-data-tools==1.15.0",
"esphome-dashboard-api==1.2.3"
],

View File

@ -236,7 +236,7 @@ aioelectricitymaps==0.1.5
aioemonitor==1.0.5
# homeassistant.components.esphome
aioesphomeapi==18.5.9
aioesphomeapi==19.0.0
# homeassistant.components.flo
aioflo==2021.11.0

View File

@ -215,7 +215,7 @@ aioelectricitymaps==0.1.5
aioemonitor==1.0.5
# homeassistant.components.esphome
aioesphomeapi==18.5.9
aioesphomeapi==19.0.0
# homeassistant.components.flo
aioflo==2021.11.0

View File

@ -1,6 +1,6 @@
"""Test ESPHome manager."""
from collections.abc import Awaitable, Callable
from unittest.mock import AsyncMock
from unittest.mock import AsyncMock, call
from aioesphomeapi import APIClient, DeviceInfo, EntityInfo, EntityState, UserService
import pytest
@ -16,6 +16,7 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import issue_registry as ir
from homeassistant.setup import async_setup_component
from .conftest import MockESPHomeDevice
@ -332,3 +333,39 @@ async def test_connection_aborted_wrong_device(
await hass.async_block_till_done()
assert len(new_info.mock_calls) == 1
assert "Unexpected device found at" not in caplog.text
async def test_debug_logging(
mock_client: APIClient,
hass: HomeAssistant,
mock_generic_device_entry: Callable[
[APIClient, list[EntityInfo], list[UserService], list[EntityState]],
Awaitable[MockConfigEntry],
],
) -> None:
"""Test enabling and disabling debug logging."""
assert await async_setup_component(hass, "logger", {"logger": {}})
await mock_generic_device_entry(
mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
)
await hass.services.async_call(
"logger",
"set_level",
{"homeassistant.components.esphome": "DEBUG"},
blocking=True,
)
await hass.async_block_till_done()
mock_client.set_debug.assert_has_calls([call(True)])
mock_client.reset_mock()
await hass.services.async_call(
"logger",
"set_level",
{"homeassistant.components.esphome": "WARNING"},
blocking=True,
)
await hass.async_block_till_done()
mock_client.set_debug.assert_has_calls([call(False)])