Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [feature] Add support for Auxiliary Pendant sensors #91

Merged
merged 1 commit into from
Feb 19, 2023
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
2 changes: 2 additions & 0 deletions apps/qolsysgw/mqtt/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from qolsys.config import QolsysGatewayConfig
from qolsys.partition import QolsysPartition
from qolsys.sensors import QolsysSensor
from qolsys.sensors import QolsysSensorAuxiliaryPendant
from qolsys.sensors import QolsysSensorBluetooth
from qolsys.sensors import QolsysSensorCODetector
from qolsys.sensors import QolsysSensorDoorWindow
Expand Down Expand Up @@ -438,6 +439,7 @@ class MqttWrapperQolsysSensor(MqttWrapper):
QolsysSensorHeat: 'heat',
QolsysSensorTilt: 'garage_door',
QolsysSensorKeypad: 'safety',
QolsysSensorAuxiliaryPendant: 'safety',
}

def __init__(self, sensor: QolsysSensor, *args, **kwargs):
Expand Down
6 changes: 6 additions & 0 deletions apps/qolsysgw/qolsys/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,9 @@ class QolsysSensorKeypad(QolsysSensor, _QolsysSensorWithoutUpdates):
@classmethod
def from_json(cls, data, common=None):
return cls.from_json_subclass('Keypad', data, common)


class QolsysSensorAuxiliaryPendant(QolsysSensor, _QolsysSensorWithoutUpdates):
@classmethod
def from_json(cls, data, common=None):
return cls.from_json_subclass('Auxiliary Pendant', data, common)
28 changes: 27 additions & 1 deletion tests/end-to-end/test_qolsysgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,19 @@ async def _check_initial_state(self, ctx):
'entity_id': 'binary_sensor.my_keypad_sensor',
'state': 'off',
},
{
'attributes': {
'device_class': 'safety',
'friendly_name': 'My Auxiliary Pendant Sensor',
'group': 'fixedmedical',
'zone_alarm_type': 0,
'zone_physical_type': 1,
'zone_type': 21,
'tampered': False,
},
'entity_id': 'binary_sensor.my_auxiliary_pendant_sensor',
'state': 'off',
},
]
self._check_entity_states(ctx, expected_states, msg='Initial state')

Expand All @@ -459,7 +472,7 @@ async def _check_panel_events(self, ctx):
]

closed_entities = [100, 110, 111, 120, 121, 130, 140, 141, 150,
200, 210, 220, 230, 240]
200, 210, 220, 230, 240, 250]
open_entities = [101]
tamper_entities = [100, 110, 111, 210]
untamper_entities_to_open = [100]
Expand Down Expand Up @@ -779,6 +792,19 @@ def zone_active_event(zone_id, closed=False):
'entity_id': 'binary_sensor.my_keypad_sensor',
'state': 'on',
},
{
'attributes': {
'device_class': 'safety',
'friendly_name': 'My Auxiliary Pendant Sensor',
'group': 'fixedmedical',
'zone_alarm_type': 0,
'zone_physical_type': 1,
'zone_type': 21,
'tampered': False,
},
'entity_id': 'binary_sensor.my_auxiliary_pendant_sensor',
'state': 'on',
},
]
self._check_entity_states(ctx, expected_states, msg='Panel events')

Expand Down
25 changes: 24 additions & 1 deletion tests/integration/test_qolsys_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from testutils.mock_types import ISODATE

from qolsys.sensors import QolsysSensorAuxiliaryPendant
from qolsys.sensors import QolsysSensorBluetooth
from qolsys.sensors import QolsysSensorCODetector
from qolsys.sensors import QolsysSensorDoorWindow
Expand Down Expand Up @@ -254,7 +255,7 @@ async def test_integration_event_info_summary_initializes_all_entities(self):

with self.subTest(msg='Partition 1 is properly configured'):
partition1 = state.partition(1)
self.assertEqual(5, len(partition1.sensors))
self.assertEqual(6, len(partition1.sensors))
self.assertEqual(1, partition1.id)
self.assertEqual('partition1', partition1.name)
self.assertEqual('DISARM', partition1.status)
Expand Down Expand Up @@ -599,6 +600,28 @@ async def test_integration_event_info_summary_initializes_all_entities(self):
expected_enabled_by_default=False,
)

with self.subTest(msg='Sensor 250 is properly configured'):
sensor250 = partition1.zone(250)
self.assertEqual(QolsysSensorAuxiliaryPendant, sensor250.__class__)
self.assertEqual('002-0050', sensor250.id)
self.assertEqual('My Auxiliary Pendant Sensor', sensor250.name)
self.assertEqual('fixedmedical', sensor250.group)
self.assertEqual('Closed', sensor250.status)
self.assertEqual('0', sensor250.state)
self.assertEqual(250, sensor250.zone_id)
self.assertEqual(1, sensor250.zone_physical_type)
self.assertEqual(0, sensor250.zone_alarm_type)
self.assertEqual(21, sensor250.zone_type)
self.assertEqual(1, sensor250.partition_id)

await self._check_sensor_mqtt_messages(
gw=gw,
sensor_flat_name='my_auxiliary_pendant_sensor',
sensor_state=sensor250,
expected_device_class='safety',
expected_enabled_by_default=False,
)

async def _test_integration_event_info_secure_arm(self, from_secure_arm,
to_secure_arm):
panel, gw, _, _ = await self._ready_panel_and_gw(
Expand Down
13 changes: 13 additions & 0 deletions tests/mock_modules/testutils/fixtures_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,19 @@ def get_summary(secure_arm=False, partition_ids=None,
'zone_type': 104,
'partition_id': 1,
},
{
'id': '002-0050',
'type': 'Auxiliary Pendant',
'name': 'My Auxiliary Pendant Sensor',
'group': 'fixedmedical',
'status': 'Closed',
'state': '0',
'zone_id': 250,
'zone_physical_type': 1,
'zone_alarm_type': 0,
'zone_type': 21,
'partition_id': 1,
},
],
},
],
Expand Down