Skip to content
Merged

2022.3.8 #68825

2 changes: 0 additions & 2 deletions homeassistant/components/abode/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ def camera_image(
self, width: int | None = None, height: int | None = None
) -> bytes | None:
"""Get a camera image."""
if not self.capture():
return None
self.refresh_image()

if self._response:
Expand Down
45 changes: 33 additions & 12 deletions homeassistant/components/elkm1/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@

CONF_DEVICE = "device"

NON_SECURE_PORT = 2101
SECURE_PORT = 2601
STANDARD_PORTS = {NON_SECURE_PORT, SECURE_PORT}

_LOGGER = logging.getLogger(__name__)

Expand All @@ -48,6 +50,7 @@
"serial": "serial://",
}


VALIDATE_TIMEOUT = 35

BASE_SCHEMA = {
Expand All @@ -60,6 +63,11 @@
DEFAULT_SECURE_PROTOCOL = "secure"
DEFAULT_NON_SECURE_PROTOCOL = "non-secure"

PORT_PROTOCOL_MAP = {
NON_SECURE_PORT: DEFAULT_NON_SECURE_PROTOCOL,
SECURE_PORT: DEFAULT_SECURE_PROTOCOL,
}


async def validate_input(data: dict[str, str], mac: str | None) -> dict[str, str]:
"""Validate the user input allows us to connect.
Expand Down Expand Up @@ -97,6 +105,13 @@ async def validate_input(data: dict[str, str], mac: str | None) -> dict[str, str
return {"title": device_name, CONF_HOST: url, CONF_PREFIX: slugify(prefix)}


def _address_from_discovery(device: ElkSystem):
"""Append the port only if its non-standard."""
if device.port in STANDARD_PORTS:
return device.ip_address
return f"{device.ip_address}:{device.port}"


def _make_url_from_data(data):
if host := data.get(CONF_HOST):
return host
Expand All @@ -109,7 +124,7 @@ def _make_url_from_data(data):
def _placeholders_from_device(device: ElkSystem) -> dict[str, str]:
return {
"mac_address": _short_mac(device.mac_address),
"host": f"{device.ip_address}:{device.port}",
"host": _address_from_discovery(device),
}


Expand Down Expand Up @@ -166,6 +181,9 @@ async def _async_handle_discovery(self) -> FlowResult:
for progress in self._async_in_progress():
if progress.get("context", {}).get(CONF_HOST) == host:
return self.async_abort(reason="already_in_progress")
# Handled ignored case since _async_current_entries
# is called with include_ignore=False
self._abort_if_unique_id_configured()
if not device.port:
if discovered_device := await async_discover_device(self.hass, host):
self._discovered_device = discovered_device
Expand Down Expand Up @@ -255,26 +273,26 @@ async def async_step_discovered_connection(self, user_input=None):
device = self._discovered_device
assert device is not None
if user_input is not None:
user_input[CONF_ADDRESS] = f"{device.ip_address}:{device.port}"
user_input[CONF_ADDRESS] = _address_from_discovery(device)
if self._async_current_entries():
user_input[CONF_PREFIX] = _short_mac(device.mac_address)
else:
user_input[CONF_PREFIX] = ""
if device.port != SECURE_PORT:
user_input[CONF_PROTOCOL] = DEFAULT_NON_SECURE_PROTOCOL
errors, result = await self._async_create_or_error(user_input, False)
if not errors:
return result

base_schmea = BASE_SCHEMA.copy()
if device.port == SECURE_PORT:
base_schmea[
vol.Required(CONF_PROTOCOL, default=DEFAULT_SECURE_PROTOCOL)
] = vol.In(SECURE_PROTOCOLS)

default_proto = PORT_PROTOCOL_MAP.get(device.port, DEFAULT_SECURE_PROTOCOL)
return self.async_show_form(
step_id="discovered_connection",
data_schema=vol.Schema(base_schmea),
data_schema=vol.Schema(
{
**BASE_SCHEMA,
vol.Required(CONF_PROTOCOL, default=default_proto): vol.In(
ALL_PROTOCOLS
),
}
),
errors=errors,
description_placeholders=_placeholders_from_device(device),
)
Expand Down Expand Up @@ -334,7 +352,10 @@ async def async_step_import(self, user_input):
)
self._abort_if_unique_id_configured()

return (await self._async_create_or_error(user_input, True))[1]
errors, result = await self._async_create_or_error(user_input, True)
if errors:
return self.async_abort(reason=list(errors.values())[0])
return result

def _url_already_configured(self, url):
"""See if we already have a elkm1 matching user input configured."""
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/elkm1/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"unknown": "[%key:common::config_flow::error::unknown%]"
},
"abort": {
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"unknown": "[%key:common::config_flow::error::unknown%]",
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"already_configured": "An ElkM1 with this prefix is already configured",
Expand Down
12 changes: 4 additions & 8 deletions homeassistant/components/elkm1/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"address_already_configured": "An ElkM1 with this address is already configured",
"already_configured": "An ElkM1 with this prefix is already configured",
"already_in_progress": "Configuration flow is already in progress",
"cannot_connect": "Failed to connect"
"cannot_connect": "Failed to connect",
"invalid_auth": "Invalid authentication",
"unknown": "Unexpected error"
},
"error": {
"cannot_connect": "Failed to connect",
Expand Down Expand Up @@ -37,13 +39,7 @@
},
"user": {
"data": {
"address": "The IP address or domain or serial port if connecting via serial.",
"device": "Device",
"password": "Password",
"prefix": "A unique prefix (leave blank if you only have one ElkM1).",
"protocol": "Protocol",
"temperature_unit": "The temperature unit ElkM1 uses.",
"username": "Username"
"device": "Device"
},
"description": "Choose a discovered system or 'Manual Entry' if no devices have been discovered.",
"title": "Connect to Elk-M1 Control"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/emulated_kasa/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "emulated_kasa",
"name": "Emulated Kasa",
"documentation": "https://www.home-assistant.io/integrations/emulated_kasa",
"requirements": ["sense_energy==0.10.3"],
"requirements": ["sense_energy==0.10.4"],
"codeowners": ["@kbickar"],
"quality_scale": "internal",
"iot_class": "local_push",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/screenlogic/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def async_step_user(self, user_input=None):

async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
"""Handle dhcp discovery."""
mac = _extract_mac_from_name(discovery_info.hostname)
mac = format_mac(discovery_info.macaddress)
await self.async_set_unique_id(mac)
self._abort_if_unique_id_configured(
updates={CONF_IP_ADDRESS: discovery_info.ip}
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/screenlogic/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dhcp": [
{"registered_devices": true},
{
"hostname": "pentair: *",
"hostname": "pentair*",
"macaddress": "00C033*"
}
],
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/sense/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "sense",
"name": "Sense",
"documentation": "https://www.home-assistant.io/integrations/sense",
"requirements": ["sense_energy==0.10.3"],
"requirements": ["sense_energy==0.10.4"],
"codeowners": ["@kbickar"],
"config_flow": true,
"dhcp": [
Expand Down
22 changes: 11 additions & 11 deletions homeassistant/components/solaredge/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@

from homeassistant import config_entries
from homeassistant.const import CONF_API_KEY, CONF_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.util import slugify

from .const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN


@callback
def solaredge_entries(hass: HomeAssistant):
"""Return the site_ids for the domain."""
return {
(entry.data[CONF_SITE_ID])
for entry in hass.config_entries.async_entries(DOMAIN)
}


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

Expand All @@ -34,9 +25,18 @@ def __init__(self) -> None:
"""Initialize the config flow."""
self._errors = {}

@callback
def _async_current_site_ids(self) -> set[str]:
"""Return the site_ids for the domain."""
return {
entry.data[CONF_SITE_ID]
for entry in self._async_current_entries(include_ignore=False)
if CONF_SITE_ID in entry.data
}

def _site_in_configuration_exists(self, site_id: str) -> bool:
"""Return True if site_id exists in configuration."""
return site_id in solaredge_entries(self.hass)
return site_id in self._async_current_site_ids()

def _check_site(self, site_id: str, api_key: str) -> bool:
"""Check if we can connect to the soleredge api service."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zwave_js/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
TITLE = "Z-Wave JS"

ADDON_SETUP_TIMEOUT = 5
ADDON_SETUP_TIMEOUT_ROUNDS = 4
ADDON_SETUP_TIMEOUT_ROUNDS = 40
CONF_EMULATE_HARDWARE = "emulate_hardware"
CONF_LOG_LEVEL = "log_level"
SERVER_VERSION_TIMEOUT = 10
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

MAJOR_VERSION: Final = 2022
MINOR_VERSION: Final = 3
PATCH_VERSION: Final = "7"
PATCH_VERSION: Final = "8"
__short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__: Final = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 9, 0)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/generated/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
{'domain': 'samsungtv', 'macaddress': '4844F7*'},
{'domain': 'samsungtv', 'macaddress': '8CEA48*'},
{'domain': 'screenlogic', 'registered_devices': True},
{'domain': 'screenlogic', 'hostname': 'pentair: *', 'macaddress': '00C033*'},
{'domain': 'screenlogic', 'hostname': 'pentair*', 'macaddress': '00C033*'},
{'domain': 'sense', 'hostname': 'sense-*', 'macaddress': '009D6B*'},
{'domain': 'sense', 'hostname': 'sense-*', 'macaddress': 'DCEFCA*'},
{'domain': 'sense', 'hostname': 'sense-*', 'macaddress': 'A4D578*'},
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ multidict>=6.0.2
# Required for compatibility with point integration - ensure_active_token
# https://github.com/home-assistant/core/pull/68176
authlib<1.0

# Required for compatibility with typer, used by pyunifiprotect integration
# https://github.com/tiangolo/typer/pull/375
click<=8.0.4
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ sense-hat==2.2.0

# homeassistant.components.emulated_kasa
# homeassistant.components.sense
sense_energy==0.10.3
sense_energy==0.10.4

# homeassistant.components.sentry
sentry-sdk==1.5.5
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ screenlogicpy==0.5.4

# homeassistant.components.emulated_kasa
# homeassistant.components.sense
sense_energy==0.10.3
sense_energy==0.10.4

# homeassistant.components.sentry
sentry-sdk==1.5.5
Expand Down
4 changes: 4 additions & 0 deletions script/gen_requirements_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
# Required for compatibility with point integration - ensure_active_token
# https://github.com/home-assistant/core/pull/68176
authlib<1.0

# Required for compatibility with typer, used by pyunifiprotect integration
# https://github.com/tiangolo/typer/pull/375
click<=8.0.4
"""

IGNORE_PRE_COMMIT_HOOK_ID = (
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = homeassistant
version = 2022.3.7
version = 2022.3.8
author = The Home Assistant Authors
author_email = hello@home-assistant.io
license = Apache-2.0
Expand Down
1 change: 1 addition & 0 deletions tests/components/elkm1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
MOCK_MAC = "aa:bb:cc:dd:ee:ff"
ELK_DISCOVERY = ElkSystem(MOCK_MAC, MOCK_IP_ADDRESS, 2601)
ELK_NON_SECURE_DISCOVERY = ElkSystem(MOCK_MAC, MOCK_IP_ADDRESS, 2101)
ELK_DISCOVERY_NON_STANDARD_PORT = ElkSystem(MOCK_MAC, MOCK_IP_ADDRESS, 444)


def mock_elk(invalid_auth=None, sync_complete=None, exception=None):
Expand Down
Loading