XaF / qolsysgw

Qolsys IQ Panel 2+ gateway to an Home Assistant Alarm Control Panel
MIT License
131 stars 13 forks source link

✨ [feature] Add support for `Temperature` sensor #100

Closed jthun closed 1 year ago

jthun commented 1 year ago

Thank you for an awesome integration!

This PR adds support for Visonic TMD-560 PG2 Temperature sensor. It's a low/high temp sensor, so I'm not sure if 'heat' is the right sensor type. I have not been able to test but added the baseline code for the new sensor subclass.

jthun commented 1 year ago

Just saw that the group should probably be Temperature with capital T.

From my zone_list in the INFO event:

{ "group": "Temperature", "id": "250-1234", "name": "Temperature", "partition_id": 0, "state": "0", "status": "Closed", "type": "Temperature", "zone_alarm_type": 0, "zone_id": 17, "zone_physical_type": 1, "zone_type": 8 },

jthun commented 1 year ago

Hmm. Could you please give some direction on how to set up the dev environment so that I can run pytest locally? I have the dev container running, but where should I put the qolsysgw repo so that the tests will run? config/custom_components? Sorry for the newbie questions...

The errors I get when running pytest now are:

=================================== ERRORS ====================================
_____________ ERROR collecting tests/end-to-end/test_qolsysgw.py ______________
ImportError while importing test module 'c:\Users\j\source\repos\qolsysgw\tests\end-to-end\test_qolsysgw.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\end-to-end\test_qolsysgw.py:2: in 
    import copier
E   ModuleNotFoundError: No module named 'copier'
____ ERROR collecting tests/integration/test_alarm_control_panel_config.py ____
tests\integration\test_alarm_control_panel_config.py:4: in 
    from testbase import TestQolsysGatewayBase
tests\integration\testbase.py:12: in 
    class TestQolsysGatewayBase(unittest.IsolatedAsyncioTestCase):
E   AttributeError: module 'unittest' has no attribute 'IsolatedAsyncioTestCase'
_____________ ERROR collecting tests/integration/test_gateway.py ______________
tests\integration\test_gateway.py:4: in 
    from testbase import TestQolsysGatewayBase
tests\integration\testbase.py:12: in 
    class TestQolsysGatewayBase(unittest.IsolatedAsyncioTestCase):
E   AttributeError: module 'unittest' has no attribute 'IsolatedAsyncioTestCase'
_________ ERROR collecting tests/integration/test_gateway_control.py __________
tests\integration\test_gateway_control.py:4: in 
    from testbase import TestQolsysGatewayBase
tests\integration\testbase.py:12: in 
    class TestQolsysGatewayBase(unittest.IsolatedAsyncioTestCase):
E   AttributeError: module 'unittest' has no attribute 'IsolatedAsyncioTestCase'
__________ ERROR collecting tests/integration/test_qolsys_events.py ___________
tests\integration\test_qolsys_events.py:7: in 
    from testbase import TestQolsysGatewayBase
tests\integration\testbase.py:12: in 
    class TestQolsysGatewayBase(unittest.IsolatedAsyncioTestCase):
E   AttributeError: module 'unittest' has no attribute 'IsolatedAsyncioTestCase'
_________ ERROR collecting tests/unit/qolsysgw/mqtt/test_listener.py __________
tests\unit\qolsysgw\mqtt\test_listener.py:12: in 
    class TestUnitMqttQolsysEventListener(unittest.IsolatedAsyncioTestCase):
E   AttributeError: module 'unittest' has no attribute 'IsolatedAsyncioTestCase'
_________ ERROR collecting tests/unit/qolsysgw/qolsys/test_control.py _________
tests\unit\qolsysgw\qolsys\test_control.py:16: in 
    class TestUnitQolsysControlDisarm(unittest.IsolatedAsyncioTestCase):
E   AttributeError: module 'unittest' has no attribute 'IsolatedAsyncioTestCase'
=========================== short test summary info ===========================
ERROR tests/end-to-end/test_qolsysgw.py
ERROR tests/integration/test_alarm_control_panel_config.py - AttributeError: ...
ERROR tests/integration/test_gateway.py - AttributeError: module 'unittest' h...
ERROR tests/integration/test_gateway_control.py - AttributeError: module 'uni...
ERROR tests/integration/test_qolsys_events.py - AttributeError: module 'unitt...
ERROR tests/unit/qolsysgw/mqtt/test_listener.py - AttributeError: module 'uni...
ERROR tests/unit/qolsysgw/qolsys/test_control.py - AttributeError: module 'un...
!!!!!!!!!!!!!!!!!!! Interrupted: 7 errors during collection !!!!!!!!!!!!!!!!!!!
==================== 20 tests collected, 7 errors in 0.33s ====================
XaF commented 1 year ago

You seem to be lacking some requirements! From https://github.com/XaF/qolsysgw/blob/main/.github/workflows/build.yaml#L223-L225 :

pip install pytest pytest-clarity pytest-subtests
pip install -r tests/requirements.txt
pip install -r tests/end-to-end/requirements.txt

That being said, the error left seems to simply be related to https://github.com/XaF/qolsysgw/blob/a60d949e39fd1fcb1d2d0bf9f1e3a0f7e4d7cb7c/tests/integration/test_qolsys_events.py#L261 - we added a sensor, but we're still expecting 8 sensors in the partition vs. 9 !

XaF commented 1 year ago

You should be able to rely on the tests here for the end-to-end now. Right now there is a lint issue! Sorry for the delay - had to fight with github tokens as there's supposed to be a code coverage comment, I disabled that for fork pull requests for now, and I'll re-investigate that later when I get a moment!

jthun commented 1 year ago

Sorry for the messy commits but "it" didn't want to add my new line in sensors.py. Now it should pass that linting, at least.

XaF commented 1 year ago

Finally got the time to get to this, will merge now!