1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Bump bosch-alarm-mode2 to v0.4.10 (#157564)

This commit is contained in:
Sanjay Govind
2025-12-01 04:02:43 +13:00
committed by GitHub
parent 6357067f0f
commit 64bed19805
11 changed files with 41 additions and 34 deletions

View File

@@ -68,9 +68,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: BoschAlarmConfigEntry) -
config_entry_id=entry.entry_id,
connections={(CONNECTION_NETWORK_MAC, mac)} if mac else set(),
identifiers={(DOMAIN, entry.unique_id or entry.entry_id)},
name=f"Bosch {panel.model}",
name=f"Bosch {panel.model.name}",
manufacturer="Bosch Security Systems",
model=panel.model,
model=panel.model.name,
sw_version=panel.firmware_version,
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

View File

@@ -83,7 +83,7 @@ async def try_connect(
finally:
await panel.disconnect()
return (panel.model, panel.serial_number)
return (panel.model.name, panel.serial_number)
class BoschAlarmConfigFlow(ConfigFlow, domain=DOMAIN):

View File

@@ -20,7 +20,8 @@ async def async_get_config_entry_diagnostics(
return {
"entry_data": async_redact_data(entry.data, TO_REDACT),
"data": {
"model": entry.runtime_data.model,
"model": entry.runtime_data.model.name,
"family": entry.runtime_data.model.family.name,
"serial_number": entry.runtime_data.serial_number,
"protocol_version": entry.runtime_data.protocol_version,
"firmware_version": entry.runtime_data.firmware_version,

View File

@@ -26,7 +26,7 @@ class BoschAlarmEntity(Entity):
self._attr_should_poll = False
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, unique_id)},
name=f"Bosch {panel.model}",
name=f"Bosch {panel.model.name}",
manufacturer="Bosch Security Systems",
)

View File

@@ -12,5 +12,5 @@
"integration_type": "device",
"iot_class": "local_push",
"quality_scale": "platinum",
"requirements": ["bosch-alarm-mode2==0.4.6"]
"requirements": ["bosch-alarm-mode2==0.4.10"]
}

2
requirements_all.txt generated
View File

@@ -675,7 +675,7 @@ bluetooth-data-tools==1.28.4
bond-async==0.2.1
# homeassistant.components.bosch_alarm
bosch-alarm-mode2==0.4.6
bosch-alarm-mode2==0.4.10
# homeassistant.components.bosch_shc
boschshcpy==0.2.107

View File

@@ -609,7 +609,7 @@ bluetooth-data-tools==1.28.4
bond-async==0.2.1
# homeassistant.components.bosch_alarm
bosch-alarm-mode2==0.4.6
bosch-alarm-mode2==0.4.10
# homeassistant.components.bosch_shc
boschshcpy==0.2.107

View File

@@ -4,6 +4,7 @@ from collections.abc import Generator
from typing import Any
from unittest.mock import AsyncMock, patch
from bosch_alarm_mode2.const import PANEL_FAMILY, PanelModel
from bosch_alarm_mode2.panel import Area, Door, Output, Point
from bosch_alarm_mode2.utils import Observable
import pytest
@@ -39,10 +40,10 @@ def model(request: pytest.FixtureRequest) -> Generator[str]:
@pytest.fixture
def extra_config_entry_data(
model: str, model_name: str, config_flow_data: dict[str, Any]
model: str, panel_model: PanelModel, config_flow_data: dict[str, Any]
) -> dict[str, Any]:
"""Return extra config entry data."""
return {CONF_MODEL: model_name} | config_flow_data
return {CONF_MODEL: panel_model.name} | config_flow_data
@pytest.fixture(params=[None])
@@ -64,12 +65,12 @@ def config_flow_data(model: str) -> dict[str, Any]:
@pytest.fixture
def model_name(model: str) -> str | None:
def panel_model(model: str) -> PanelModel | None:
"""Return extra config entry data."""
return {
"solution_3000": "Solution 3000",
"amax_3000": "AMAX 3000",
"b5512": "B5512 (US1B)",
"solution_3000": PanelModel("Solution 3000", PANEL_FAMILY.SOLUTION),
"amax_3000": PanelModel("AMAX 3000", PANEL_FAMILY.AMAX),
"b5512": PanelModel("B5512 (US1B)", PANEL_FAMILY.BG_SERIES),
}.get(model)
@@ -166,7 +167,7 @@ def mock_panel(
door: AsyncMock,
output: AsyncMock,
points: dict[int, AsyncMock],
model_name: str,
panel_model: str,
serial_number: str | None,
) -> Generator[AsyncMock]:
"""Define a fixture to set up Bosch Alarm."""
@@ -181,7 +182,7 @@ def mock_panel(
client.doors = {1: door}
client.outputs = {1: output}
client.points = points
client.model = model_name
client.model = panel_model
client.faults = []
client.events = []
client.panel_faults_ids = []

View File

@@ -28,6 +28,7 @@
'open': False,
}),
]),
'family': 'AMAX',
'firmware_version': '1.0.0',
'history_events': list([
]),
@@ -124,6 +125,7 @@
'open': False,
}),
]),
'family': 'BG_SERIES',
'firmware_version': '1.0.0',
'history_events': list([
]),
@@ -219,6 +221,7 @@
'open': False,
}),
]),
'family': 'SOLUTION',
'firmware_version': '1.0.0',
'history_events': list([
]),

View File

@@ -4,6 +4,7 @@ import asyncio
from typing import Any
from unittest.mock import AsyncMock
from bosch_alarm_mode2.const import PANEL_FAMILY, PanelModel
import pytest
from homeassistant.components.bosch_alarm.const import DOMAIN
@@ -22,7 +23,7 @@ async def test_form_user(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
) -> None:
@@ -45,13 +46,13 @@ async def test_form_user(
config_flow_data,
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Bosch {model_name}"
assert result["title"] == f"Bosch {panel_model.name}"
assert (
result["data"]
== {
CONF_HOST: "1.1.1.1",
CONF_PORT: 7700,
CONF_MODEL: model_name,
CONF_MODEL: panel_model.name,
}
| config_flow_data
)
@@ -211,7 +212,7 @@ async def test_dhcp_can_finish(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
) -> None:
@@ -237,12 +238,12 @@ async def test_dhcp_can_finish(
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Bosch {model_name}"
assert result["title"] == f"Bosch {panel_model.name}"
assert result["data"] == {
CONF_HOST: "1.1.1.1",
CONF_MAC: "34:ea:34:b4:3b:5a",
CONF_PORT: 7700,
CONF_MODEL: model_name,
CONF_MODEL: panel_model.name,
**config_flow_data,
}
@@ -258,7 +259,7 @@ async def test_dhcp_exceptions(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
exception: Exception,
@@ -316,7 +317,7 @@ async def test_dhcp_discovery_if_panel_setup_config_flow(
mock_config_entry: MockConfigEntry,
mock_panel: AsyncMock,
serial_number: str,
model_name: str,
panel_model: PanelModel,
config_flow_data: dict[str, Any],
) -> None:
"""Test DHCP discovery doesn't fail if a different panel was set up via config flow."""
@@ -346,12 +347,12 @@ async def test_dhcp_discovery_if_panel_setup_config_flow(
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Bosch {model_name}"
assert result["title"] == f"Bosch {panel_model.name}"
assert result["data"] == {
CONF_HOST: "4.5.6.7",
CONF_MAC: "34:ea:34:b4:3b:5a",
CONF_PORT: 7700,
CONF_MODEL: model_name,
CONF_MODEL: panel_model.name,
**config_flow_data,
}
assert mock_config_entry.unique_id == serial_number
@@ -395,7 +396,7 @@ async def test_dhcp_updates_mac(
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
) -> None:
@@ -424,7 +425,7 @@ async def test_reauth_flow_success(
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
) -> None:
@@ -459,7 +460,7 @@ async def test_reauth_flow_error(
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
exception: Exception,
@@ -494,7 +495,7 @@ async def test_reconfig_flow(
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
) -> None:
@@ -529,7 +530,7 @@ async def test_reconfig_flow(
assert mock_config_entry.data == {
CONF_HOST: "1.1.1.1",
CONF_PORT: 7700,
CONF_MODEL: model_name,
CONF_MODEL: panel_model.name,
**config_flow_data,
}
@@ -540,7 +541,7 @@ async def test_reconfig_flow_incorrect_model(
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
mock_panel: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
config_flow_data: dict[str, Any],
) -> None:
@@ -556,7 +557,7 @@ async def test_reconfig_flow_incorrect_model(
},
)
mock_panel.model = "Solution 3000"
mock_panel.model = PanelModel("Solution 3000", family=PANEL_FAMILY.SOLUTION)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"

View File

@@ -3,6 +3,7 @@
from typing import Any
from unittest.mock import AsyncMock
from bosch_alarm_mode2.const import PanelModel
from syrupy.assertion import SnapshotAssertion
from homeassistant.core import HomeAssistant
@@ -19,7 +20,7 @@ async def test_diagnostics(
hass_client: ClientSessionGenerator,
mock_panel: AsyncMock,
area: AsyncMock,
model_name: str,
panel_model: PanelModel,
serial_number: str,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,