Skip to content

Commit

Permalink
Merge pull request home-assistant#54676 from home-assistant/rc
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Aug 16, 2021
2 parents 745afc8 + 700f149 commit e087349
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 81 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ omit =
homeassistant/components/mystrom/light.py
homeassistant/components/mystrom/switch.py
homeassistant/components/myq/__init__.py
homeassistant/components/myq/cover.py
homeassistant/components/nad/media_player.py
homeassistant/components/nanoleaf/light.py
homeassistant/components/neato/__init__.py
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/adax/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/adax",
"requirements": [
"adax==0.0.1"
"adax==0.1.1"
],
"codeowners": [
"@danielhiversen"
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/ambiclimate/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ def __init__(self, heater, store):
"name": self.name,
"manufacturer": "Ambiclimate",
}
self._attr_min_temp = heater.get_min_temp()
self._attr_max_temp = heater.get_max_temp()

async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
Expand Down Expand Up @@ -184,6 +182,8 @@ async def async_update(self) -> None:
await self._store.async_save(token_info)

data = await self._heater.update_device()
self._attr_min_temp = self._heater.get_min_temp()
self._attr_max_temp = self._heater.get_max_temp()
self._attr_target_temperature = data.get("target_temperature")
self._attr_current_temperature = data.get("temperature")
self._attr_current_humidity = data.get("humidity")
Expand Down
5 changes: 0 additions & 5 deletions homeassistant/components/bmw_connected_drive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,6 @@ def __init__(self, account, vehicle):
"manufacturer": vehicle.attributes.get("brand"),
}

@property
def extra_state_attributes(self):
"""Return the state attributes of the sensor."""
return self._attrs

def update_callback(self):
"""Schedule a state update."""
self.schedule_update_ha_state(True)
Expand Down
51 changes: 20 additions & 31 deletions homeassistant/components/bmw_connected_drive/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,54 +85,38 @@ def __init__(
def update(self):
"""Read new state data from the library."""
vehicle_state = self._vehicle.state
result = self._attrs.copy()

# device class opening: On means open, Off means closed
if self._attribute == "lids":
_LOGGER.debug("Status of lid: %s", vehicle_state.all_lids_closed)
self._attr_state = not vehicle_state.all_lids_closed
if self._attribute == "windows":
self._attr_state = not vehicle_state.all_windows_closed
# device class lock: On means unlocked, Off means locked
if self._attribute == "door_lock_state":
# Possible values: LOCKED, SECURED, SELECTIVE_LOCKED, UNLOCKED
self._attr_state = vehicle_state.door_lock_state not in [
LockState.LOCKED,
LockState.SECURED,
]
# device class light: On means light detected, Off means no light
if self._attribute == "lights_parking":
self._attr_state = vehicle_state.are_parking_lights_on
# device class problem: On means problem detected, Off means no problem
if self._attribute == "condition_based_services":
self._attr_state = not vehicle_state.are_all_cbs_ok
if self._attribute == "check_control_messages":
self._attr_state = vehicle_state.has_check_control_messages
# device class power: On means power detected, Off means no power
if self._attribute == "charging_status":
self._attr_state = vehicle_state.charging_status in [ChargingState.CHARGING]
# device class plug: On means device is plugged in,
# Off means device is unplugged
if self._attribute == "connection_status":
self._attr_state = vehicle_state.connection_status == "CONNECTED"

vehicle_state = self._vehicle.state
result = self._attrs.copy()

if self._attribute == "lids":
self._attr_is_on = not vehicle_state.all_lids_closed
for lid in vehicle_state.lids:
result[lid.name] = lid.state.value
elif self._attribute == "windows":
self._attr_is_on = not vehicle_state.all_windows_closed
for window in vehicle_state.windows:
result[window.name] = window.state.value
# device class lock: On means unlocked, Off means locked
elif self._attribute == "door_lock_state":
# Possible values: LOCKED, SECURED, SELECTIVE_LOCKED, UNLOCKED
self._attr_is_on = vehicle_state.door_lock_state not in [
LockState.LOCKED,
LockState.SECURED,
]
result["door_lock_state"] = vehicle_state.door_lock_state.value
result["last_update_reason"] = vehicle_state.last_update_reason
# device class light: On means light detected, Off means no light
elif self._attribute == "lights_parking":
self._attr_is_on = vehicle_state.are_parking_lights_on
result["lights_parking"] = vehicle_state.parking_lights.value
# device class problem: On means problem detected, Off means no problem
elif self._attribute == "condition_based_services":
self._attr_is_on = not vehicle_state.are_all_cbs_ok
for report in vehicle_state.condition_based_services:
result.update(self._format_cbs_report(report))
elif self._attribute == "check_control_messages":
self._attr_is_on = vehicle_state.has_check_control_messages
check_control_messages = vehicle_state.check_control_messages
has_check_control_messages = vehicle_state.has_check_control_messages
if has_check_control_messages:
Expand All @@ -142,13 +126,18 @@ def update(self):
result["check_control_messages"] = cbs_list
else:
result["check_control_messages"] = "OK"
# device class power: On means power detected, Off means no power
elif self._attribute == "charging_status":
self._attr_is_on = vehicle_state.charging_status in [ChargingState.CHARGING]
result["charging_status"] = vehicle_state.charging_status.value
result["last_charging_end_result"] = vehicle_state.last_charging_end_result
# device class plug: On means device is plugged in,
# Off means device is unplugged
elif self._attribute == "connection_status":
self._attr_is_on = vehicle_state.connection_status == "CONNECTED"
result["connection_status"] = vehicle_state.connection_status

self._attr_extra_state_attributes = sorted(result.items())
self._attr_extra_state_attributes = result

def _format_cbs_report(self, report):
result = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def source_type(self):

def update(self):
"""Update state of the decvice tracker."""
self._attr_extra_state_attributes = self._attrs
self._location = (
self._vehicle.state.gps_position
if self._vehicle.state.is_vehicle_tracking_enabled
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/esphome/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ async def async_turn_on(self, **kwargs: Any) -> None:
color_bri = max(rgb)
# normalize rgb
data["rgb"] = tuple(x / (color_bri or 1) for x in rgb)
data["color_brightness"] = color_bri
if self._supports_color_mode:
data["color_brightness"] = color_bri
data["color_mode"] = LightColorMode.RGB

if (rgbw_ha := kwargs.get(ATTR_RGBW_COLOR)) is not None:
Expand All @@ -116,8 +116,8 @@ async def async_turn_on(self, **kwargs: Any) -> None:
# normalize rgb
data["rgb"] = tuple(x / (color_bri or 1) for x in rgb)
data["white"] = w
data["color_brightness"] = color_bri
if self._supports_color_mode:
data["color_brightness"] = color_bri
data["color_mode"] = LightColorMode.RGB_WHITE

if (rgbww_ha := kwargs.get(ATTR_RGBWW_COLOR)) is not None:
Expand All @@ -144,8 +144,8 @@ async def async_turn_on(self, **kwargs: Any) -> None:
data["color_temperature"] = min_ct + ct_ratio * (max_ct - min_ct)
target_mode = LightColorMode.RGB_COLOR_TEMPERATURE

data["color_brightness"] = color_bri
if self._supports_color_mode:
data["color_brightness"] = color_bri
data["color_mode"] = target_mode

if (flash := kwargs.get(ATTR_FLASH)) is not None:
Expand Down Expand Up @@ -230,7 +230,7 @@ def rgbww_color(self) -> tuple[int, int, int, int, int] | None:
# Try to reverse white + color temp to cwww
min_ct = self._static_info.min_mireds
max_ct = self._static_info.max_mireds
color_temp = self._state.color_temperature
color_temp = min(max(self._state.color_temperature, min_ct), max_ct)
white = self._state.white

ww_frac = (color_temp - min_ct) / (max_ct - min_ct)
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/homekit/type_lights.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Class to hold all light accessories."""
import logging
import math

from pyhap.const import CATEGORY_LIGHTBULB

Expand Down Expand Up @@ -115,8 +116,8 @@ def __init__(self, *args):
)

if self.is_color_temp_supported:
min_mireds = attributes.get(ATTR_MIN_MIREDS, 153)
max_mireds = attributes.get(ATTR_MAX_MIREDS, 500)
min_mireds = math.floor(attributes.get(ATTR_MIN_MIREDS, 153))
max_mireds = math.ceil(attributes.get(ATTR_MAX_MIREDS, 500))
serv_light = serv_light_secondary or serv_light_primary
self.char_color_temperature = serv_light.configure_char(
CHAR_COLOR_TEMPERATURE,
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/http/forwarded.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def async_setup_forwarded(

try:
from hass_nabucasa import remote # pylint: disable=import-outside-toplevel

# venv users might have already loaded it before it got upgraded so guard for this
# This can only happen when people upgrade from before 2021.8.5.
if not hasattr(remote, "is_cloud_request"):
remote = None
except ImportError:
remote = None

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/huawei_lte/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ async def async_added_to_hass(self) -> None:
async_dispatcher_connect(self.hass, UPDATE_SIGNAL, self._async_maybe_update)
)

async def _async_maybe_update(self, url: str) -> None:
async def _async_maybe_update(self, config_entry_unique_id: str) -> None:
"""Update state if the update signal comes from our router."""
if url == self.router.url:
if config_entry_unique_id == self.router.config_entry.unique_id:
self.async_schedule_update_ha_state(True)

async def async_will_remove_from_hass(self) -> None:
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/modbus/base_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def __init__(self, hub: ModbusHub, config: dict) -> None:
self._verify_address = config[CONF_VERIFY].get(
CONF_ADDRESS, config[CONF_ADDRESS]
)
self._verify_type = config[CONF_VERIFY].get(
CONF_INPUT_TYPE, convert[config[CONF_WRITE_TYPE]][0]
)
self._verify_type = convert[
config[CONF_VERIFY].get(CONF_INPUT_TYPE, config[CONF_WRITE_TYPE])
][0]
self._state_on = config[CONF_VERIFY].get(CONF_STATE_ON, self.command_on)
self._state_off = config[CONF_VERIFY].get(CONF_STATE_OFF, self._command_off)
else:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/myq/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def _async_validate_input(self, username, password):
"""Validate the user input allows us to connect."""
websession = aiohttp_client.async_get_clientsession(self.hass)
try:
await pymyq.login(username, password, websession)
await pymyq.login(username, password, websession, True)
except InvalidCredentialsError:
return {CONF_PASSWORD: "invalid_auth"}
except MyQError:
Expand Down
8 changes: 6 additions & 2 deletions homeassistant/components/myq/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ async def async_close_cover(self, **kwargs):
# Write closing state to HASS
self.async_write_ha_state()

if not await wait_task:
result = wait_task if isinstance(wait_task, bool) else await wait_task

if not result:
_LOGGER.error("Closing of cover %s failed", self._device.name)

# Write final state to HASS
Expand All @@ -137,7 +139,9 @@ async def async_open_cover(self, **kwargs):
# Write opening state to HASS
self.async_write_ha_state()

if not await wait_task:
result = wait_task if isinstance(wait_task, bool) else await wait_task

if not result:
_LOGGER.error("Opening of cover %s failed", self._device.name)

# Write final state to HASS
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/myq/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "myq",
"name": "MyQ",
"documentation": "https://www.home-assistant.io/integrations/myq",
"requirements": ["pymyq==3.0.4"],
"requirements": ["pymyq==3.1.2"],
"codeowners": ["@bdraco"],
"config_flow": true,
"homekit": {
Expand Down
7 changes: 1 addition & 6 deletions homeassistant/components/nfandroidtv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""The NFAndroidTV integration."""
import logging

from notifications_android_tv.notifications import ConnectError, Notifications

from homeassistant.components.notify import DOMAIN as NOTIFY
Expand All @@ -12,8 +10,6 @@

from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

PLATFORMS = [NOTIFY]


Expand Down Expand Up @@ -41,8 +37,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
try:
await hass.async_add_executor_job(Notifications, host)
except ConnectError as ex:
_LOGGER.warning("Failed to connect: %s", ex)
raise ConfigEntryNotReady from ex
raise ConfigEntryNotReady("Failed to connect") from ex

hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nfandroidtv/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "nfandroidtv",
"name": "Notifications for Android TV / Fire TV",
"documentation": "https://www.home-assistant.io/integrations/nfandroidtv",
"requirements": ["notifications-android-tv==0.1.2"],
"requirements": ["notifications-android-tv==0.1.3"],
"codeowners": ["@tkdrob"],
"config_flow": true,
"iot_class": "local_push"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nissan_leaf/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "nissan_leaf",
"name": "Nissan Leaf",
"documentation": "https://www.home-assistant.io/integrations/nissan_leaf",
"requirements": ["pycarwings2==2.10"],
"requirements": ["pycarwings2==2.11"],
"codeowners": ["@filcole"],
"iot_class": "cloud_polling"
}
2 changes: 1 addition & 1 deletion homeassistant/components/qnap/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "qnap",
"name": "QNAP",
"documentation": "https://www.home-assistant.io/integrations/qnap",
"requirements": ["qnapstats==0.3.1"],
"requirements": ["qnapstats==0.4.0"],
"codeowners": ["@colinodell"],
"iot_class": "local_polling"
}
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "synology_dsm",
"name": "Synology DSM",
"documentation": "https://www.home-assistant.io/integrations/synology_dsm",
"requirements": ["py-synologydsm-api==1.0.3"],
"requirements": ["py-synologydsm-api==1.0.4"],
"codeowners": ["@hacf-fr", "@Quentame", "@mib1185"],
"config_flow": true,
"ssdp": [
Expand Down
9 changes: 9 additions & 0 deletions homeassistant/components/tesla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ async def async_setup_entry(hass, config_entry):
await async_client.aclose()
if ex.code == HTTP_UNAUTHORIZED:
raise ConfigEntryAuthFailed from ex
if ex.message in [
"VEHICLE_UNAVAILABLE",
"TOO_MANY_REQUESTS",
"SERVICE_MAINTENANCE",
"UPSTREAM_TIMEOUT",
]:
raise ConfigEntryNotReady(
f"Temporarily unable to communicate with Tesla API: {ex.message}"
) from ex
_LOGGER.error("Unable to communicate with Tesla API: %s", ex.message)
return False

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tesla/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async def validate_input(hass: core.HomeAssistant, data):
if ex.code == HTTP_UNAUTHORIZED:
_LOGGER.error("Invalid credentials: %s", ex)
raise InvalidAuth() from ex
_LOGGER.error("Unable to communicate with Tesla API: %s", ex)
_LOGGER.error("Unable to communicate with Tesla API: %s", ex.message)
raise CannotConnect() from ex
finally:
await async_client.aclose()
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/tibber/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ class TibberSensorEntityDescription(SensorEntityDescription):
device_class=DEVICE_CLASS_ENERGY,
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_MEASUREMENT,
reset_type=ResetType.NEVER,
),
"lastMeterProduction": TibberSensorEntityDescription(
key="lastMeterProduction",
name="last meter production",
device_class=DEVICE_CLASS_ENERGY,
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_MEASUREMENT,
reset_type=ResetType.NEVER,
),
"voltagePhase1": TibberSensorEntityDescription(
key="voltagePhase1",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/universal/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(
self._cmds = commands
self._attrs = {}
for key, val in attributes.items():
attr = val.split("|", 1)
attr = list(map(str.strip, val.split("|", 1)))
if len(attr) == 1:
attr.append(None)
self._attrs[key] = attr
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zeroconf/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "zeroconf",
"name": "Zero-configuration networking (zeroconf)",
"documentation": "https://www.home-assistant.io/integrations/zeroconf",
"requirements": ["zeroconf==0.34.3"],
"requirements": ["zeroconf==0.35.0"],
"dependencies": ["network", "api"],
"codeowners": ["@bdraco"],
"quality_scale": "internal",
Expand Down
Loading

0 comments on commit e087349

Please sign in to comment.