Skip to content

Commit

Permalink
2023.2.1 (#87221)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Feb 3, 2023
2 parents 5fe3adf + 372afc5 commit dbd8ffc
Show file tree
Hide file tree
Showing 27 changed files with 378 additions and 131 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/frontend/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "frontend",
"name": "Home Assistant Frontend",
"documentation": "https://www.home-assistant.io/integrations/frontend",
"requirements": ["home-assistant-frontend==20230201.0"],
"requirements": ["home-assistant-frontend==20230202.0"],
"dependencies": [
"api",
"auth",
Expand Down
21 changes: 9 additions & 12 deletions homeassistant/components/honeywell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import asyncio
from dataclasses import dataclass

import AIOSomecomfort
import aiosomecomfort

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .const import (
Expand Down Expand Up @@ -50,22 +50,19 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
username = config_entry.data[CONF_USERNAME]
password = config_entry.data[CONF_PASSWORD]

client = AIOSomecomfort.AIOSomeComfort(
client = aiosomecomfort.AIOSomeComfort(
username, password, session=async_get_clientsession(hass)
)
try:
await client.login()
await client.discover()

except AIOSomecomfort.AuthError as ex:
raise ConfigEntryNotReady(
"Failed to initialize the Honeywell client: "
"Check your configuration (username, password), "
) from ex
except aiosomecomfort.device.AuthError as ex:
raise ConfigEntryAuthFailed("Incorrect Password") from ex

except (
AIOSomecomfort.ConnectionError,
AIOSomecomfort.ConnectionTimeout,
aiosomecomfort.device.ConnectionError,
aiosomecomfort.device.ConnectionTimeout,
asyncio.TimeoutError,
) as ex:
raise ConfigEntryNotReady(
Expand Down Expand Up @@ -117,5 +114,5 @@ class HoneywellData:
"""Shared data for Honeywell."""

entry_id: str
client: AIOSomecomfort.AIOSomeComfort
devices: dict[str, AIOSomecomfort.device.Device]
client: aiosomecomfort.AIOSomeComfort
devices: dict[str, aiosomecomfort.device.Device]
23 changes: 11 additions & 12 deletions homeassistant/components/honeywell/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import datetime
from typing import Any

import AIOSomecomfort
import aiosomecomfort

from homeassistant.components.climate import (
ATTR_TARGET_TEMP_HIGH,
Expand Down Expand Up @@ -100,7 +100,7 @@ class HoneywellUSThermostat(ClimateEntity):
def __init__(
self,
data: HoneywellData,
device: AIOSomecomfort.device.Device,
device: aiosomecomfort.device.Device,
cool_away_temp: int | None,
heat_away_temp: int | None,
) -> None:
Expand Down Expand Up @@ -295,7 +295,7 @@ async def _set_temperature(self, **kwargs) -> None:
if mode == "heat":
await self._device.set_setpoint_heat(temperature)

except AIOSomecomfort.SomeComfortError as err:
except aiosomecomfort.SomeComfortError as err:
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)

async def async_set_temperature(self, **kwargs: Any) -> None:
Expand All @@ -308,7 +308,7 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
if temperature := kwargs.get(ATTR_TARGET_TEMP_LOW):
await self._device.set_setpoint_heat(temperature)

except AIOSomecomfort.SomeComfortError as err:
except aiosomecomfort.SomeComfortError as err:
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)

async def async_set_fan_mode(self, fan_mode: str) -> None:
Expand All @@ -330,7 +330,7 @@ async def _turn_away_mode_on(self) -> None:
try:
# Get current mode
mode = self._device.system_mode
except AIOSomecomfort.SomeComfortError:
except aiosomecomfort.SomeComfortError:
_LOGGER.error("Can not get system mode")
return
try:
Expand All @@ -344,8 +344,7 @@ async def _turn_away_mode_on(self) -> None:
await self._device.set_hold_heat(True)
await self._device.set_setpoint_heat(self._heat_away_temp)

except AIOSomecomfort.SomeComfortError:

except aiosomecomfort.SomeComfortError:
_LOGGER.error(
"Temperature out of range. Mode: %s, Heat Temperature: %.1f, Cool Temperature: %.1f",
mode,
Expand All @@ -358,7 +357,7 @@ async def _turn_hold_mode_on(self) -> None:
try:
# Get current mode
mode = self._device.system_mode
except AIOSomecomfort.SomeComfortError:
except aiosomecomfort.SomeComfortError:
_LOGGER.error("Can not get system mode")
return
# Check that we got a valid mode back
Expand All @@ -370,7 +369,7 @@ async def _turn_hold_mode_on(self) -> None:
if mode in HEATING_MODES:
await self._device.set_hold_heat(True)

except AIOSomecomfort.SomeComfortError:
except aiosomecomfort.SomeComfortError:
_LOGGER.error("Couldn't set permanent hold")
else:
_LOGGER.error("Invalid system mode returned: %s", mode)
Expand All @@ -382,7 +381,7 @@ async def _turn_away_mode_off(self) -> None:
# Disabling all hold modes
await self._device.set_hold_cool(False)
await self._device.set_hold_heat(False)
except AIOSomecomfort.SomeComfortError:
except aiosomecomfort.SomeComfortError:
_LOGGER.error("Can not stop hold mode")

async def async_set_preset_mode(self, preset_mode: str) -> None:
Expand Down Expand Up @@ -411,13 +410,13 @@ async def async_update(self) -> None:
try:
await self._device.refresh()
except (
AIOSomecomfort.SomeComfortError,
aiosomecomfort.SomeComfortError,
OSError,
):
try:
await self._data.client.login()

except AIOSomecomfort.SomeComfortError:
except aiosomecomfort.SomeComfortError:
self._attr_available = False
await self.hass.async_create_task(
self.hass.config_entries.async_reload(self._data.entry_id)
Expand Down
68 changes: 63 additions & 5 deletions homeassistant/components/honeywell/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from __future__ import annotations

import asyncio
from collections.abc import Mapping
from typing import Any

import AIOSomecomfort
import aiosomecomfort
import voluptuous as vol

from homeassistant import config_entries
Expand All @@ -20,23 +22,79 @@
DOMAIN,
)

REAUTH_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})


class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a honeywell config flow."""

VERSION = 1
entry: config_entries.ConfigEntry | None

async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
"""Handle re-authentication with Honeywell."""

self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
return await self.async_step_reauth_confirm()

async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Confirm re-authentication with Honeywell."""
errors: dict[str, str] = {}

if user_input:
assert self.entry is not None
password = user_input[CONF_PASSWORD]
data = {
CONF_USERNAME: self.entry.data[CONF_USERNAME],
CONF_PASSWORD: password,
}

try:
await self.is_valid(
username=data[CONF_USERNAME], password=data[CONF_PASSWORD]
)

except aiosomecomfort.AuthError:
errors["base"] = "invalid_auth"

except (
aiosomecomfort.ConnectionError,
aiosomecomfort.ConnectionTimeout,
asyncio.TimeoutError,
):
errors["base"] = "cannot_connect"

else:

self.hass.config_entries.async_update_entry(
self.entry,
data={
**self.entry.data,
CONF_PASSWORD: password,
},
)
await self.hass.config_entries.async_reload(self.entry.entry_id)
return self.async_abort(reason="reauth_successful")

return self.async_show_form(
step_id="reauth_confirm",
data_schema=REAUTH_SCHEMA,
errors=errors,
)

async def async_step_user(self, user_input=None) -> FlowResult:
"""Create config entry. Show the setup form to the user."""
errors = {}
if user_input is not None:
try:
await self.is_valid(**user_input)
except AIOSomecomfort.AuthError:
except aiosomecomfort.AuthError:
errors["base"] = "invalid_auth"
except (
AIOSomecomfort.ConnectionError,
AIOSomecomfort.ConnectionTimeout,
aiosomecomfort.ConnectionError,
aiosomecomfort.ConnectionTimeout,
asyncio.TimeoutError,
):
errors["base"] = "cannot_connect"
Expand All @@ -57,7 +115,7 @@ async def async_step_user(self, user_input=None) -> FlowResult:

async def is_valid(self, **kwargs) -> bool:
"""Check if login credentials are valid."""
client = AIOSomecomfort.AIOSomeComfort(
client = aiosomecomfort.AIOSomeComfort(
kwargs[CONF_USERNAME],
kwargs[CONF_PASSWORD],
session=async_get_clientsession(self.hass),
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/honeywell/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Honeywell Total Connect Comfort (US)",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/honeywell",
"requirements": ["aiosomecomfort==0.0.3"],
"requirements": ["aiosomecomfort==0.0.6"],
"codeowners": ["@rdfurman", "@mkmer"],
"iot_class": "cloud_polling",
"loggers": ["somecomfort"]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/honeywell/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from typing import Any

from AIOSomecomfort.device import Device
from aiosomecomfort.device import Device

from homeassistant.components.sensor import (
SensorDeviceClass,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/isy994/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
FILTER_STATES: ["open", "closed", "closing", "opening", "stopped"],
FILTER_NODE_DEF_ID: ["DimmerMotorSwitch_ADV"],
FILTER_INSTEON_TYPE: [TYPE_CATEGORY_COVER],
FILTER_ZWAVE_CAT: [],
FILTER_ZWAVE_CAT: ["106", "107"],
},
Platform.LIGHT: {
FILTER_UOM: ["51"],
Expand Down
11 changes: 11 additions & 0 deletions homeassistant/components/recorder/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@
from homeassistant.util import dt as dt_util
from homeassistant.util.unit_conversion import (
BaseUnitConverter,
DataRateConverter,
DistanceConverter,
ElectricCurrentConverter,
ElectricPotentialConverter,
EnergyConverter,
InformationConverter,
MassConverter,
PowerConverter,
PressureConverter,
Expand Down Expand Up @@ -128,8 +132,15 @@


STATISTIC_UNIT_TO_UNIT_CONVERTER: dict[str | None, type[BaseUnitConverter]] = {
**{unit: DataRateConverter for unit in DataRateConverter.VALID_UNITS},
**{unit: DistanceConverter for unit in DistanceConverter.VALID_UNITS},
**{unit: ElectricCurrentConverter for unit in ElectricCurrentConverter.VALID_UNITS},
**{
unit: ElectricPotentialConverter
for unit in ElectricPotentialConverter.VALID_UNITS
},
**{unit: EnergyConverter for unit in EnergyConverter.VALID_UNITS},
**{unit: InformationConverter for unit in InformationConverter.VALID_UNITS},
**{unit: MassConverter for unit in MassConverter.VALID_UNITS},
**{unit: PowerConverter for unit in PowerConverter.VALID_UNITS},
**{unit: PressureConverter for unit in PressureConverter.VALID_UNITS},
Expand Down
Loading

0 comments on commit dbd8ffc

Please sign in to comment.