8000 2021.10.5 by balloob · Pull Request #57793 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

2021.10.5 #57793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 15, 2021
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
4 changes: 2 additions & 2 deletions homeassistant/components/dlna_dmr/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ async def async_update(self) -> None:
try:
do_ping = self.poll_availability or self.check_available
await self._device.async_update(do_ping=do_ping)
except UpnpError:
_LOGGER.debug("Device unavailable")
except UpnpError as err:
_LOGGER.debug("Device unavailable: %r", err)
await self._device_disconnect()
return
finally:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fastdotcom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for testing internet speed via Fast.com."""
from __future__ import annotations

from datetime import timedelta
from datetime import datetime, timedelta
import logging
from typing import Any

Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self, hass: HomeAssistant) -> None:
self.data: dict[str, Any] | None = None
self._hass = hass

def update(self) -> None:
def update(self, now: datetime | None = None) -> None:
"""Get the latest data from fast.com."""

_LOGGER.debug("Executing fast.com speedtest")
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mill/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "mill",
"name": "Mill",
"documentation": "https://www.home-assistant.io/integrations/mill",
"requirements": ["millheater==0.6.1"],
"requirements": ["millheater==0.6.2"],
"codeowners": ["@danielhiversen"],
"config_flow": true,
"iot_class": "cloud_polling"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/notion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def __init__(
"identifiers": {(DOMAIN, sensor["hardware_id"])},
"manufacturer": "Silicon Labs",
"model": sensor["hardware_revision"],
"name": sensor["name"],
"name": str(sensor["name"]),
"sw_version": sensor["firmware_version"],
"via_device": (DOMAIN, bridge.get("hardware_id")),
}
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/recorder/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ def setup_connection_for_dialect(
result = query_on_connection(dbapi_connection, "SELECT VERSION()")
version = result[0][0]
major, minor, _patch = version.split(".", 2)
if int(major) == 5 and int(minor) < 8:
if (int(major) == 5 and int(minor) < 8) or (
int(major) == 10 and int(minor) < 2
):
instance._db_supports_row_number = ( # pylint: disable=[protected-access]
False
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/shelly/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
value=lambda value: round(value, 1),
device_class=sensor.DEVICE_CLASS_HUMIDITY,
state_class=sensor.STATE_CLASS_MEASUREMENT,
available=lambda block: cast(int, block.extTemp) != 999,
available=lambda block: cast(int, block.humidity) != 999,
),
("sensor", "luminosity"): BlockAttributeDescription(
name="Luminosity",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/simplisafe/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "SimpliSafe",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/simplisafe",
"requirements": ["simplisafe-python==11.0.6"],
"requirements": ["simplisafe-python==11.0.7"],
"codeowners": ["@bachya"],
"iot_class": "cloud_polling"
}
2 changes: 1 addition & 1 deletion homeassistant/components/spider/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "spider",
"name": "Itho Daalderop Spider",
"documentation": "https://www.home-assistant.io/integrations/spider",
"requirements": ["spiderpy==1.4.2"],
"requirements": ["spiderpy==1.4.3"],
"codeowners": ["@peternijssen"],
"config_flow": true,
"iot_class": "cloud_polling"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/upnp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,5 @@ def __init__(
def available(self) -> bool:
"""Return if entity is available."""
return super().available and (
self.coordinator.data.get(self.entity_description.key) or False
self.coordinator.data.get(self.entity_description.key) is not None
)
5 changes: 4 additions & 1 deletion homeassistant/components/upnp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ def native_value(self) -> str | None:

# Calculate derivative.
delta_value = current_value - self._last_value
if self.entity_description.native_unit_of_measurement == DATA_BYTES:
if (
self.entity_description.native_unit_of_measurement
== DATA_RATE_KIBIBYTES_PER_SECOND
):
delta_value /= KIBIBYTE
delta_time = current_timestamp - self._last_timestamp
if delta_time.total_seconds() == 0:
Expand Down
17 changes: 10 additions & 7 deletions homeassistant/components/yeelight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from datetime import timedelta
from ipaddress import IPv4Address, IPv6Address
import logging
import socket
from urllib.parse import urlparse

from async_upnp_client.search import SsdpSearchListener
Expand Down Expand Up @@ -163,9 +162,6 @@
"active_mode",
]

BULB_NETWORK_EXCEPTIONS = (socket.error,)
BULB_EXCEPTIONS = (BulbException, asyncio.TimeoutError, *BULB_NETWORK_EXCEPTIONS)


PLATFORMS = ["binary_sensor", "light"]

Expand Down Expand Up @@ -270,7 +266,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
try:
device = await _async_get_device(hass, entry.data[CONF_HOST], entry)
await _async_initialize(hass, entry, device)
except BULB_EXCEPTIONS as ex:
except (asyncio.TimeoutError, OSError, BulbException) as ex:
raise ConfigEntryNotReady from ex

hass.config_entries.async_setup_platforms(entry, PLATFORMS)
Expand Down Expand Up @@ -594,13 +590,20 @@ async def _async_update_properties(self):
self._available = True
if not self._initialized:
self._initialized = True
except BULB_NETWORK_EXCEPTIONS as ex:
except OSError as ex:
if self._available: # just inform once
_LOGGER.error(
"Unable to update device %s, %s: %s", self._host, self.name, ex
)
self._available = False
except BULB_EXCEPTIONS as ex:
except asyncio.TimeoutError as ex:
_LOGGER.debug(
"timed out while trying to update device %s, %s: %s",
self._host,
self.name,
ex,
)
except BulbException as ex:
_LOGGER.debug(
"Unable to update device %s, %s: %s", self._host, self.name, ex
)
Expand Down
66 changes: 44 additions & 22 deletions homeassistant/components/yeelight/light.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Light platform support for yeelight."""
from __future__ import annotations

import asyncio
import logging
import math

import voluptuous as vol
import yeelight
from yeelight import Bulb, Flow, RGBTransition, SleepTransition, flows
from yeelight.enums import BulbType, LightType, PowerMode, SceneClass
from yeelight.main import BulbException

from homeassistant.components.light import (
ATTR_BRIGHTNESS,
Expand Down Expand Up @@ -51,8 +53,6 @@
ATTR_COUNT,
ATTR_MODE_MUSIC,
ATTR_TRANSITIONS,
BULB_EXCEPTIONS,
BULB_NETWORK_EXCEPTIONS,
CONF_FLOW_PARAMS,
CONF_MODE_MUSIC,
CONF_NIGHTLIGHT_SWITCH,
Expand Down Expand Up @@ -243,23 +243,33 @@ def _async_cmd(func):
"""Define a wrapper to catch exceptions from the bulb."""

async def _async_wrap(self, *args, **kwargs):
try:
_LOGGER.debug("Calling %s with %s %s", func, args, kwargs)
return await func(self, *args, **kwargs)
except BULB_NETWORK_EXCEPTIONS as ex:
# A network error happened, the bulb is likely offline now
self.device.async_mark_unavailable()
self.async_state_changed()
exc_message = str(ex) or type(ex)
raise HomeAssistantError(
f"Error when calling {func.__name__} for bulb {self.device.name} at {self.device.host}: {exc_message}"
) from ex
except BULB_EXCEPTIONS as ex:
# The bulb likely responded but had an error
exc_message = str(ex) or type(ex)
raise HomeAssistantError(
f"Error when calling {func.__name__} for bulb {self.device.name} at {self.device.host}: {exc_message}"
) from ex
for attempts in range(2):
try:
_LOGGER.debug("Calling %s with %s %s", func, args, kwargs)
return await func(self, *args, **kwargs)
except asyncio.TimeoutError as ex:
# The wifi likely dropped, so we want to retry once since
# python-yeelight will auto reconnect
exc_message = str(ex) or type(ex)
if attempts == 0:
continue
raise HomeAssistantError(
f"Timed out when calling {func.__name__} for bulb {self.device.name} at {self.device.host}: {exc_message}"
) from ex
except OSError as ex:
# A network error happened, the bulb is likely offline now
self.device.async_mark_unavailable()
self.async_state_changed()
exc_message = str(ex) or type(ex)
raise HomeAssistantError(
f"Error when calling {func.__name__} for bulb {self.device.name} at {self.device.host}: {exc_message}"
) from ex
except BulbException as ex:
# The bulb likely responded but had an error
exc_message = str(ex) or type(ex)
raise HomeAssistantError(
f"Error when calling {func.__name__} for bulb {self.device.name} at {self.device.host}: {exc_message}"
) from ex

return _async_wrap

Expand Down Expand Up @@ -621,7 +631,11 @@ async def async_set_hs(self, hs_color, duration) -> None:
"""Set bulb's color."""
if not hs_color or COLOR_MODE_HS not in self.supported_color_modes:
return
if self.color_mode == COLOR_MODE_HS and self.hs_color == hs_color:
if (
not self.device.is_color_flow_enabled
and self.color_mode == COLOR_MODE_HS
and self.hs_color == hs_color
):
_LOGGER.debug("HS already set to: %s", hs_color)
# Already set, and since we get pushed updates
# we avoid setting it again to ensure we do not
Expand All @@ -638,7 +652,11 @@ async def async_set_rgb(self, rgb, duration) -> None:
"""Set bulb's color."""
if not rgb or COLOR_MODE_RGB not in self.supported_color_modes:
return
if self.color_mode == COLOR_MODE_RGB and self.rgb_color == rgb:
if (
not self.device.is_color_flow_enabled
and self.color_mode == COLOR_MODE_RGB
and self.rgb_color == rgb
):
_LOGGER.debug("RGB already set to: %s", rgb)
# Already set, and since we get pushed updates
# we avoid setting it again to ensure we do not
Expand All @@ -657,7 +675,11 @@ async def async_set_colortemp(self, colortemp, duration) -> None:
return
temp_in_k = mired_to_kelvin(colortemp)

if self.color_mode == COLOR_MODE_COLOR_TEMP and self.color_temp == colortemp:
if (
not self.device.is_color_flow_enabled
and self.color_mode == COLOR_MODE_COLOR_TEMP
and self.color_temp == colortemp
):
_LOGGER.debug("Color temp already set to: %s", temp_in_k)
# Already set, and since we get pushed updates
# we avoid setting it again to ensure we do not
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/yeelight/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "yeelight",
"name": "Yeelight",
"documentation": "https://www.home-assistant.io/integrations/yeelight",
"requirements": ["yeelight==0.7.7", "async-upnp-client==0.22.8"],
"requirements": ["yeelight==0.7.8", "async-upnp-client==0.22.8"],
"codeowners": ["@rytilahti", "@zewelor", "@shenxn", "@starkillerOG"],
"config_flow": true,
"dependencies": ["network"],
Expand Down
14 changes: 10 additions & 4 deletions homeassistant/components/youless/sensor.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
)
Expand Down Expand Up @@ -40,9 +41,9 @@ async def async_setup_entry(
async_add_entities(
[
GasSensor(coordinator, device),
PowerMeterSensor(coordinator, device, "low"),
PowerMeterSensor(coordinator, device, "high"),
PowerMeterSensor(coordinator, device, "total"),
PowerMeterSensor(coordinator, device, "low", STATE_CLASS_TOTAL_INCREASING),
PowerMeterSensor(coordinator, device, "high", STATE_CLASS_TOTAL_INCREASING),
PowerMeterSensor(coordinator, device, "total", STATE_CLASS_TOTAL),
CurrentPowerSensor(coordinator, device),
DeliveryMeterSensor(coordinator, device, "low"),
DeliveryMeterSensor(coordinator, device, "high"),
Expand Down Expand Up @@ -168,7 +169,11 @@ class PowerMeterSensor(YoulessBaseSensor):
_attr_state_class = STATE_CLASS_TOTAL_INCREASING

def __init__(
self, coordinator: DataUpdateCoordinator, device: str, dev_type: str
self,
coordinator: DataUpdateCoordinator,
device: str,
dev_type: str,
state_class: str,
) -> None:
"""Instantiate a power meter sensor."""
super().__init__(
Expand All @@ -177,6 +182,7 @@ def __init__(
self._device = device
self._type = dev_type
self._attr_name = f"Power {dev_type}"
self._attr_state_class = state_class

@property
def get_sensor(self) -> YoulessSensor | None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

MAJOR_VERSION: Final = 2021
MINOR_VERSION: Final = 10
PATCH_VERSION: Final = "4"
PATCH_VERSION: Final = "5"
__short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__: Final = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 8, 0)
Expand Down
8 changes: 4 additions & 4 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ micloud==0.3
miflora==0.7.0

# homeassistant.components.mill
millheater==0.6.1
millheater==0.6.2

# homeassistant.components.minio
minio==4.0.9
Expand Down Expand Up @@ -2149,7 +2149,7 @@ simplehound==0.3
simplepush==1.1.4

# homeassistant.components.simplisafe
simplisafe-python==11.0.6
simplisafe-python==11.0.7

# homeassistant.components.sisyphus
sisyphus-control==3.0
Expand Down Expand Up @@ -2214,7 +2214,7 @@ speak2mary==1.4.0
speedtest-cli==2.1.3

# homeassistant.components.spider
spiderpy==1.4.2
spiderpy==1.4.3

# homeassistant.components.spotify
spotipy==2.18.0
Expand Down Expand Up @@ -2459,7 +2459,7 @@ yalesmartalarmclient==0.3.4
yalexs==1.1.13

# homeassistant.components.yeelight
yeelight==0.7.7
yeelight==0.7.8

# homeassistant.components.yeelightsunflower
yeelightsunflower==0.0.10
Expand Down
Loading
0