Skip to content

Commit

Permalink
Merge pull request #49139 from home-assistant/rc
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Apr 13, 2021
2 parents a9602e7 + e528105 commit b5548c5
Show file tree
Hide file tree
Showing 32 changed files with 356 additions and 291 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/cast/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def async_step_options(self, user_input=None):
)

if not bad_cec and not bad_hosts and not bad_uuid:
updated_config = {}
updated_config = dict(current_config)
updated_config[CONF_IGNORE_CEC] = ignore_cec
updated_config[CONF_KNOWN_HOSTS] = known_hosts
updated_config[CONF_UUID] = wanted_uuid
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/cast/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import functools as ft
import json
import logging
from urllib.parse import quote

import pychromecast
from pychromecast.controllers.homeassistant import HomeAssistantController
Expand Down Expand Up @@ -472,7 +473,7 @@ async def async_play_media(self, media_type, media_id, **kwargs):
media_id = async_sign_path(
self.hass,
refresh_token.id,
media_id,
quote(media_id),
timedelta(seconds=media_source.DEFAULT_EXPIRY_TIME),
)

Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/homekit_controller/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ async def async_step_zeroconf(self, discovery_info):
}

if "id" not in properties:
_LOGGER.warning(
"HomeKit device %s: id not exposed, in violation of spec", properties
# This can happen if the TXT record is received after the PTR record
# we will wait for the next update in this case
_LOGGER.debug(
"HomeKit device %s: id not exposed; TXT record may have not yet been received",
properties,
)
return self.async_abort(reason="invalid_properties")

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit_controller/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/homekit_controller",
"requirements": [
"aiohomekit==0.2.60"
"aiohomekit==0.2.61"
],
"zeroconf": [
"_hap._tcp.local."
Expand Down
10 changes: 8 additions & 2 deletions homeassistant/components/http/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Authentication for HTTP component."""
import logging
import secrets
from urllib.parse import unquote

from aiohttp import hdrs
from aiohttp.web import middleware
Expand Down Expand Up @@ -30,11 +31,16 @@ def async_sign_path(hass, refresh_token_id, path, expiration):

now = dt_util.utcnow()
encoded = jwt.encode(
{"iss": refresh_token_id, "path": path, "iat": now, "exp": now + expiration},
{
"iss": refresh_token_id,
"path": unquote(path),
"iat": now,
"exp": now + expiration,
},
secret,
algorithm="HS256",
)
return f"{path}?{SIGN_QUERY_PARAM}=" f"{encoded.decode()}"
return f"{path}?{SIGN_QUERY_PARAM}={encoded.decode()}"


@callback
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _add_log_filter(logger, patterns):
"""Add a Filter to the logger based on a regexp of the filter_str."""

def filter_func(logrecord):
return not any(p.match(logrecord.getMessage()) for p in patterns)
return not any(p.search(logrecord.getMessage()) for p in patterns)

logger.addFilter(filter_func)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/lyric/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import logging
from time import gmtime, strftime, time
from time import localtime, strftime, time

from aiolyric.objects.device import LyricDevice
from aiolyric.objects.location import LyricLocation
Expand Down Expand Up @@ -82,7 +82,7 @@
vol.Required(ATTR_TIME_PERIOD, default="01:00:00"): vol.All(
cv.time_period,
cv.positive_timedelta,
lambda td: strftime("%H:%M:%S", gmtime(time() + td.total_seconds())),
lambda td: strftime("%H:%M:%S", localtime(time() + td.total_seconds())),
)
}

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/maxcube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SCAN_INTERVAL
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import load_platform
from homeassistant.util.dt import now

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -59,7 +60,7 @@ def setup(hass, config):
scan_interval = gateway[CONF_SCAN_INTERVAL].total_seconds()

try:
cube = MaxCube(host, port)
cube = MaxCube(host, port, now=now)
hass.data[DATA_KEY][host] = MaxCubeHandle(cube, scan_interval)
except timeout as ex:
_LOGGER.error("Unable to connect to Max!Cube gateway: %s", str(ex))
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/maxcube/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"domain": "maxcube",
"name": "eQ-3 MAX!",
"documentation": "https://www.home-assistant.io/integrations/maxcube",
"requirements": ["maxcube-api==0.4.1"],
"requirements": ["maxcube-api==0.4.2"],
"codeowners": []
}
3 changes: 2 additions & 1 deletion homeassistant/components/media_source/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

from datetime import timedelta
from urllib.parse import quote

import voluptuous as vol

Expand Down Expand Up @@ -123,7 +124,7 @@ async def websocket_resolve_media(hass, connection, msg):
url = async_sign_path(
hass,
connection.refresh_token_id,
url,
quote(url),
timedelta(seconds=msg["expires"]),
)

Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/mqtt/fan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Support for MQTT fans."""
import functools
import logging
import math

import voluptuous as vol

Expand Down Expand Up @@ -441,13 +442,12 @@ def speed_received(msg):
)
return

if not self._feature_percentage:
if speed in self._legacy_speeds_list_no_off:
self._percentage = ordered_list_item_to_percentage(
self._legacy_speeds_list_no_off, speed
)
elif speed == SPEED_OFF:
self._percentage = 0
if speed in self._legacy_speeds_list_no_off:
self._percentage = ordered_list_item_to_percentage(
self._legacy_speeds_list_no_off, speed
)
elif speed == SPEED_OFF:
self._percentage = 0

self.async_write_ha_state()

Expand Down Expand Up @@ -592,7 +592,7 @@ async def async_set_percentage(self, percentage: int) -> None:
This method is a coroutine.
"""
percentage_payload = int(
percentage_payload = math.ceil(
percentage_to_ranged_value(self._speed_range, percentage)
)
mqtt_payload = self._command_templates[ATTR_PERCENTAGE](percentage_payload)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nexia/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "nexia",
"name": "Nexia",
"requirements": ["nexia==0.9.5"],
"requirements": ["nexia==0.9.6"],
"codeowners": ["@bdraco"],
"documentation": "https://www.home-assistant.io/integrations/nexia",
"config_flow": true,
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/nexia/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ def is_invalid_auth_code(http_status_code):

def percent_conv(val):
"""Convert an actual percentage (0.0-1.0) to 0-100 scale."""
if val is None:
return None
return round(val * 100.0, 1)
6 changes: 5 additions & 1 deletion homeassistant/components/philips_js/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ def _update_listeners():

async def _notify_task(self):
while self.api.on and self.api.notify_change_supported:
if await self.api.notifyChange(130):
res = await self.api.notifyChange(130)
if res:
self.async_set_updated_data(None)
elif res is None:
LOGGER.debug("Aborting notify due to unexpected return")
break

@callback
def _async_notify_stop(self):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/philips_js/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Philips TV",
"documentation": "https://www.home-assistant.io/integrations/philips_js",
"requirements": [
"ha-philipsjs==2.3.2"
"ha-philipsjs==2.7.0"
],
"codeowners": [
"@elupus"
Expand Down
8 changes: 5 additions & 3 deletions homeassistant/components/roku/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ async def async_setup(hass: HomeAssistantType, config: dict) -> bool:

async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Set up Roku from a config entry."""
coordinator = RokuDataUpdateCoordinator(hass, host=entry.data[CONF_HOST])
await coordinator.async_config_entry_first_refresh()
coordinator = hass.data[DOMAIN].get(entry.entry_id)
if not coordinator:
coordinator = RokuDataUpdateCoordinator(hass, host=entry.data[CONF_HOST])
hass.data[DOMAIN][entry.entry_id] = coordinator

hass.data[DOMAIN][entry.entry_id] = coordinator
await coordinator.async_config_entry_first_refresh()

for platform in PLATFORMS:
hass.async_create_task(
Expand Down
8 changes: 7 additions & 1 deletion homeassistant/components/screenlogic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,15 @@ def device_info(self):
"""Return device information for the controller."""
controller_type = self.config_data["controller_type"]
hardware_type = self.config_data["hardware_type"]
try:
equipment_model = EQUIPMENT.CONTROLLER_HARDWARE[controller_type][
hardware_type
]
except KeyError:
equipment_model = f"Unknown Model C:{controller_type} H:{hardware_type}"
return {
"connections": {(dr.CONNECTION_NETWORK_MAC, self.mac)},
"name": self.gateway_name,
"manufacturer": "Pentair",
"model": EQUIPMENT.CONTROLLER_HARDWARE[controller_type][hardware_type],
"model": equipment_model,
}
17 changes: 9 additions & 8 deletions homeassistant/components/shelly/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ def brightness(self) -> int:
"""Brightness of light."""
if self.mode == "color":
if self.control_result:
brightness = self.control_result["gain"]
brightness_pct = self.control_result["gain"]
else:
brightness = self.block.gain
brightness_pct = self.block.gain
else:
if self.control_result:
brightness = self.control_result["brightness"]
brightness_pct = self.control_result["brightness"]
else:
brightness = self.block.brightness
return int(brightness / 100 * 255)
brightness_pct = self.block.brightness

return round(255 * brightness_pct / 100)

@property
def white_value(self) -> int:
Expand Down Expand Up @@ -188,11 +189,11 @@ async def async_turn_on(self, **kwargs) -> None:
set_mode = None
params = {"turn": "on"}
if ATTR_BRIGHTNESS in kwargs:
tmp_brightness = int(kwargs[ATTR_BRIGHTNESS] / 255 * 100)
brightness_pct = int(100 * (kwargs[ATTR_BRIGHTNESS] + 1) / 255)
if hasattr(self.block, "gain"):
params["gain"] = tmp_brightness
params["gain"] = brightness_pct
if hasattr(self.block, "brightness"):
params["brightness"] = tmp_brightness
params["brightness"] = brightness_pct
if ATTR_COLOR_TEMP in kwargs:
color_temp = color_temperature_mired_to_kelvin(kwargs[ATTR_COLOR_TEMP])
color_temp = min(self._max_kelvin, max(self._min_kelvin, color_temp))
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/zwave_js/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def __init__(
THERMOSTAT_OPERATING_STATE_PROPERTY,
command_class=CommandClass.THERMOSTAT_OPERATING_STATE,
add_to_watched_value_ids=True,
check_all_endpoints=True,
)
self._current_temp = self.get_zwave_value(
THERMOSTAT_CURRENT_TEMP_PROPERTY,
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 = "3"
PATCH_VERSION = "4"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (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 @@ -172,7 +172,7 @@ aioguardian==1.0.4
aioharmony==0.2.7

# homeassistant.components.homekit_controller
aiohomekit==0.2.60
aiohomekit==0.2.61

# homeassistant.components.emulated_hue
# homeassistant.components.http
Expand Down Expand Up @@ -721,7 +721,7 @@ guppy3==3.1.0
ha-ffmpeg==3.0.2

# homeassistant.components.philips_js
ha-philipsjs==2.3.2
ha-philipsjs==2.7.0

# homeassistant.components.habitica
habitipy==0.2.0
Expand Down Expand Up @@ -916,7 +916,7 @@ magicseaweed==1.0.3
matrix-client==0.3.2

# homeassistant.components.maxcube
maxcube-api==0.4.1
maxcube-api==0.4.2

# homeassistant.components.mythicbeastsdns
mbddns==0.1.2
Expand Down Expand Up @@ -986,7 +986,7 @@ netdisco==2.8.2
neurio==0.3.1

# homeassistant.components.nexia
nexia==0.9.5
nexia==0.9.6

# homeassistant.components.nextcloud
nextcloudmonitor==1.1.0
Expand Down
8 changes: 4 additions & 4 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ aioguardian==1.0.4
aioharmony==0.2.7

# homeassistant.components.homekit_controller
aiohomekit==0.2.60
aiohomekit==0.2.61

# homeassistant.components.emulated_hue
# homeassistant.components.http
Expand Down Expand Up @@ -382,7 +382,7 @@ guppy3==3.1.0
ha-ffmpeg==3.0.2

# homeassistant.components.philips_js
ha-philipsjs==2.3.2
ha-philipsjs==2.7.0

# homeassistant.components.habitica
habitipy==0.2.0
Expand Down Expand Up @@ -476,7 +476,7 @@ logi_circle==0.2.2
luftdaten==0.6.4

# homeassistant.components.maxcube
maxcube-api==0.4.1
maxcube-api==0.4.2

# homeassistant.components.mythicbeastsdns
mbddns==0.1.2
Expand Down Expand Up @@ -516,7 +516,7 @@ nessclient==0.9.15
netdisco==2.8.2

# homeassistant.components.nexia
nexia==0.9.5
nexia==0.9.6

# homeassistant.components.notify_events
notify-events==1.0.4
Expand Down
Loading

0 comments on commit b5548c5

Please sign in to comment.