fix switch15
This commit is contained in:
S. Seegel 2020-11-21 01:03:14 +01:00
parent bbb679af60
commit 9cfecb5bed
5 changed files with 12 additions and 56 deletions

View file

@ -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])

View file

@ -19,7 +19,7 @@
"idOutside": "64" "idOutside": "64"
}, },
{ {
"id": "0", "id": "24",
"name": "Badezimmer", "name": "Badezimmer",
"tMin": 20, "tMin": 20,
"tMax": 25, "tMax": 25,

View file

@ -51,7 +51,6 @@ class RcProtocol:
self._add_pulses([8 - self.__numbits]) self._add_pulses([8 - self.__numbits])
def _add_symbols(self, symbols): def _add_symbols(self, symbols):
print(symbols)
for s in symbols: for s in symbols:
sym = self._symbols[s] sym = self._symbols[s]
for pulse in sym: for pulse in sym:
@ -213,7 +212,7 @@ class Switch15(RcProtocol): #e. g. logilight
def __init__(self): def __init__(self):
self._name = "switch15" self._name = "switch15"
self._timebase = 300 self._timebase = 300
self._repetitions = 4 self._repetitions = 6
self._pattern = "[01]{24}" self._pattern = "[01]{24}"
self._symbols = { self._symbols = {
'1': [3, 1], '1': [3, 1],
@ -252,6 +251,7 @@ class Switch15(RcProtocol): #e. g. logilight
} }
def encode(self, args): def encode(self, args):
self._reset()
sym = '{:020b}'.format(args.id) sym = '{:020b}'.format(args.id)
if args.unit == 1: if args.unit == 1:
@ -271,7 +271,7 @@ class Switch15(RcProtocol): #e. g. logilight
self._add_finish() self._add_finish()
return self._ookdata return self._ookdata
class Emylo(Switch15): #e. g. logilight class Emylo(Switch15):
def __init__(self): def __init__(self):
Switch15.__init__(self) Switch15.__init__(self)
self._name = "emylo" self._name = "emylo"
@ -435,7 +435,6 @@ protocols = [
def encode(protocol, args): def encode(protocol, args):
for p in protocols: for p in protocols:
if (protocol): if (protocol):
print("found ptoto")
if p._name == protocol: if p._name == protocol:
return (p.encode(p._parser.parse_args(args)), p._timebase, p._repetitions) return (p.encode(p._parser.parse_args(args)), p._timebase, p._repetitions)

View file

@ -3,7 +3,6 @@
from raspyrfm import * from raspyrfm import *
import sys import sys
import time import time
#import it32
#import tristate #import tristate
#import bistate24 #import bistate24
#import fs20 #import fs20

View file

@ -5,8 +5,15 @@ import threading
from raspyrfm import * from raspyrfm import *
import rcprotocols import rcprotocols
import json 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 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srvsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srvsock.bind(('', 1989)) srvsock.bind(('', 1989))
srvsock.listen(5) srvsock.listen(5)
@ -41,7 +48,6 @@ class clientthread(threading.Thread):
try: try:
lock.acquire() lock.acquire()
txdata = rcprotocols.encode_dict(json.loads(chunk)) txdata = rcprotocols.encode_dict(json.loads(chunk))
print(txdata)
rfm.set_params( rfm.set_params(
SyncPattern = [], SyncPattern = [],
Datarate = 1000.0 / txdata[1] Datarate = 1000.0 / txdata[1]