mirror of
https://github.com/home-assistant/core.git
synced 2026-12-03 04:08:19 -04:00
Fix bosch_alarm ready to arm binary sensor observer (#195245)
Co-authored-by: tisocks <tisocks@users.noreply.github.com>
This commit is contained in:
@@ -60,7 +60,13 @@ class AreaAlarmControlPanel(BoschAlarmAreaEntity, AlarmControlPanelEntity):
|
||||
) -> None:
|
||||
"""Initialise a Bosch Alarm control panel entity."""
|
||||
super().__init__(
|
||||
hass, panel, area_id, unique_id, config_entry_id, True, False, True
|
||||
hass,
|
||||
panel,
|
||||
area_id,
|
||||
unique_id,
|
||||
config_entry_id,
|
||||
observe_alarms=True,
|
||||
observe_status=True,
|
||||
)
|
||||
self._attr_unique_id = self._area_unique_id
|
||||
|
||||
|
||||
@@ -193,7 +193,12 @@ class AreaReadyToArmSensor(BoschAlarmAreaEntity, BinarySensorEntity):
|
||||
) -> None:
|
||||
"""Set up a binary sensor for arming status in a bosch panel."""
|
||||
super().__init__(
|
||||
hass, panel, area_id, unique_id, config_entry_id, False, False, True
|
||||
hass,
|
||||
panel,
|
||||
area_id,
|
||||
unique_id,
|
||||
config_entry_id,
|
||||
observe_ready=True,
|
||||
)
|
||||
self.panel = panel
|
||||
self._arm_type = arm_type
|
||||
|
||||
@@ -63,9 +63,10 @@ class BoschAlarmAreaEntity(BoschAlarmEntity):
|
||||
area_id: int,
|
||||
unique_id: str,
|
||||
config_entry_id: str,
|
||||
observe_alarms: bool,
|
||||
observe_ready: bool,
|
||||
observe_status: bool,
|
||||
*,
|
||||
observe_alarms: bool = False,
|
||||
observe_ready: bool = False,
|
||||
observe_status: bool = False,
|
||||
) -> None:
|
||||
"""Set up a area related entity for a bosch alarm panel."""
|
||||
super().__init__(panel, unique_id)
|
||||
|
||||
@@ -114,9 +114,9 @@ class BoschAreaSensor(BoschAlarmAreaEntity, SensorEntity):
|
||||
area_id,
|
||||
unique_id,
|
||||
config_entry_id,
|
||||
entity_description.observe_alarms,
|
||||
entity_description.observe_ready,
|
||||
entity_description.observe_status,
|
||||
observe_alarms=entity_description.observe_alarms,
|
||||
observe_ready=entity_description.observe_ready,
|
||||
observe_status=entity_description.observe_status,
|
||||
)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id = f"{self._area_unique_id}_{entity_description.key}"
|
||||
|
||||
@@ -56,24 +56,24 @@ async def test_panel_faults(
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", ["b5512"])
|
||||
@pytest.mark.usefixtures("mock_panel")
|
||||
async def test_area_ready_to_arm(
|
||||
hass: HomeAssistant,
|
||||
mock_panel: AsyncMock,
|
||||
area: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that fault sensor state changes after inducing a fault."""
|
||||
"""Test that area ready to arm sensor state changes when readiness updates."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
entity_id = "binary_sensor.area1_area_ready_to_arm_away"
|
||||
entity_id_2 = "binary_sensor.area1_area_ready_to_arm_home"
|
||||
assert hass.states.get(entity_id).state == STATE_ON
|
||||
assert hass.states.get(entity_id_2).state == STATE_ON
|
||||
area.all_ready = False
|
||||
await call_observable(hass, area.status_observer)
|
||||
await call_observable(hass, area.ready_observer)
|
||||
assert hass.states.get(entity_id).state == STATE_OFF
|
||||
assert hass.states.get(entity_id_2).state == STATE_ON
|
||||
area.part_ready = False
|
||||
await call_observable(hass, area.status_observer)
|
||||
await call_observable(hass, area.ready_observer)
|
||||
assert hass.states.get(entity_id).state == STATE_OFF
|
||||
assert hass.states.get(entity_id_2).state == STATE_OFF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user