From 9cfecb5bedb8735e0134b73ee33297b7d9b91fd5 Mon Sep 17 00:00:00 2001 From: "S. Seegel" Date: Sat, 21 Nov 2020 01:03:14 +0100 Subject: [PATCH] clean up fix switch15 --- apps/it32.py | 48 -------------------------------------------- apps/lacrossegw.conf | 4 ++-- apps/rcprotocols.py | 7 +++---- apps/rcpulse.py | 1 - apps/rfmnodered.py | 8 +++++++- 5 files changed, 12 insertions(+), 56 deletions(-) delete mode 100644 apps/it32.py diff --git a/apps/it32.py b/apps/it32.py deleted file mode 100644 index abe5d64..0000000 --- a/apps/it32.py +++ /dev/null @@ -1,48 +0,0 @@ -import re - -def Decode(pulses): - if len(pulses) != 130: - return - - sym = "" - s = 0 - for p in pulses: - if (p >= 150) and (p <= 500): - s += p - sym += 's' - elif (p >= 1000) and (p <= 1500): - s += p - sym += 'l' - else: - sym += '?' - - it = "" - temp = sym - for i in range(32): - if temp[:4] == 'sssl': - it += "0" - elif temp[:4] == "slss": - it += "1" - else: - return - temp = temp[4:] - return("it32", it, int(round(s / (32.0 * 8 + 1)))) - -def Encode(args): - code = ' '.join(args) - if re.match("^[01]{32}$", code): - data = [0x08, 0x00] #sync - for c in args[0]: - if c == '0': - data.append(0xA0) - elif c == '1': - data.append(0x82) - data += [0x80, 0x00, 0x00, 0x00, 0x00] - return (data, 6, 275) - - elif re.match("^[01]{26} ([0][1-9]|[1-9]|[1][0-6]) (on|off)$", code): - g = re.match("^([01]{26}) ([0][1-9]|[1-9]|[1][0-6]) (on|off)$", code).groups() - bits = g[0] + '0' - bits += '1' if g[2] == 'on' else '0' - bits += "{0:04b}".format(int(g[1]) - 1) - return Encode([bits]) \ No newline at end of file diff --git a/apps/lacrossegw.conf b/apps/lacrossegw.conf index 68afd88..29b90f6 100644 --- a/apps/lacrossegw.conf +++ b/apps/lacrossegw.conf @@ -19,7 +19,7 @@ "idOutside": "64" }, { - "id": "0", + "id": "24", "name": "Badezimmer", "tMin": 20, "tMax": 25, @@ -89,4 +89,4 @@ "pass": "admin", "database": "sensors" } -} \ No newline at end of file +} diff --git a/apps/rcprotocols.py b/apps/rcprotocols.py index 2e063b8..66013da 100644 --- a/apps/rcprotocols.py +++ b/apps/rcprotocols.py @@ -51,7 +51,6 @@ class RcProtocol: self._add_pulses([8 - self.__numbits]) def _add_symbols(self, symbols): - print(symbols) for s in symbols: sym = self._symbols[s] for pulse in sym: @@ -213,7 +212,7 @@ class Switch15(RcProtocol): #e. g. logilight def __init__(self): self._name = "switch15" self._timebase = 300 - self._repetitions = 4 + self._repetitions = 6 self._pattern = "[01]{24}" self._symbols = { '1': [3, 1], @@ -252,6 +251,7 @@ class Switch15(RcProtocol): #e. g. logilight } def encode(self, args): + self._reset() sym = '{:020b}'.format(args.id) if args.unit == 1: @@ -271,7 +271,7 @@ class Switch15(RcProtocol): #e. g. logilight self._add_finish() return self._ookdata -class Emylo(Switch15): #e. g. logilight +class Emylo(Switch15): def __init__(self): Switch15.__init__(self) self._name = "emylo" @@ -435,7 +435,6 @@ protocols = [ def encode(protocol, args): for p in protocols: if (protocol): - print("found ptoto") if p._name == protocol: return (p.encode(p._parser.parse_args(args)), p._timebase, p._repetitions) diff --git a/apps/rcpulse.py b/apps/rcpulse.py index b433658..bd5427b 100755 --- a/apps/rcpulse.py +++ b/apps/rcpulse.py @@ -3,7 +3,6 @@ from raspyrfm import * import sys import time -#import it32 #import tristate #import bistate24 #import fs20 diff --git a/apps/rfmnodered.py b/apps/rfmnodered.py index 0a3a231..5bc84b5 100755 --- a/apps/rfmnodered.py +++ b/apps/rfmnodered.py @@ -5,8 +5,15 @@ import threading from raspyrfm import * import rcprotocols import json +from argparse import ArgumentParser + +parser = ArgumentParser() +parser.add_argument("-m", "--module", type=int, metavar="1-4", help=u"RaspyRFM module 1-4", default=1) +parser.add_argument("-o", "--mode", help=u"Mode (rcpulse, lacrosse)", default="rcpulse") +args = parser.parse_known_args() srvsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +srvsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) srvsock.bind(('', 1989)) srvsock.listen(5) @@ -41,7 +48,6 @@ class clientthread(threading.Thread): try: lock.acquire() txdata = rcprotocols.encode_dict(json.loads(chunk)) - print(txdata) rfm.set_params( SyncPattern = [], Datarate = 1000.0 / txdata[1]