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 Temperature sensor #100

Merged
merged 22 commits into from
Jun 26, 2023

Conversation

jthun
Copy link
Contributor

@jthun jthun commented Feb 27, 2023

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
Copy link
Contributor Author

jthun commented Feb 27, 2023

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 },

Copy link
Owner

@XaF XaF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution! And for your patience!
Just a few comments below :)

We're also missing a test in tests/integration/test_qolsys_events.py (e.g. https://github.com/XaF/qolsysgw/pull/93/files#diff-6332c8d6f4e44732305529e69c856d16a7a14d452704fe15fdacab145e0387c8)

apps/qolsysgw/mqtt/updater.py Show resolved Hide resolved
tests/mock_modules/testutils/fixtures_data.py Outdated Show resolved Hide resolved
Copy link
Owner

@XaF XaF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few other updates!
I approved the workflow so you can see the current state of the tests: https://github.com/XaF/qolsysgw/actions/runs/4561734609

You should also be able to run the tests locally using pytest

apps/qolsysgw/mqtt/updater.py Show resolved Hide resolved
tests/end-to-end/test_qolsysgw.py Outdated Show resolved Hide resolved
tests/end-to-end/test_qolsysgw.py Outdated Show resolved Hide resolved
tests/end-to-end/test_qolsysgw.py Outdated Show resolved Hide resolved
tests/end-to-end/test_qolsysgw.py Outdated Show resolved Hide resolved
tests/end-to-end/test_qolsysgw.py Outdated Show resolved Hide resolved
@jthun
Copy link
Contributor Author

jthun commented Mar 31, 2023

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
Copy link
Owner

XaF commented Mar 31, 2023

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

self.assertEqual(8, len(partition1.sensors))
- we added a sensor, but we're still expecting 8 sensors in the partition vs. 9 !

@XaF XaF changed the title Added support for Temperature sensor ✨ [feature] Add support for Temperature sensor Apr 28, 2023
@XaF
Copy link
Owner

XaF commented Apr 28, 2023

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
Copy link
Contributor Author

jthun commented May 25, 2023

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
Copy link
Owner

XaF commented Jun 26, 2023

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

@XaF XaF merged commit 0f21016 into XaF:main Jun 26, 2023
@jthun jthun deleted the temperature_support branch June 26, 2023 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants