Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/esphome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"mqtt": ["esphome/discover/#"],
"quality_scale": "platinum",
"requirements": [
"aioesphomeapi==37.0.1",
"aioesphomeapi==37.0.2",
"esphome-dashboard-api==1.3.0",
"bleak-esphome==3.1.0"
],
Expand Down
42 changes: 42 additions & 0 deletions homeassistant/components/huum/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Sensor for door state."""

from __future__ import annotations

from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback

from .coordinator import HuumConfigEntry, HuumDataUpdateCoordinator
from .entity import HuumBaseEntity


async def async_setup_entry(
hass: HomeAssistant,
config_entry: HuumConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up door sensor."""
async_add_entities(
[HuumDoorSensor(config_entry.runtime_data)],
)


class HuumDoorSensor(HuumBaseEntity, BinarySensorEntity):
"""Representation of a BinarySensor."""

_attr_name = "Door"
_attr_device_class = BinarySensorDeviceClass.DOOR

def __init__(self, coordinator: HuumDataUpdateCoordinator) -> None:
"""Initialize the BinarySensor."""
super().__init__(coordinator)

self._attr_unique_id = f"{coordinator.config_entry.entry_id}_door"

@property
def is_on(self) -> bool | None:
"""Return the current value."""
return not self.coordinator.data.door_closed
2 changes: 1 addition & 1 deletion homeassistant/components/huum/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

DOMAIN = "huum"

PLATFORMS = [Platform.CLIMATE]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE]
6 changes: 0 additions & 6 deletions homeassistant/components/onkyo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ async def async_setup(hass: HomeAssistant, _: ConfigType) -> bool:

async def async_setup_entry(hass: HomeAssistant, entry: OnkyoConfigEntry) -> bool:
"""Set up the Onkyo config entry."""
entry.async_on_unload(entry.add_update_listener(update_listener))

host = entry.data[CONF_HOST]

Expand Down Expand Up @@ -82,8 +81,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: OnkyoConfigEntry) -> bo
receiver.conn.close()

return unload_ok


async def update_listener(hass: HomeAssistant, entry: OnkyoConfigEntry) -> None:
"""Handle options update."""
await hass.config_entries.async_reload(entry.entry_id)
6 changes: 3 additions & 3 deletions homeassistant/components/onkyo/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
OptionsFlowWithReload,
)
from homeassistant.const import CONF_HOST
from homeassistant.core import callback
Expand Down Expand Up @@ -329,7 +329,7 @@ async def async_step_reconfigure(

@staticmethod
@callback
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlowWithReload:
"""Return the options flow."""
return OnkyoOptionsFlowHandler()

Expand Down Expand Up @@ -357,7 +357,7 @@ def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
)


class OnkyoOptionsFlowHandler(OptionsFlow):
class OnkyoOptionsFlowHandler(OptionsFlowWithReload):
"""Handle an options flow for Onkyo."""

_data: dict[str, Any]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/unifiprotect/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"integration_type": "hub",
"iot_class": "local_push",
"loggers": ["uiprotect", "unifi_discovery"],
"requirements": ["uiprotect==7.14.2", "unifi-discovery==1.2.0"],
"requirements": ["uiprotect==7.15.1", "unifi-discovery==1.2.0"],
"ssdp": [
{
"manufacturer": "Ubiquiti Networks",
Expand Down
8 changes: 0 additions & 8 deletions homeassistant/components/vodafone_station/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) ->

entry.runtime_data = coordinator

entry.async_on_unload(entry.add_update_listener(update_listener))

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

return True
Expand All @@ -39,9 +37,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) ->
await coordinator.api.logout()

return unload_ok


async def update_listener(hass: HomeAssistant, entry: VodafoneConfigEntry) -> None:
"""Update when config_entry options update."""
if entry.options:
await hass.config_entries.async_reload(entry.entry_id)
8 changes: 6 additions & 2 deletions homeassistant/components/vodafone_station/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
CONF_CONSIDER_HOME,
DEFAULT_CONSIDER_HOME,
)
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow
from homeassistant.config_entries import (
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithReload,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback

Expand Down Expand Up @@ -180,7 +184,7 @@ async def async_step_reconfigure(
)


class VodafoneStationOptionsFlowHandler(OptionsFlow):
class VodafoneStationOptionsFlowHandler(OptionsFlowWithReload):
"""Handle a option flow."""

async def async_step_init(
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions tests/components/huum/snapshots/test_binary_sensor.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# serializer version: 1
# name: test_binary_sensor[binary_sensor.huum_sauna_door-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.huum_sauna_door',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Door',
'platform': 'huum',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'AABBCC112233_door',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensor[binary_sensor.huum_sauna_door-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Huum sauna Door',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.huum_sauna_door',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
29 changes: 29 additions & 0 deletions tests/components/huum/test_binary_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Tests for the Huum climate entity."""

from unittest.mock import AsyncMock

from syrupy.assertion import SnapshotAssertion

from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er

from . import setup_with_selected_platforms

from tests.common import MockConfigEntry, snapshot_platform

ENTITY_ID = "binary_sensor.huum_sauna_door"


async def test_binary_sensor(
hass: HomeAssistant,
mock_huum: AsyncMock,
mock_config_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test the initial parameters."""
await setup_with_selected_platforms(
hass, mock_config_entry, [Platform.BINARY_SENSOR]
)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
20 changes: 0 additions & 20 deletions tests/components/onkyo/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@ async def test_load_unload_entry(
assert config_entry.state is ConfigEntryState.NOT_LOADED


async def test_update_entry(
hass: HomeAssistant,
config_entry: MockConfigEntry,
) -> None:
"""Test update options."""

with patch.object(hass.config_entries, "async_reload", return_value=True):
config_entry = create_empty_config_entry()
receiver_info = create_receiver_info(1)
await setup_integration(hass, config_entry, receiver_info)

# Force option change
assert hass.config_entries.async_update_entry(
config_entry, options={"option": "new_value"}
)
await hass.async_block_till_done()

hass.config_entries.async_reload.assert_called_with(config_entry.entry_id)


async def test_no_connection(
hass: HomeAssistant,
config_entry: MockConfigEntry,
Expand Down
Loading