Add code_arm_required to manual alarm with MQTT (#22641)
* add code_arm_requited to manual-mqtt alarm * Add fix for alarm front end more-info-alarm_control_panel * Fix code mistake
This commit is contained in:
1 parent
cb5426c1fa
commit
f722a6c08d
4 files changed
+110
-7
No files matched your search
@@ -77,6 +77,32 @@ class TestAlarmControlPanelManualMqtt(unittest.TestCase):
|
||||
assert STATE_ALARM_ARMED_HOME == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
def test_arm_home_no_pending_when_code_not_req(self):
|
||||
"""Test arm home method."""
|
||||
assert setup_component(
|
||||
self.hass, alarm_control_panel.DOMAIN,
|
||||
{'alarm_control_panel': {
|
||||
'platform': 'manual_mqtt',
|
||||
'name': 'test',
|
||||
'code': CODE,
|
||||
'code_arm_required': False,
|
||||
'pending_time': 0,
|
||||
'disarm_after_trigger': False,
|
||||
'command_topic': 'alarm/command',
|
||||
'state_topic': 'alarm/state',
|
||||
}})
|
||||
|
||||
entity_id = 'alarm_control_panel.test'
|
||||
|
||||
assert STATE_ALARM_DISARMED == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
common.alarm_arm_home(self.hass, 0)
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert STATE_ALARM_ARMED_HOME == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
def test_arm_home_with_pending(self):
|
||||
"""Test arm home method."""
|
||||
assert setup_component(
|
||||
@@ -164,6 +190,32 @@ class TestAlarmControlPanelManualMqtt(unittest.TestCase):
|
||||
assert STATE_ALARM_ARMED_AWAY == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
def test_arm_away_no_pending_when_code_not_req(self):
|
||||
"""Test arm home method."""
|
||||
assert setup_component(
|
||||
self.hass, alarm_control_panel.DOMAIN,
|
||||
{'alarm_control_panel': {
|
||||
'platform': 'manual_mqtt',
|
||||
'name': 'test',
|
||||
'code_arm_required': False,
|
||||
'code': CODE,
|
||||
'pending_time': 0,
|
||||
'disarm_after_trigger': False,
|
||||
'command_topic': 'alarm/command',
|
||||
'state_topic': 'alarm/state',
|
||||
}})
|
||||
|
||||
entity_id = 'alarm_control_panel.test'
|
||||
|
||||
assert STATE_ALARM_DISARMED == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
common.alarm_arm_away(self.hass, 0, entity_id)
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert STATE_ALARM_ARMED_AWAY == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
def test_arm_home_with_template_code(self):
|
||||
"""Attempt to arm with a template-based code."""
|
||||
assert setup_component(
|
||||
@@ -279,6 +331,32 @@ class TestAlarmControlPanelManualMqtt(unittest.TestCase):
|
||||
assert STATE_ALARM_ARMED_NIGHT == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
def test_arm_night_no_pending_when_code_not_req(self):
|
||||
"""Test arm night method."""
|
||||
assert setup_component(
|
||||
self.hass, alarm_control_panel.DOMAIN,
|
||||
{'alarm_control_panel': {
|
||||
'platform': 'manual_mqtt',
|
||||
'name': 'test',
|
||||
'code_arm_required': False,
|
||||
'code': CODE,
|
||||
'pending_time': 0,
|
||||
'disarm_after_trigger': False,
|
||||
'command_topic': 'alarm/command',
|
||||
'state_topic': 'alarm/state',
|
||||
}})
|
||||
|
||||
entity_id = 'alarm_control_panel.test'
|
||||
|
||||
assert STATE_ALARM_DISARMED == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
common.alarm_arm_night(self.hass, 0, entity_id)
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert STATE_ALARM_ARMED_NIGHT == \
|
||||
self.hass.states.get(entity_id).state
|
||||
|
||||
def test_arm_night_with_pending(self):
|
||||
"""Test arm night method."""
|
||||
assert setup_component(
|
||||
|
||||
Reference in new issue
Block a user