Add attribute to show who last un/set alarm (SPC) (#9906)
* Add attribute to show who last un/set alarm. This allows showing the name of the SPC user who last issued an arm/disarm command and also allows for automations to depend on this value. * Optimize * Update spc.py * Update spc.py * fix * Fix test. * Fix for removed is_state_attr.
This commit is contained in:
1 parent
68fb995c63
commit
db56748d88
6 files changed
+82
-45
No files matched your search
@@ -7,7 +7,7 @@ from homeassistant.components.spc import SpcRegistry
|
||||
from homeassistant.components.alarm_control_panel import spc
|
||||
from tests.common import async_test_home_assistant
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED)
|
||||
STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -38,19 +38,19 @@ def test_setup_platform(hass):
|
||||
'last_set_user_name': 'Pelle',
|
||||
'last_unset_time': '1485800564',
|
||||
'last_unset_user_id': '1',
|
||||
'last_unset_user_name': 'Pelle',
|
||||
'last_unset_user_name': 'Lisa',
|
||||
'last_alarm': '1478174896'
|
||||
}, {
|
||||
}, {
|
||||
'id': '3',
|
||||
'name': 'Garage',
|
||||
'mode': '0',
|
||||
'last_set_time': '1483705803',
|
||||
'last_set_user_id': '9998',
|
||||
'last_set_user_name': 'Lisa',
|
||||
'last_set_user_name': 'Pelle',
|
||||
'last_unset_time': '1483705808',
|
||||
'last_unset_user_id': '9998',
|
||||
'last_unset_user_name': 'Lisa'
|
||||
}]}
|
||||
}]}
|
||||
|
||||
yield from spc.async_setup_platform(hass=hass,
|
||||
config={},
|
||||
@@ -58,7 +58,11 @@ def test_setup_platform(hass):
|
||||
discovery_info=areas)
|
||||
|
||||
assert len(added_entities) == 2
|
||||
|
||||
assert added_entities[0].name == 'House'
|
||||
assert added_entities[0].state == STATE_ALARM_ARMED_AWAY
|
||||
assert added_entities[0].changed_by == 'Pelle'
|
||||
|
||||
assert added_entities[1].name == 'Garage'
|
||||
assert added_entities[1].state == STATE_ALARM_DISARMED
|
||||
assert added_entities[1].changed_by == 'Lisa'
|
||||
Reference in new issue
Block a user