Skip to content
Merged
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
14 changes: 6 additions & 8 deletions homeassistant/components/hikvision/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ async def async_step_user(
HikCamera, url, port, username, password, ssl
)
except requests.exceptions.RequestException:
_LOGGER.exception("Error connecting to Hikvision device")
errors["base"] = "cannot_connect"
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
device_id = camera.get_id
device_name = camera.get_name
Expand Down Expand Up @@ -105,10 +107,10 @@ async def async_step_import(self, import_data: ConfigType) -> ConfigFlowResult:
HikCamera, url, port, username, password, ssl
)
except requests.exceptions.RequestException:
_LOGGER.exception(
"Error connecting to Hikvision device during import, aborting"
)
return self.async_abort(reason="cannot_connect")
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")

device_id = camera.get_id
device_name = camera.get_name
Expand All @@ -118,10 +120,6 @@ async def async_step_import(self, import_data: ConfigType) -> ConfigFlowResult:
await self.async_set_unique_id(device_id)
self._abort_if_unique_id_configured()

_LOGGER.warning(
"Importing Hikvision config from configuration.yaml for %s", host
)

return self.async_create_entry(
title=name or device_name or host,
data={
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/hikvision/strings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"unknown": "[%key:common::config_flow::error::unknown%]"
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"unknown": "[%key:common::config_flow::error::unknown%]"
},
"step": {
"user": {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/knx/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"requirements": [
"xknx==3.13.0",
"xknxproject==3.8.2",
"knx-frontend==2025.12.24.74016"
"knx-frontend==2025.12.25.200238"
],
"single_config_entry": true
}
2 changes: 1 addition & 1 deletion homeassistant/components/plugwise/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "local_polling",
"loggers": ["plugwise"],
"quality_scale": "platinum",
"requirements": ["plugwise==1.11.0"],
"requirements": ["plugwise==1.11.2"],
"zeroconf": ["_plugwise._tcp.local."]
}
4 changes: 2 additions & 2 deletions homeassistant/components/zwave_js/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class ZWaveDiscoverySchema:
platform=Platform.COVER,
hint="shutter_tilt",
manufacturer_id={0x0460},
product_id={0x0082},
product_id={0x0082, 0x0083},
product_type={0x0003},
primary_value=ZWaveValueDiscoverySchema(
command_class={CommandClass.SWITCH_MULTILEVEL},
Expand Down Expand Up @@ -412,7 +412,7 @@ class ZWaveDiscoverySchema:
platform=Platform.COVER,
hint="shutter",
manufacturer_id={0x0460},
product_id={0x0082},
product_id={0x0082, 0x0083},
product_type={0x0003},
primary_value=ZWaveValueDiscoverySchema(
command_class={CommandClass.SWITCH_MULTILEVEL},
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions tests/components/hikvision/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
CONF_SSL,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant

from . import setup_integration

from tests.common import MockConfigEntry

Expand Down Expand Up @@ -94,12 +91,3 @@ def mock_hik_nvr(mock_hikcamera: MagicMock) -> MagicMock:
camera.current_event_states = {}
camera.get_event_triggers.return_value = {"Motion": [1, 2]}
return mock_hikcamera


@pytest.fixture
async def init_integration(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_hikcamera: MagicMock
) -> MockConfigEntry:
"""Set up the Hikvision integration for testing."""
await setup_integration(hass, mock_config_entry)
return mock_config_entry
70 changes: 70 additions & 0 deletions tests/components/hikvision/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,52 @@ async def test_form_exception(
assert result["result"].unique_id == TEST_DEVICE_ID


async def test_form_unknown_exception(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_hikcamera: MagicMock,
) -> None:
"""Test we handle unknown exception during connection and can recover."""
mock_hikcamera.side_effect = Exception("Unexpected error")

result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)

result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_HOST: TEST_HOST,
CONF_PORT: TEST_PORT,
CONF_USERNAME: TEST_USERNAME,
CONF_PASSWORD: TEST_PASSWORD,
CONF_SSL: False,
},
)

assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"}

# Recover from error
mock_hikcamera.side_effect = None
mock_hikcamera.return_value.get_id = TEST_DEVICE_ID
mock_hikcamera.return_value.get_name = TEST_DEVICE_NAME

result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_HOST: TEST_HOST,
CONF_PORT: TEST_PORT,
CONF_USERNAME: TEST_USERNAME,
CONF_PASSWORD: TEST_PASSWORD,
CONF_SSL: False,
},
)

assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].unique_id == TEST_DEVICE_ID


async def test_form_already_configured(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
Expand Down Expand Up @@ -297,6 +343,30 @@ async def test_import_flow_no_device_id(
assert result["reason"] == "cannot_connect"


async def test_import_flow_unknown_exception(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_hikcamera: MagicMock,
) -> None:
"""Test YAML import flow aborts on unknown exception."""
mock_hikcamera.side_effect = Exception("Unexpected error")

result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_HOST: TEST_HOST,
CONF_PORT: TEST_PORT,
CONF_USERNAME: TEST_USERNAME,
CONF_PASSWORD: TEST_PASSWORD,
CONF_SSL: False,
},
)

assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"


async def test_import_flow_already_configured(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "f871b8c4d63549319221e294e4f88074",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Tom Badkamer",
"sensors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "f871b8c4d63549319221e294e4f88074",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Tom Badkamer",
"sensors": {
Expand Down
8 changes: 4 additions & 4 deletions tests/components/plugwise/fixtures/m_adam_jip/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "d58fec52899f4f1c92e4f8fad6d8c48c",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Tom Logeerkamer",
"sensors": {
Expand All @@ -108,7 +108,7 @@
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "06aecb3d00354375924f50c47af36bd2",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Tom Slaapkamer",
"sensors": {
Expand Down Expand Up @@ -175,7 +175,7 @@
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "13228dab8ce04617af318a2888b3c548",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Tom Woonkamer",
"sensors": {
Expand Down Expand Up @@ -275,7 +275,7 @@
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "d27aede973b54be484f6842d1b2802ad",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Tom Kinderkamer",
"sensors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "08963fec7c53423ca5680aa4cb502c63",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Thermostatic Radiator Badkamer 1",
"sensors": {
Expand Down Expand Up @@ -327,7 +327,7 @@
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "12493538af164a409c6a1c79e38afe1c",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Bios Cv Thermostatic Radiator ",
"sensors": {
Expand All @@ -352,7 +352,7 @@
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "c50f167537524366a5af7aa3942feb1e",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Floor kraan",
"sensors": {
Expand Down Expand Up @@ -460,7 +460,7 @@
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "82fa13f017d240daa0d0ea1775420f24",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "Thermostatic Radiator Jessie",
"sensors": {
Expand Down Expand Up @@ -528,7 +528,7 @@
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "446ac08dd04d4eff8ac57489757b7314",
"model": "Tom/Floor",
"model": "Tom",
"model_id": "106-03",
"name": "CV Kraan Garage",
"sensors": {
Expand Down
10 changes: 5 additions & 5 deletions tests/components/plugwise/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '08963fec7c53423ca5680aa4cb502c63',
'model': 'Tom/Floor',
'model': 'Tom',
'model_id': '106-03',
'name': 'Thermostatic Radiator Badkamer 1',
'sensors': dict({
Expand Down Expand Up @@ -366,7 +366,7 @@
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '12493538af164a409c6a1c79e38afe1c',
'model': 'Tom/Floor',
'model': 'Tom',
'model_id': '106-03',
'name': 'Bios Cv Thermostatic Radiator ',
'sensors': dict({
Expand All @@ -391,7 +391,7 @@
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': 'c50f167537524366a5af7aa3942feb1e',
'model': 'Tom/Floor',
'model': 'Tom',
'model_id': '106-03',
'name': 'Floor kraan',
'sensors': dict({
Expand Down Expand Up @@ -509,7 +509,7 @@
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '82fa13f017d240daa0d0ea1775420f24',
'model': 'Tom/Floor',
'model': 'Tom',
'model_id': '106-03',
'name': 'Thermostatic Radiator Jessie',
'sensors': dict({
Expand Down Expand Up @@ -577,7 +577,7 @@
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '446ac08dd04d4eff8ac57489757b7314',
'model': 'Tom/Floor',
'model': 'Tom',
'model_id': '106-03',
'name': 'CV Kraan Garage',
'sensors': dict({
Expand Down
Loading
Loading