diff --git a/tests/protocols/test_generic2.py b/tests/protocols/test_generic2.py new file mode 100644 index 0000000..01d8e87 --- /dev/null +++ b/tests/protocols/test_generic2.py @@ -0,0 +1,46 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import generic2 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestGeneric2(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = generic2.decode( + "011010101010101001011010101010101010101010010101101001101010100102" + ) + self.assertDictEqual( + { + "id": 123, + "type": 1, + "value": 1023, + "freq": 3, + "battery": 99, + "checksum": True, + }, + decoded, + ) + + def test_decode_2(self) -> None: + decoded = generic2.decode( + "010110101010101001011010101010101010101010010101101001101010100102" + ) + self.assertDictEqual( + { + "id": 123, + "type": 1, + "value": 1023, + "freq": 3, + "battery": 99, + "checksum": False, + }, + decoded, + ) diff --git a/tests/protocols/test_pir1.py b/tests/protocols/test_pir1.py new file mode 100644 index 0000000..ed5a2f7 --- /dev/null +++ b/tests/protocols/test_pir1.py @@ -0,0 +1,26 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import pir1 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestPir1(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = pir1.decode("01100101011001100110011001100110011001010110011002") + self.assertDictEqual({"id": 1, "unit": 8, "state": True}, decoded) + + def test_decode_2(self) -> None: + decoded = pir1.decode("01100110011001100110010101100110011001010110011002") + self.assertDictEqual({"id": 17, "unit": 0, "state": True}, decoded) + + def test_decode_3(self) -> None: + decoded = pir1.decode("01100110011001010110011001100110010101100110011002") + self.assertDictEqual({"id": 2, "unit": 2, "state": True}, decoded) diff --git a/tests/protocols/test_pir2.py b/tests/protocols/test_pir2.py new file mode 100644 index 0000000..dc45149 --- /dev/null +++ b/tests/protocols/test_pir2.py @@ -0,0 +1,18 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import pir2 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestPir2(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = pir2.decode("01100110010110011001010110100101010101011010010102") + self.assertDictEqual({"id": 21, "unit": 21, "state": True}, decoded) diff --git a/tests/protocols/test_pir4.py b/tests/protocols/test_pir4.py new file mode 100644 index 0000000..aedfba7 --- /dev/null +++ b/tests/protocols/test_pir4.py @@ -0,0 +1,18 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import pir4 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestPir4(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = pir4.decode("110100110101001101010011001010101012") + self.assertDictEqual({"id": 54099, "unit": 21290, "state": True}, decoded) diff --git a/tests/protocols/test_pir6.py b/tests/protocols/test_pir6.py new file mode 100644 index 0000000..61a1ea5 --- /dev/null +++ b/tests/protocols/test_pir6.py @@ -0,0 +1,26 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import pir6 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestPir6(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = pir6.decode("01011010010101011010100110010101101001010101101002") + self.assertDictEqual({"id": 6410630, "state": True}, decoded) + + def test_decode_2(self) -> None: + decoded = pir6.decode("01011010010101011010100110010101101001010110010102") + self.assertDictEqual({"id": 6410632, "state": True}, decoded) + + def test_decode_3(self) -> None: + decoded = pir6.decode("01011010010101011010100110010101101001011001010102") + self.assertDictEqual({"id": 6410640, "state": True}, decoded) diff --git a/tests/protocols/test_switch25.py b/tests/protocols/test_switch25.py new file mode 100644 index 0000000..fd6a577 --- /dev/null +++ b/tests/protocols/test_switch25.py @@ -0,0 +1,144 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import switch25 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestSwitch25(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101011010100110011002" + ) + self.assertDictEqual({"id": 0, "unit": 14, "state": True}, decoded) + + def test_decode_2(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101011010100101101002" + ) + self.assertDictEqual({"id": 0, "unit": 14, "state": False}, decoded) + + def test_decode_3(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101011001101010011002" + ) + self.assertDictEqual({"id": 0, "unit": 11, "state": True}, decoded) + + def test_decode_4(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101011001101001101002" + ) + self.assertDictEqual({"id": 0, "unit": 11, "state": False}, decoded) + + def test_decode_5(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101010110101010011002" + ) + self.assertDictEqual({"id": 0, "unit": 7, "state": True}, decoded) + + def test_decode_6(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101010110101001101002" + ) + self.assertDictEqual({"id": 0, "unit": 7, "state": False}, decoded) + + def test_decode_7(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101011010011010011002" + ) + self.assertDictEqual({"id": 0, "unit": 13, "state": True}, decoded) + + def test_decode_8(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101011010011001101002" + ) + self.assertDictEqual({"id": 0, "unit": 13, "state": False}, decoded) + + def test_decode_9(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101010101010110011002" + ) + self.assertDictEqual({"id": 0, "unit": 0, "state": True}, decoded) + + def test_decode_10(self) -> None: + decoded = switch25.decode( + "101010101010101010101010101010100101010101010101010101010101101002" + ) + self.assertDictEqual({"id": 0, "unit": 0, "state": False}, decoded) + + def test_encode_1(self) -> None: + encoded = switch25.encode(id=0, unit=14, state=True) + self.assertEqual( + "101010101010101010101010101010100101010101010101011010100110011002", + encoded, + ) + + def test_encode_2(self) -> None: + encoded = switch25.encode(id=0, unit=14, state=False) + self.assertEqual( + "101010101010101010101010101010100101010101010101011010100101101002", + encoded, + ) + + def test_encode_3(self) -> None: + encoded = switch25.encode(id=0, unit=11, state=True) + self.assertEqual( + "101010101010101010101010101010100101010101010101011001101010011002", + encoded, + ) + + def test_encode_4(self) -> None: + encoded = switch25.encode(id=0, unit=11, state=False) + self.assertEqual( + "101010101010101010101010101010100101010101010101011001101001101002", + encoded, + ) + + def test_encode_5(self) -> None: + encoded = switch25.encode(id=0, unit=7, state=True) + self.assertEqual( + "101010101010101010101010101010100101010101010101010110101010011002", + encoded, + ) + + def test_encode_6(self) -> None: + encoded = switch25.encode(id=0, unit=7, state=False) + self.assertEqual( + "101010101010101010101010101010100101010101010101010110101001101002", + encoded, + ) + + def test_encode_7(self) -> None: + encoded = switch25.encode(id=0, unit=13, state=True) + self.assertEqual( + "101010101010101010101010101010100101010101010101011010011010011002", + encoded, + ) + + def test_encode_8(self) -> None: + encoded = switch25.encode(id=0, unit=13, state=False) + self.assertEqual( + "101010101010101010101010101010100101010101010101011010011001101002", + encoded, + ) + + def test_encode_9(self) -> None: + encoded = switch25.encode(id=0, unit=0, state=True) + self.assertEqual( + "101010101010101010101010101010100101010101010101010101010110011002", + encoded, + ) + + def test_encode_10(self) -> None: + encoded = switch25.encode(id=0, unit=0, state=False) + self.assertEqual( + "101010101010101010101010101010100101010101010101010101010101101002", + encoded, + ) diff --git a/tests/protocols/test_switch5.py b/tests/protocols/test_switch5.py new file mode 100644 index 0000000..b920595 --- /dev/null +++ b/tests/protocols/test_switch5.py @@ -0,0 +1,144 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import switch5 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestSwitch5(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101011010101002") + self.assertDictEqual( + {"id": 465695, "unit": 1, "all": False, "state": True}, decoded + ) + + def test_decode_2(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101011010100102") + self.assertDictEqual( + {"id": 465695, "unit": 1, "all": False, "state": False}, decoded + ) + + def test_decode_3(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101011010011002") + self.assertDictEqual( + {"id": 465695, "unit": 2, "all": False, "state": True}, decoded + ) + + def test_decode_4(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101011010010102") + self.assertDictEqual( + {"id": 465695, "unit": 2, "all": False, "state": False}, decoded + ) + + def test_decode_5(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101011001101002") + self.assertDictEqual( + {"id": 465695, "unit": 3, "all": False, "state": True}, decoded + ) + + def test_decode_6(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101011001100102") + self.assertDictEqual( + {"id": 465695, "unit": 3, "all": False, "state": False}, decoded + ) + + def test_decode_7(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101010110101002") + self.assertDictEqual( + {"id": 465695, "unit": 4, "all": False, "state": True}, decoded + ) + + def test_decode_8(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101010110100102") + self.assertDictEqual( + {"id": 465695, "unit": 4, "all": False, "state": False}, decoded + ) + + def test_decode_9(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101010101011002") + self.assertDictEqual( + {"id": 465695, "unit": 0, "all": True, "state": False}, decoded + ) + + def test_decode_10(self) -> None: + decoded = switch5.decode("10010101101010010110010110101001010101010101100102") + self.assertDictEqual( + {"id": 465695, "unit": 0, "all": True, "state": True}, decoded + ) + + def test_encode_1(self) -> None: + encoded = switch5.encode(id=465695, unit=1, all=False, state=True) + self.assertEqual( + "10010101101010010110010110101001010101011010101002", + encoded, + ) + + def test_encode_2(self) -> None: + encoded = switch5.encode(id=465695, unit=1, all=False, state=False) + self.assertEqual( + "10010101101010010110010110101001010101011010100102", + encoded, + ) + + def test_encode_3(self) -> None: + encoded = switch5.encode(id=465695, unit=2, all=False, state=True) + self.assertEqual( + "10010101101010010110010110101001010101011010011002", + encoded, + ) + + def test_encode_4(self) -> None: + encoded = switch5.encode(id=465695, unit=2, all=False, state=False) + self.assertEqual( + "10010101101010010110010110101001010101011010010102", + encoded, + ) + + def test_encode_5(self) -> None: + encoded = switch5.encode(id=465695, unit=3, all=False, state=True) + self.assertEqual( + "10010101101010010110010110101001010101011001101002", + encoded, + ) + + def test_encode_6(self) -> None: + encoded = switch5.encode(id=465695, unit=3, all=False, state=False) + self.assertEqual( + "10010101101010010110010110101001010101011001100102", + encoded, + ) + + def test_encode_7(self) -> None: + encoded = switch5.encode(id=465695, unit=4, all=False, state=True) + self.assertEqual( + "10010101101010010110010110101001010101010110101002", + encoded, + ) + + def test_encode_8(self) -> None: + encoded = switch5.encode(id=465695, unit=4, all=False, state=False) + self.assertEqual( + "10010101101010010110010110101001010101010110100102", + encoded, + ) + + def test_encode_9(self) -> None: + encoded = switch5.encode(id=465695, unit=0, all=True, state=False) + self.assertEqual( + "10010101101010010110010110101001010101010101011002", + encoded, + ) + + def test_encode_10(self) -> None: + encoded = switch5.encode(id=465695, unit=0, all=True, state=True) + self.assertEqual( + "10010101101010010110010110101001010101010101100102", + encoded, + ) diff --git a/tests/protocols/test_switch6.py b/tests/protocols/test_switch6.py new file mode 100644 index 0000000..d658e99 --- /dev/null +++ b/tests/protocols/test_switch6.py @@ -0,0 +1,36 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import switch6 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestSwitch6(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = switch6.decode("10101010101010101010010101100110011001100110010102") + self.assertDictEqual({"id": 31, "unit": 1, "state": True}, decoded) + + def test_decode_2(self) -> None: + decoded = switch6.decode("10101010101010100110011001010110011001100110010102") + self.assertDictEqual({"id": 15, "unit": 2, "state": True}, decoded) + + def test_encode_1(self) -> None: + encoded = switch6.encode(id=31, unit=1, state=True) + self.assertEqual( + "10101010101010101010010101100110011001100110010102", + encoded, + ) + + def test_encode_2(self) -> None: + encoded = switch6.encode(id=15, unit=2, state=True) + self.assertEqual( + "10101010101010100110011001010110011001100110010102", + encoded, + ) diff --git a/tests/protocols/test_switch7.py b/tests/protocols/test_switch7.py new file mode 100644 index 0000000..8d9609d --- /dev/null +++ b/tests/protocols/test_switch7.py @@ -0,0 +1,47 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import switch7 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestSwitch7(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = switch7.decode("01010101010101100110011001100110011001100110011002") + self.assertDictEqual({"id": 0, "unit": 3, "state": True}, decoded) + + def test_decode_2(self) -> None: + decoded = switch7.decode("01010101010101100101010101010110011001100110011002") + self.assertDictEqual({"id": 7, "unit": 3, "state": True}, decoded) + + def test_decode_3(self) -> None: + decoded = switch7.decode("10100101011001100101010101010110011001100110011002") + self.assertDictEqual({"id": 7, "unit": 1, "state": False}, decoded) + + def test_encode_1(self) -> None: + encoded = switch7.encode(id=0, unit=3, state=True) + self.assertEqual( + "01010101010101100110011001100110011001100110011002", + encoded, + ) + + def test_encode_2(self) -> None: + encoded = switch7.encode(id=7, unit=3, state=True) + self.assertEqual( + "01010101010101100101010101010110011001100110011002", + encoded, + ) + + def test_encode_3(self) -> None: + encoded = switch7.encode(id=7, unit=1, state=False) + self.assertEqual( + "10100101011001100101010101010110011001100110011002", + encoded, + ) diff --git a/tests/protocols/test_weather19.py b/tests/protocols/test_weather19.py new file mode 100644 index 0000000..637310f --- /dev/null +++ b/tests/protocols/test_weather19.py @@ -0,0 +1,38 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import weather19 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestWeather19(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = weather19.decode( + "020202010101010101010101010101020101010102010201020101010201020203" + ) + self.assertDictEqual({"id": 56, "unit": 1, "temperature": 26.6}, decoded) + + def test_decode_2(self) -> None: + decoded = weather19.decode( + "020102020102010101010101010101020101020101020201010102020201020203" + ) + self.assertDictEqual({"id": 45, "unit": 1, "temperature": 29.4}, decoded) + + def test_decode_3(self) -> None: + decoded = weather19.decode( + "020102020102010101010101010101020101020201010101020102010102010203" + ) + self.assertDictEqual({"id": 45, "unit": 1, "temperature": 30.4}, decoded) + + def test_decode_4(self) -> None: + decoded = weather19.decode( + "020102020102010101010101010101020202010102020101020102010101010203" + ) + self.assertDictEqual({"id": 45, "unit": 1, "temperature": 46.0}, decoded) diff --git a/tests/protocols/test_weather4.py b/tests/protocols/test_weather4.py new file mode 100644 index 0000000..365ea97 --- /dev/null +++ b/tests/protocols/test_weather4.py @@ -0,0 +1,59 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import weather4 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestWeather4(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = weather4.decode( + "11111111040303030203030302020302030203020302030302020202030302020202030303020202030202020305" + ) + self.assertDictEqual( + { + "id": 238, + "unit": 1, + "temperature": 18.9, + "humidity": 71, + "lowBattery": False, + }, + decoded, + ) + + def test_decode_2(self) -> None: + decoded = weather4.decode( + "11111111040203020303030302030302020203020302030302030202030202030202030303020202020202030305" + ) + self.assertDictEqual( + { + "id": 94, + "unit": 3, + "temperature": 25.7, + "humidity": 70, + "lowBattery": False, + }, + decoded, + ) + + def test_decode_3(self) -> None: + decoded = weather4.decode( + "11111111040302030203030303020302030202030202030303020202020202030302030203020302020202020305" + ) + self.assertDictEqual( + { + "id": 175, + "unit": 1, + "temperature": 31.9, + "humidity": 54, + "lowBattery": False, + }, + decoded, + ) diff --git a/tests/protocols/test_weather7.py b/tests/protocols/test_weather7.py new file mode 100644 index 0000000..a3667ba --- /dev/null +++ b/tests/protocols/test_weather7.py @@ -0,0 +1,29 @@ +# pylint: disable=line-too-long +# pylint: disable=missing-module-docstring +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import logging +import unittest + +from rfcontrol.protocols import weather7 + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class TestWeather7(unittest.TestCase): + def test_decode_1(self) -> None: + decoded = weather7.decode( + "010202010201010202010101010101010101010202020102020202010202010103" + ) + self.assertDictEqual( + { + "id": 105, + "unit": 0, + "temperature": 2.9, + "humidity": 59, + "lowBattery": False, + }, + decoded, + )