Bump pydeconz to v88 (#69369)

pull/69438/head
Robert Svensson 2022-04-05 22:44:04 +02:00 committed by GitHub
parent da55c48cce
commit d6d7f3cb3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 86 additions and 82 deletions

View File

@ -1,8 +1,6 @@
"""Support for deCONZ alarm control panel devices."""
from __future__ import annotations
from collections.abc import ValuesView
from pydeconz.alarm_system import AlarmSystem
from pydeconz.sensor import (
ANCILLARY_CONTROL_ARMED_AWAY,
@ -81,12 +79,14 @@ async def async_setup_entry(
@callback
def async_add_alarm_control_panel(
sensors: list[AncillaryControl]
| ValuesView[AncillaryControl] = gateway.api.sensors.values(),
sensors: list[AncillaryControl] | None = None,
) -> None:
"""Add alarm control panel devices from deCONZ."""
entities = []
if sensors is None:
sensors = list(gateway.api.sensors.ancillary_control.values())
for sensor in sensors:
if (
@ -143,7 +143,7 @@ class DeconzAlarmControlPanel(DeconzDevice, AlarmControlPanelEntity):
keys = {"panel", "reachable"}
if (
self._device.changed_keys.intersection(keys)
and self._device.state in DECONZ_TO_ALARM_STATE
and self._device.panel in DECONZ_TO_ALARM_STATE
):
super().async_update_callback()

View File

@ -1,17 +1,17 @@
"""Support for deCONZ binary sensors."""
from __future__ import annotations
from collections.abc import Callable, ValuesView
from collections.abc import Callable
from dataclasses import dataclass
from pydeconz.sensor import (
Alarm,
CarbonMonoxide,
DeconzSensor as PydeconzSensor,
Fire,
GenericFlag,
OpenClose,
Presence,
SensorBase as PydeconzSensor,
Vibration,
Water,
)
@ -178,13 +178,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_sensor(
sensors: list[PydeconzSensor]
| ValuesView[PydeconzSensor] = gateway.api.sensors.values(),
) -> None:
def async_add_sensor(sensors: list[PydeconzSensor] | None = None) -> None:
"""Add binary sensor from deCONZ."""
entities: list[DeconzBinarySensor] = []
if sensors is None:
sensors = gateway.api.sensors.values()
for sensor in sensors:
if not gateway.option_allow_clip_sensor and sensor.type.startswith("CLIP"):

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import ValuesView
from dataclasses import dataclass
from pydeconz.group import Scene as PydeconzScene
@ -58,13 +57,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_scene(
scenes: list[PydeconzScene]
| ValuesView[PydeconzScene] = gateway.api.scenes.values(),
) -> None:
def async_add_scene(scenes: list[PydeconzScene] | None = None) -> None:
"""Add scene button from deCONZ."""
entities = []
if scenes is None:
scenes = list(gateway.api.scenes.values())
for scene in scenes:
known_entities = set(gateway.entities[DOMAIN])

View File

@ -1,7 +1,6 @@
"""Support for deCONZ climate devices."""
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any
from pydeconz.sensor import (
@ -107,13 +106,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_climate(
sensors: list[Thermostat]
| ValuesView[Thermostat] = gateway.api.sensors.values(),
) -> None:
def async_add_climate(sensors: list[Thermostat] | None = None) -> None:
"""Add climate devices from deCONZ."""
entities: list[DeconzThermostat] = []
if sensors is None:
sensors = list(gateway.api.sensors.thermostat.values())
for sensor in sensors:
if not gateway.option_allow_clip_sensor and sensor.type.startswith("CLIP"):
@ -245,7 +244,7 @@ class DeconzThermostat(DeconzDevice, ClimateEntity):
@property
def current_temperature(self) -> float:
"""Return the current temperature."""
return self._device.temperature # type: ignore[no-any-return]
return self._device.scaled_temperature # type: ignore[no-any-return]
@property
def target_temperature(self) -> float | None:

View File

@ -30,7 +30,6 @@ from .const import (
CONF_ALLOW_CLIP_SENSOR,
CONF_ALLOW_DECONZ_GROUPS,
CONF_ALLOW_NEW_DEVICES,
CONF_BRIDGE_ID,
DEFAULT_PORT,
DOMAIN,
HASSIO_CONFIGURATION_URL,
@ -86,7 +85,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
for bridge in self.bridges:
if bridge[CONF_HOST] == user_input[CONF_HOST]:
self.bridge_id = cast(str, bridge[CONF_BRIDGE_ID])
self.bridge_id = cast(str, bridge["id"])
self.deconz_config = {
CONF_HOST: bridge[CONF_HOST],
CONF_PORT: bridge[CONF_PORT],

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any, cast
from pydeconz.light import Cover
@ -47,12 +46,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_cover(
lights: list[Cover] | ValuesView[Cover] = gateway.api.lights.values(),
) -> None:
def async_add_cover(lights: list[Cover] | None = None) -> None:
"""Add cover from deCONZ."""
entities = []
if lights is None:
lights = list(gateway.api.lights.covers.values())
for light in lights:
if (
isinstance(light, Cover)

View File

@ -3,8 +3,8 @@
from __future__ import annotations
from pydeconz.group import Group as DeconzGroup, Scene as PydeconzScene
from pydeconz.light import DeconzLight
from pydeconz.sensor import DeconzSensor
from pydeconz.light import LightBase as DeconzLight
from pydeconz.sensor import SensorBase as DeconzSensor
from homeassistant.core import callback
from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE

View File

@ -43,12 +43,15 @@ async def async_setup_events(gateway: DeconzGateway) -> None:
@callback
def async_add_sensor(
sensors: AncillaryControl | Switch = gateway.api.sensors.values(),
sensors: AncillaryControl | Switch | None = None,
) -> None:
"""Create DeconzEvent."""
new_events = []
known_events = {event.unique_id for event in gateway.events}
if sensors is None:
sensors = gateway.api.sensors.values()
for sensor in sensors:
if not gateway.option_allow_clip_sensor and sensor.type.startswith("CLIP"):
@ -130,7 +133,7 @@ class DeconzEvent(DeconzBase):
data = {
CONF_ID: self.event_id,
CONF_UNIQUE_ID: self.serial,
CONF_EVENT: self._device.state,
CONF_EVENT: self._device.button_event,
}
if self.device_id:

View File

@ -1,7 +1,6 @@
"""Support for deCONZ fans."""
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any
from pydeconz.light import (
@ -44,12 +43,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_fan(
lights: list[Fan] | ValuesView[Fan] = gateway.api.lights.values(),
) -> None:
def async_add_fan(lights: list[Fan] | None = None) -> None:
"""Add fan from deCONZ."""
entities = []
if lights is None:
lights = list(gateway.api.lights.fans.values())
for light in lights:
if (

View File

@ -10,8 +10,8 @@ import async_timeout
from pydeconz import DeconzSession, errors, group, light, sensor
from pydeconz.alarm_system import AlarmSystem as DeconzAlarmSystem
from pydeconz.group import Group as DeconzGroup
from pydeconz.light import DeconzLight
from pydeconz.sensor import DeconzSensor
from pydeconz.light import LightBase as DeconzLight
from pydeconz.sensor import SensorBase as DeconzSensor
from homeassistant.config_entries import SOURCE_HASSIO, ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any
from pydeconz.group import Group
@ -62,12 +61,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_light(
lights: list[Light] | ValuesView[Light] = gateway.api.lights.values(),
) -> None:
def async_add_light(lights: list[Light] | None = None) -> None:
"""Add light from deCONZ."""
entities = []
if lights is None:
lights = gateway.api.lights.values()
for light in lights:
if (
isinstance(light, Light)
@ -88,15 +88,16 @@ async def async_setup_entry(
)
@callback
def async_add_group(
groups: list[Group] | ValuesView[Group] = gateway.api.groups.values(),
) -> None:
def async_add_group(groups: list[Group] | None = None) -> None:
"""Add group from deCONZ."""
if not gateway.option_allow_deconz_groups:
return
entities = []
if groups is None:
groups = list(gateway.api.groups.values())
for group in groups:
if not group.lights:
continue

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any
from pydeconz.light import Lock
@ -28,12 +27,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_lock_from_light(
lights: list[Lock] | ValuesView[Lock] = gateway.api.lights.values(),
) -> None:
def async_add_lock_from_light(lights: list[Lock] | None = None) -> None:
"""Add lock from deCONZ."""
entities = []
if lights is None:
lights = list(gateway.api.lights.locks.values())
for light in lights:
if (
@ -54,12 +54,13 @@ async def async_setup_entry(
)
@callback
def async_add_lock_from_sensor(
sensors: list[DoorLock] | ValuesView[DoorLock] = gateway.api.sensors.values(),
) -> None:
def async_add_lock_from_sensor(sensors: list[DoorLock] | None = None) -> None:
"""Add lock from deCONZ."""
entities = []
if sensors is None:
sensors = list(gateway.api.sensors.door_lock.values())
for sensor in sensors:
if (

View File

@ -3,7 +3,7 @@
"name": "deCONZ",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/deconz",
"requirements": ["pydeconz==87"],
"requirements": ["pydeconz==88"],
"ssdp": [
{
"manufacturer": "Royal Philips Electronics"

View File

@ -2,10 +2,10 @@
from __future__ import annotations
from collections.abc import Callable, ValuesView
from collections.abc import Callable
from dataclasses import dataclass
from pydeconz.sensor import PRESENCE_DELAY, DeconzSensor as PydeconzSensor, Presence
from pydeconz.sensor import PRESENCE_DELAY, Presence, SensorBase as PydeconzSensor
from homeassistant.components.number import (
DOMAIN,
@ -62,12 +62,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_sensor(
sensors: list[Presence] | ValuesView[Presence] = gateway.api.sensors.values(),
) -> None:
def async_add_sensor(sensors: list[Presence] | None = None) -> None:
"""Add number config sensor from deCONZ."""
entities = []
if sensors is None:
sensors = list(gateway.api.sensors.presence.values())
for sensor in sensors:
if sensor.type.startswith("CLIP"):

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any
from pydeconz.group import Scene as PydeconzScene
@ -27,13 +26,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_scene(
scenes: list[PydeconzScene]
| ValuesView[PydeconzScene] = gateway.api.scenes.values(),
) -> None:
def async_add_scene(scenes: list[PydeconzScene] | None = None) -> None:
"""Add scene from deCONZ."""
entities = []
if scenes is None:
scenes = list(gateway.api.scenes.values())
for scene in scenes:
known_entities = set(gateway.entities[DOMAIN])

View File

@ -1,7 +1,7 @@
"""Support for deCONZ sensors."""
from __future__ import annotations
from collections.abc import Callable, ValuesView
from collections.abc import Callable
from dataclasses import dataclass
from datetime import datetime
@ -9,12 +9,12 @@ from pydeconz.sensor import (
AirQuality,
Consumption,
Daylight,
DeconzSensor as PydeconzSensor,
GenericStatus,
Humidity,
LightLevel,
Power,
Pressure,
SensorBase as PydeconzSensor,
Switch,
Temperature,
Time,
@ -174,7 +174,7 @@ ENTITY_DESCRIPTIONS = {
Temperature: [
DeconzSensorDescription(
key="temperature",
value_fn=lambda device: device.temperature, # type: ignore[no-any-return]
value_fn=lambda device: device.scaled_temperature, # type: ignore[no-any-return]
update_key="temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
@ -227,10 +227,7 @@ async def async_setup_entry(
battery_handler = DeconzBatteryHandler(gateway)
@callback
def async_add_sensor(
sensors: list[PydeconzSensor]
| ValuesView[PydeconzSensor] = gateway.api.sensors.values(),
) -> None:
def async_add_sensor(sensors: list[PydeconzSensor] | None = None) -> None:
"""Add sensors from deCONZ.
Create DeconzBattery if sensor has a battery attribute.
@ -238,6 +235,9 @@ async def async_setup_entry(
"""
entities: list[DeconzSensor] = []
if sensors is None:
sensors = gateway.api.sensors.values()
for sensor in sensors:
if not gateway.option_allow_clip_sensor and sensor.type.startswith("CLIP"):

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any
from pydeconz.light import Siren
@ -34,12 +33,13 @@ async def async_setup_entry(
gateway.entities[DOMAIN] = set()
@callback
def async_add_siren(
lights: list[Siren] | ValuesView[Siren] = gateway.api.lights.values(),
) -> None:
def async_add_siren(lights: list[Siren] | None = None) -> None:
"""Add siren from deCONZ."""
entities = []
if lights is None:
lights = list(gateway.api.lights.sirens.values())
for light in lights:
if (

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import ValuesView
from typing import Any
from pydeconz.light import Light, Siren
@ -34,7 +33,7 @@ async def async_setup_entry(
entity_registry = er.async_get(hass)
# Siren platform replacing sirens in switch platform added in 2021.10
for light in gateway.api.lights.values():
for light in gateway.api.lights.sirens.values():
if isinstance(light, Siren) and (
entity_id := entity_registry.async_get_entity_id(
DOMAIN, DECONZ_DOMAIN, light.unique_id
@ -43,12 +42,13 @@ async def async_setup_entry(
entity_registry.async_remove(entity_id)
@callback
def async_add_switch(
lights: list[Light] | ValuesView[Light] = gateway.api.lights.values(),
) -> None:
def async_add_switch(lights: list[Light] | None = None) -> None:
"""Add switch from deCONZ."""
entities = []
if lights is None:
lights = list(gateway.api.lights.lights.values())
for light in lights:
if (

View File

@ -1423,7 +1423,7 @@ pydaikin==2.7.0
pydanfossair==0.1.0
# homeassistant.components.deconz
pydeconz==87
pydeconz==88
# homeassistant.components.delijn
pydelijn==1.0.0

View File

@ -944,7 +944,7 @@ pycoolmasternet-async==0.1.2
pydaikin==2.7.0
# homeassistant.components.deconz
pydeconz==87
pydeconz==88
# homeassistant.components.dexcom
pydexcom==0.2.3

View File

@ -675,7 +675,7 @@ async def test_add_new_binary_sensor_ignored(
)
aioclient_mock.clear_requests()
data = {"groups": {}, "lights": {}, "sensors": {"1": sensor}}
data = {"config": {}, "groups": {}, "lights": {}, "sensors": {"1": sensor}}
mock_deconz_request(aioclient_mock, config_entry.data, data)
await hass.services.async_call(DECONZ_DOMAIN, SERVICE_DEVICE_REFRESH)

View File

@ -217,6 +217,7 @@ async def test_service_refresh_devices(hass, aioclient_mock):
aioclient_mock.clear_requests()
data = {
"config": {},
"groups": {
"1": {
"id": "Group 1 id",
@ -280,6 +281,7 @@ async def test_service_refresh_devices_trigger_no_state_update(hass, aioclient_m
aioclient_mock.clear_requests()
data = {
"config": {},
"groups": {
"1": {
"id": "Group 1 id",