Bump pywemo==0.8.1 (#72400)
This commit is contained in:
parent
070cb61631
commit
f0b9aa7894
12 changed files with 39 additions and 36 deletions
|
@ -1,6 +1,5 @@
|
||||||
"""Support for WeMo binary sensors."""
|
"""Support for WeMo binary sensors."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
from pywemo import Insight, Maker, StandbyState
|
from pywemo import Insight, Maker, StandbyState
|
||||||
|
|
||||||
|
@ -49,20 +48,21 @@ class MakerBinarySensor(WemoEntity, BinarySensorEntity):
|
||||||
"""Maker device's sensor port."""
|
"""Maker device's sensor port."""
|
||||||
|
|
||||||
_name_suffix = "Sensor"
|
_name_suffix = "Sensor"
|
||||||
|
wemo: Maker
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if the Maker's sensor is pulled low."""
|
"""Return true if the Maker's sensor is pulled low."""
|
||||||
return cast(int, self.wemo.has_sensor) != 0 and self.wemo.sensor_state == 0
|
return self.wemo.has_sensor != 0 and self.wemo.sensor_state == 0
|
||||||
|
|
||||||
|
|
||||||
class InsightBinarySensor(WemoBinarySensor):
|
class InsightBinarySensor(WemoBinarySensor):
|
||||||
"""Sensor representing the device connected to the Insight Switch."""
|
"""Sensor representing the device connected to the Insight Switch."""
|
||||||
|
|
||||||
_name_suffix = "Device"
|
_name_suffix = "Device"
|
||||||
|
wemo: Insight
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true device connected to the Insight Switch is on."""
|
"""Return true device connected to the Insight Switch is on."""
|
||||||
# Note: wemo.get_standby_state is a @property.
|
return super().is_on and self.wemo.standby_state == StandbyState.ON
|
||||||
return super().is_on and self.wemo.get_standby_state == StandbyState.ON
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
from pywemo.exceptions import ActionException
|
from pywemo.exceptions import ActionException
|
||||||
|
|
||||||
|
@ -89,4 +88,4 @@ class WemoBinaryStateEntity(WemoEntity):
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if the state is on."""
|
"""Return true if the state is on."""
|
||||||
return cast(int, self.wemo.get_state()) != 0
|
return self.wemo.get_state() != 0
|
||||||
|
|
|
@ -6,7 +6,7 @@ from datetime import timedelta
|
||||||
import math
|
import math
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pywemo.ouimeaux_device.humidifier import DesiredHumidity, FanMode, Humidifier
|
from pywemo import DesiredHumidity, FanMode, Humidifier
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Any, Optional, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from pywemo.ouimeaux_device import bridge
|
from pywemo import Bridge, BridgeLight, Dimmer
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
|
@ -40,7 +40,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
async def _discovered_wemo(coordinator: DeviceCoordinator) -> None:
|
async def _discovered_wemo(coordinator: DeviceCoordinator) -> None:
|
||||||
"""Handle a discovered Wemo device."""
|
"""Handle a discovered Wemo device."""
|
||||||
if isinstance(coordinator.wemo, bridge.Bridge):
|
if isinstance(coordinator.wemo, Bridge):
|
||||||
async_setup_bridge(hass, config_entry, async_add_entities, coordinator)
|
async_setup_bridge(hass, config_entry, async_add_entities, coordinator)
|
||||||
else:
|
else:
|
||||||
async_add_entities([WemoDimmer(coordinator)])
|
async_add_entities([WemoDimmer(coordinator)])
|
||||||
|
@ -70,7 +70,8 @@ def async_setup_bridge(
|
||||||
"""Check to see if the bridge has any new lights."""
|
"""Check to see if the bridge has any new lights."""
|
||||||
new_lights = []
|
new_lights = []
|
||||||
|
|
||||||
for light_id, light in coordinator.wemo.Lights.items():
|
bridge = cast(Bridge, coordinator.wemo)
|
||||||
|
for light_id, light in bridge.Lights.items():
|
||||||
if light_id not in known_light_ids:
|
if light_id not in known_light_ids:
|
||||||
known_light_ids.add(light_id)
|
known_light_ids.add(light_id)
|
||||||
new_lights.append(WemoLight(coordinator, light))
|
new_lights.append(WemoLight(coordinator, light))
|
||||||
|
@ -87,7 +88,7 @@ class WemoLight(WemoEntity, LightEntity):
|
||||||
|
|
||||||
_attr_supported_features = LightEntityFeature.TRANSITION
|
_attr_supported_features = LightEntityFeature.TRANSITION
|
||||||
|
|
||||||
def __init__(self, coordinator: DeviceCoordinator, light: bridge.Light) -> None:
|
def __init__(self, coordinator: DeviceCoordinator, light: BridgeLight) -> None:
|
||||||
"""Initialize the WeMo light."""
|
"""Initialize the WeMo light."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.light = light
|
self.light = light
|
||||||
|
@ -97,17 +98,17 @@ class WemoLight(WemoEntity, LightEntity):
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the device if any."""
|
"""Return the name of the device if any."""
|
||||||
return cast(str, self.light.name)
|
return self.light.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return true if the device is available."""
|
"""Return true if the device is available."""
|
||||||
return super().available and self.light.state.get("available")
|
return super().available and self.light.state.get("available", False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return the ID of this light."""
|
"""Return the ID of this light."""
|
||||||
return cast(str, self.light.uniqueID)
|
return self.light.uniqueID
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
|
@ -123,17 +124,17 @@ class WemoLight(WemoEntity, LightEntity):
|
||||||
@property
|
@property
|
||||||
def brightness(self) -> int:
|
def brightness(self) -> int:
|
||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
return cast(int, self.light.state.get("level", 255))
|
return self.light.state.get("level", 255)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def xy_color(self) -> tuple[float, float] | None:
|
def xy_color(self) -> tuple[float, float] | None:
|
||||||
"""Return the xy color value [float, float]."""
|
"""Return the xy color value [float, float]."""
|
||||||
return self.light.state.get("color_xy") # type:ignore[no-any-return]
|
return self.light.state.get("color_xy")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self) -> int | None:
|
def color_temp(self) -> int | None:
|
||||||
"""Return the color temperature of this light in mireds."""
|
"""Return the color temperature of this light in mireds."""
|
||||||
return cast(Optional[int], self.light.state.get("temperature_mireds"))
|
return self.light.state.get("temperature_mireds")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_mode(self) -> ColorMode:
|
def color_mode(self) -> ColorMode:
|
||||||
|
@ -166,7 +167,7 @@ class WemoLight(WemoEntity, LightEntity):
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
return cast(int, self.light.state.get("onoff")) != WEMO_OFF
|
return self.light.state.get("onoff", WEMO_OFF) != WEMO_OFF
|
||||||
|
|
||||||
def turn_on(self, **kwargs: Any) -> None:
|
def turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
|
@ -210,6 +211,7 @@ class WemoDimmer(WemoBinaryStateEntity, LightEntity):
|
||||||
|
|
||||||
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
_attr_color_mode = ColorMode.BRIGHTNESS
|
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
|
wemo: Dimmer
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self) -> int:
|
def brightness(self) -> int:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "Belkin WeMo",
|
"name": "Belkin WeMo",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/wemo",
|
"documentation": "https://www.home-assistant.io/integrations/wemo",
|
||||||
"requirements": ["pywemo==0.7.0"],
|
"requirements": ["pywemo==0.8.1"],
|
||||||
"ssdp": [
|
"ssdp": [
|
||||||
{
|
{
|
||||||
"manufacturer": "Belkin International Inc."
|
"manufacturer": "Belkin International Inc."
|
||||||
|
|
|
@ -3,9 +3,9 @@ from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any, cast
|
from typing import Any
|
||||||
|
|
||||||
from pywemo import CoffeeMaker, Insight, Maker, StandbyState
|
from pywemo import CoffeeMaker, Insight, Maker, StandbyState, Switch
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -58,6 +58,9 @@ async def async_setup_entry(
|
||||||
class WemoSwitch(WemoBinaryStateEntity, SwitchEntity):
|
class WemoSwitch(WemoBinaryStateEntity, SwitchEntity):
|
||||||
"""Representation of a WeMo switch."""
|
"""Representation of a WeMo switch."""
|
||||||
|
|
||||||
|
# All wemo devices used with WemoSwitch are subclasses of Switch.
|
||||||
|
wemo: Switch
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the state attributes of the device."""
|
"""Return the state attributes of the device."""
|
||||||
|
@ -103,10 +106,9 @@ class WemoSwitch(WemoBinaryStateEntity, SwitchEntity):
|
||||||
def detail_state(self) -> str:
|
def detail_state(self) -> str:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
if isinstance(self.wemo, CoffeeMaker):
|
if isinstance(self.wemo, CoffeeMaker):
|
||||||
return cast(str, self.wemo.mode_string)
|
return self.wemo.mode_string
|
||||||
if isinstance(self.wemo, Insight):
|
if isinstance(self.wemo, Insight):
|
||||||
# Note: wemo.get_standby_state is a @property.
|
standby_state = self.wemo.standby_state
|
||||||
standby_state = self.wemo.get_standby_state
|
|
||||||
if standby_state == StandbyState.ON:
|
if standby_state == StandbyState.ON:
|
||||||
return STATE_ON
|
return STATE_ON
|
||||||
if standby_state == StandbyState.OFF:
|
if standby_state == StandbyState.OFF:
|
||||||
|
|
|
@ -3,7 +3,7 @@ import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pywemo import Insight, WeMoDevice
|
from pywemo import Insight, LongPressMixin, WeMoDevice
|
||||||
from pywemo.exceptions import ActionException
|
from pywemo.exceptions import ActionException
|
||||||
from pywemo.subscribe import EVENT_TYPE_LONG_PRESS
|
from pywemo.subscribe import EVENT_TYPE_LONG_PRESS
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ async def async_register_device(
|
||||||
registry.on(wemo, None, device.subscription_callback)
|
registry.on(wemo, None, device.subscription_callback)
|
||||||
await hass.async_add_executor_job(registry.register, wemo)
|
await hass.async_add_executor_job(registry.register, wemo)
|
||||||
|
|
||||||
if device.supports_long_press:
|
if isinstance(wemo, LongPressMixin):
|
||||||
try:
|
try:
|
||||||
await hass.async_add_executor_job(wemo.ensure_long_press_virtual_device)
|
await hass.async_add_executor_job(wemo.ensure_long_press_virtual_device)
|
||||||
# Temporarily handling all exceptions for #52996 & pywemo/pywemo/issues/276
|
# Temporarily handling all exceptions for #52996 & pywemo/pywemo/issues/276
|
||||||
|
|
|
@ -2017,7 +2017,7 @@ pyvolumio==0.1.5
|
||||||
pywebpush==1.9.2
|
pywebpush==1.9.2
|
||||||
|
|
||||||
# homeassistant.components.wemo
|
# homeassistant.components.wemo
|
||||||
pywemo==0.7.0
|
pywemo==0.8.1
|
||||||
|
|
||||||
# homeassistant.components.wilight
|
# homeassistant.components.wilight
|
||||||
pywilight==0.0.70
|
pywilight==0.0.70
|
||||||
|
|
|
@ -1337,7 +1337,7 @@ pyvolumio==0.1.5
|
||||||
pywebpush==1.9.2
|
pywebpush==1.9.2
|
||||||
|
|
||||||
# homeassistant.components.wemo
|
# homeassistant.components.wemo
|
||||||
pywemo==0.7.0
|
pywemo==0.8.1
|
||||||
|
|
||||||
# homeassistant.components.wilight
|
# homeassistant.components.wilight
|
||||||
pywilight==0.0.70
|
pywilight==0.0.70
|
||||||
|
|
|
@ -69,7 +69,7 @@ def create_pywemo_device(pywemo_registry, pywemo_model):
|
||||||
device.supports_long_press.return_value = cls.supports_long_press()
|
device.supports_long_press.return_value = cls.supports_long_press()
|
||||||
|
|
||||||
if issubclass(cls, pywemo.Insight):
|
if issubclass(cls, pywemo.Insight):
|
||||||
device.get_standby_state = pywemo.StandbyState.OFF
|
device.standby_state = pywemo.StandbyState.OFF
|
||||||
device.current_power_watts = MOCK_INSIGHT_CURRENT_WATTS
|
device.current_power_watts = MOCK_INSIGHT_CURRENT_WATTS
|
||||||
device.today_kwh = MOCK_INSIGHT_TODAY_KWH
|
device.today_kwh = MOCK_INSIGHT_TODAY_KWH
|
||||||
device.threshold_power_watts = MOCK_INSIGHT_STATE_THRESHOLD_POWER
|
device.threshold_power_watts = MOCK_INSIGHT_STATE_THRESHOLD_POWER
|
||||||
|
|
|
@ -117,21 +117,21 @@ class TestInsight(EntityTestHelpers):
|
||||||
"""Verify that the binary_sensor receives state updates from the registry."""
|
"""Verify that the binary_sensor receives state updates from the registry."""
|
||||||
# On state.
|
# On state.
|
||||||
pywemo_device.get_state.return_value = 1
|
pywemo_device.get_state.return_value = 1
|
||||||
pywemo_device.get_standby_state = StandbyState.ON
|
pywemo_device.standby_state = StandbyState.ON
|
||||||
pywemo_registry.callbacks[pywemo_device.name](pywemo_device, "", "")
|
pywemo_registry.callbacks[pywemo_device.name](pywemo_device, "", "")
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.states.get(wemo_entity.entity_id).state == STATE_ON
|
assert hass.states.get(wemo_entity.entity_id).state == STATE_ON
|
||||||
|
|
||||||
# Standby (Off) state.
|
# Standby (Off) state.
|
||||||
pywemo_device.get_state.return_value = 1
|
pywemo_device.get_state.return_value = 1
|
||||||
pywemo_device.get_standby_state = StandbyState.STANDBY
|
pywemo_device.standby_state = StandbyState.STANDBY
|
||||||
pywemo_registry.callbacks[pywemo_device.name](pywemo_device, "", "")
|
pywemo_registry.callbacks[pywemo_device.name](pywemo_device, "", "")
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.states.get(wemo_entity.entity_id).state == STATE_OFF
|
assert hass.states.get(wemo_entity.entity_id).state == STATE_OFF
|
||||||
|
|
||||||
# Off state.
|
# Off state.
|
||||||
pywemo_device.get_state.return_value = 0
|
pywemo_device.get_state.return_value = 0
|
||||||
pywemo_device.get_standby_state = StandbyState.OFF
|
pywemo_device.standby_state = StandbyState.OFF
|
||||||
pywemo_registry.callbacks[pywemo_device.name](pywemo_device, "", "")
|
pywemo_registry.callbacks[pywemo_device.name](pywemo_device, "", "")
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.states.get(wemo_entity.entity_id).state == STATE_OFF
|
assert hass.states.get(wemo_entity.entity_id).state == STATE_OFF
|
||||||
|
|
|
@ -134,19 +134,19 @@ async def test_insight_state_attributes(hass, pywemo_registry):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test 'ON' state detail value.
|
# Test 'ON' state detail value.
|
||||||
insight.get_standby_state = pywemo.StandbyState.ON
|
insight.standby_state = pywemo.StandbyState.ON
|
||||||
await async_update()
|
await async_update()
|
||||||
attributes = hass.states.get(wemo_entity.entity_id).attributes
|
attributes = hass.states.get(wemo_entity.entity_id).attributes
|
||||||
assert attributes[ATTR_CURRENT_STATE_DETAIL] == STATE_ON
|
assert attributes[ATTR_CURRENT_STATE_DETAIL] == STATE_ON
|
||||||
|
|
||||||
# Test 'STANDBY' state detail value.
|
# Test 'STANDBY' state detail value.
|
||||||
insight.get_standby_state = pywemo.StandbyState.STANDBY
|
insight.standby_state = pywemo.StandbyState.STANDBY
|
||||||
await async_update()
|
await async_update()
|
||||||
attributes = hass.states.get(wemo_entity.entity_id).attributes
|
attributes = hass.states.get(wemo_entity.entity_id).attributes
|
||||||
assert attributes[ATTR_CURRENT_STATE_DETAIL] == STATE_STANDBY
|
assert attributes[ATTR_CURRENT_STATE_DETAIL] == STATE_STANDBY
|
||||||
|
|
||||||
# Test 'UNKNOWN' state detail value.
|
# Test 'UNKNOWN' state detail value.
|
||||||
insight.get_standby_state = None
|
insight.standby_state = None
|
||||||
await async_update()
|
await async_update()
|
||||||
attributes = hass.states.get(wemo_entity.entity_id).attributes
|
attributes = hass.states.get(wemo_entity.entity_id).attributes
|
||||||
assert attributes[ATTR_CURRENT_STATE_DETAIL] == STATE_UNKNOWN
|
assert attributes[ATTR_CURRENT_STATE_DETAIL] == STATE_UNKNOWN
|
||||||
|
|
Loading…
Add table
Reference in a new issue