From 461cae49a6e86a7dc78be35eb9577c1a2a19414f Mon Sep 17 00:00:00 2001 From: cheetah Date: Wed, 15 Jan 2020 06:37:40 +0100 Subject: [PATCH] added Nexus Temperature Sensor --- .gitignore | 1 + .vscode/settings.json | 4 ++++ main.py | 4 ++++ protocols/Nexus.py | 19 +++++++++++++++++++ protocols/__init__.py | 0 5 files changed, 28 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 main.py create mode 100644 protocols/Nexus.py create mode 100644 protocols/__init__.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e99e36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cc67606 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.linting.pylintEnabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..48bcac2 --- /dev/null +++ b/main.py @@ -0,0 +1,4 @@ +import protocols.Nexus + +nexus = protocols.Nexus.Nexus_TempHumidity() +print(nexus.generate(244, 1, 55, 100)) diff --git a/protocols/Nexus.py b/protocols/Nexus.py new file mode 100644 index 0000000..85ee19e --- /dev/null +++ b/protocols/Nexus.py @@ -0,0 +1,19 @@ + +class Nexus_TempHumidity: + def __init__(self): + self.test() + def test(self): + print("Nexus Temperature & Humidity Sensor") + def generate(self, id=244, channel=1, temp=30, humidity=100): + packet = [ + (id >> 4) & 0x0f, + id & 0x0f, + 7 + channel, + (temp >> 8) & 0x0f, + (temp >> 4) & 0x0f, + temp & 0x0f, + 0x0f, + (humidity >> 4) & 0x0f, + humidity & 0x0f + ] + return packet diff --git a/protocols/__init__.py b/protocols/__init__.py new file mode 100644 index 0000000..e69de29