Skip to content
Merged

2021.4.2 #48954

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/cast/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ async def async_play_media(self, media_type, media_id, **kwargs):
self.hass,
refresh_token.id,
media_id,
timedelta(minutes=5),
timedelta(seconds=media_source.DEFAULT_EXPIRY_TIME),
)

# prepend external URL
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/frontend/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Home Assistant Frontend",
"documentation": "https://www.home-assistant.io/integrations/frontend",
"requirements": [
"home-assistant-frontend==20210407.2"
"home-assistant-frontend==20210407.3"
],
"dependencies": [
"api",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hassio/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def retrieve_discovery_messages(self):

This method return a coroutine.
"""
return self.send_command("/discovery", method="get")
return self.send_command("/discovery", method="get", timeout=60)

@api_data
def get_discovery_message(self, uuid):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/kodi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Kodi",
"documentation": "https://www.home-assistant.io/integrations/kodi",
"requirements": [
"pykodi==0.2.3"
"pykodi==0.2.5"
],
"codeowners": [
"@OnFreund",
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/media_source/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from .const import DOMAIN, URI_SCHEME, URI_SCHEME_REGEX
from .error import Unresolvable

DEFAULT_EXPIRY_TIME = 3600 * 24


def is_media_source_id(media_content_id: str):
"""Test if identifier is a media source."""
Expand Down Expand Up @@ -105,7 +107,7 @@ async def websocket_browse_media(hass, connection, msg):
{
vol.Required("type"): "media_source/resolve_media",
vol.Required(ATTR_MEDIA_CONTENT_ID): str,
vol.Optional("expires", default=30): int,
vol.Optional("expires", default=DEFAULT_EXPIRY_TIME): int,
}
)
@websocket_api.async_response
Expand Down
5 changes: 1 addition & 4 deletions homeassistant/components/notify_events/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,9 @@ def prepare_message(self, message, data) -> Message:

def send_message(self, message, **kwargs):
"""Send a message."""
token = self.token
data = kwargs.get(ATTR_DATA) or {}
token = data.get(ATTR_TOKEN, self.token)

msg = self.prepare_message(message, data)

if data.get(ATTR_TOKEN, "").trim():
token = data[ATTR_TOKEN]

msg.send(token)
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _convert_weather_response(self, weather_response):
ATTR_API_FEELS_LIKE_TEMPERATURE: current_weather.temperature("celsius").get(
"feels_like"
),
ATTR_API_DEW_POINT: (round(current_weather.dewpoint / 100, 1)),
ATTR_API_DEW_POINT: self._fmt_dewpoint(current_weather.dewpoint),
ATTR_API_PRESSURE: current_weather.pressure.get("press"),
ATTR_API_HUMIDITY: current_weather.humidity,
ATTR_API_WIND_BEARING: current_weather.wind().get("deg"),
Expand Down Expand Up @@ -178,6 +178,12 @@ def _convert_forecast(self, entry):

return forecast

@staticmethod
def _fmt_dewpoint(dewpoint):
if dewpoint is not None:
return round(dewpoint / 100, 1)
return None

@staticmethod
def _get_rain(rain):
"""Get rain data from weather data."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/plex/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)
from homeassistant.util import dt as dt_util

LIVE_TV_SECTION = "-4"
LIVE_TV_SECTION = -4


class PlexSession:
Expand Down
16 changes: 14 additions & 2 deletions homeassistant/components/rituals_perfume_genie/switch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"""Support for Rituals Perfume Genie switches."""
from datetime import timedelta
import logging

import aiohttp

from homeassistant.components.switch import SwitchEntity

from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

SCAN_INTERVAL = timedelta(seconds=30)

ON_STATE = "1"
Expand Down Expand Up @@ -33,6 +38,7 @@ class DiffuserSwitch(SwitchEntity):
def __init__(self, diffuser):
"""Initialize the switch."""
self._diffuser = diffuser
self._available = True

@property
def device_info(self):
Expand All @@ -53,7 +59,7 @@ def unique_id(self):
@property
def available(self):
"""Return if the device is available."""
return self._diffuser.data["hub"]["status"] == AVAILABLE_STATE
return self._available

@property
def name(self):
Expand Down Expand Up @@ -89,4 +95,10 @@ async def async_turn_off(self, **kwargs):

async def async_update(self):
"""Update the data of the device."""
await self._diffuser.update_data()
try:
await self._diffuser.update_data()
except aiohttp.ClientError:
self._available = False
_LOGGER.error("Unable to retrieve data from rituals.sense-company.com")
else:
self._available = self._diffuser.data["hub"]["status"] == AVAILABLE_STATE
13 changes: 12 additions & 1 deletion homeassistant/components/version/sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Sensor that can display the current Home Assistant versions."""
from datetime import timedelta
import logging

from pyhaversion import HaVersion, HaVersionChannel, HaVersionSource
from pyhaversion.exceptions import HaVersionFetchException, HaVersionParseException
import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
Expand Down Expand Up @@ -59,6 +61,8 @@
}
)

_LOGGER: logging.Logger = logging.getLogger(__name__)


async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Version sensor platform."""
Expand Down Expand Up @@ -114,7 +118,14 @@ def __init__(self, api: HaVersion):
@Throttle(TIME_BETWEEN_UPDATES)
async def async_update(self):
"""Get the latest version information."""
await self.api.get_version()
try:
await self.api.get_version()
except HaVersionFetchException as exception:
_LOGGER.warning(exception)
except HaVersionParseException as exception:
_LOGGER.warning(
"Could not parse data received for %s - %s", self.api.source, exception
)


class VersionSensor(SensorEntity):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"bellows==0.23.1",
"pyserial==3.5",
"pyserial-asyncio==0.5",
"zha-quirks==0.0.55",
"zha-quirks==0.0.56",
"zigpy-cc==0.5.2",
"zigpy-deconz==0.12.0",
"zigpy==0.33.0",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 2021
MINOR_VERSION = 4
PATCH_VERSION = "1"
PATCH_VERSION = "2"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (3, 8, 0)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defusedxml==0.6.0
distro==1.5.0
emoji==1.2.0
hass-nabucasa==0.42.0
home-assistant-frontend==20210407.2
home-assistant-frontend==20210407.3
httpx==0.17.1
jinja2>=2.11.3
netdisco==2.8.2
Expand Down
6 changes: 3 additions & 3 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ hole==0.5.1
holidays==0.10.5.2

# homeassistant.components.frontend
home-assistant-frontend==20210407.2
home-assistant-frontend==20210407.3

# homeassistant.components.zwave
homeassistant-pyozw==0.1.10
Expand Down Expand Up @@ -1476,7 +1476,7 @@ pykira==0.1.1
pykmtronic==0.0.3

# homeassistant.components.kodi
pykodi==0.2.3
pykodi==0.2.5

# homeassistant.components.kulersky
pykulersky==0.5.2
Expand Down Expand Up @@ -2372,7 +2372,7 @@ zengge==0.2
zeroconf==0.29.0

# homeassistant.components.zha
zha-quirks==0.0.55
zha-quirks==0.0.56

# homeassistant.components.zhong_hong
zhong_hong_hvac==1.0.9
Expand Down
9 changes: 6 additions & 3 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ hole==0.5.1
holidays==0.10.5.2

# homeassistant.components.frontend
home-assistant-frontend==20210407.2
home-assistant-frontend==20210407.3

# homeassistant.components.zwave
homeassistant-pyozw==0.1.10
Expand Down Expand Up @@ -518,6 +518,9 @@ netdisco==2.8.2
# homeassistant.components.nexia
nexia==0.9.5

# homeassistant.components.notify_events
notify-events==1.0.4

# homeassistant.components.nsw_fuel_station
nsw-fuel-api-client==1.0.10

Expand Down Expand Up @@ -784,7 +787,7 @@ pykira==0.1.1
pykmtronic==0.0.3

# homeassistant.components.kodi
pykodi==0.2.3
pykodi==0.2.5

# homeassistant.components.kulersky
pykulersky==0.5.2
Expand Down Expand Up @@ -1230,7 +1233,7 @@ zeep[async]==4.0.0
zeroconf==0.29.0

# homeassistant.components.zha
zha-quirks==0.0.55
zha-quirks==0.0.56

# homeassistant.components.zha
zigpy-cc==0.5.2
Expand Down
1 change: 1 addition & 0 deletions tests/components/notify_events/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for the notify_events integration."""
12 changes: 12 additions & 0 deletions tests/components/notify_events/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""The tests for notify_events."""
from homeassistant.components.notify_events.const import DOMAIN
from homeassistant.setup import async_setup_component


async def test_setup(hass):
"""Test setup of the integration."""
config = {"notify_events": {"token": "ABC"}}
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()

assert DOMAIN in hass.data
38 changes: 38 additions & 0 deletions tests/components/notify_events/test_notify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""The tests for notify_events."""
from homeassistant.components.notify import ATTR_DATA, ATTR_MESSAGE, DOMAIN
from homeassistant.components.notify_events.notify import (
ATTR_LEVEL,
ATTR_PRIORITY,
ATTR_TOKEN,
)

from tests.common import async_mock_service


async def test_send_msg(hass):
"""Test notify.events service."""
notify_calls = async_mock_service(hass, DOMAIN, "events")

await hass.services.async_call(
DOMAIN,
"events",
{
ATTR_MESSAGE: "message content",
ATTR_DATA: {
ATTR_TOKEN: "XYZ",
ATTR_LEVEL: "warning",
ATTR_PRIORITY: "high",
},
},
blocking=True,
)

assert len(notify_calls) == 1
call = notify_calls[-1]

assert call.domain == DOMAIN
assert call.service == "events"
assert call.data.get(ATTR_MESSAGE) == "message content"
assert call.data.get(ATTR_DATA).get(ATTR_TOKEN) == "XYZ"
assert call.data.get(ATTR_DATA).get(ATTR_LEVEL) == "warning"
assert call.data.get(ATTR_DATA).get(ATTR_PRIORITY) == "high"