-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7493aad
commit 95f4795
Showing
12 changed files
with
631 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) |
Oops, something went wrong.