01ddd7e3cc
Add weather sensors wh2, wh7000 some python3 issues fix docu & PC PIR
53 lines
1.4 KiB
Python
Executable file
53 lines
1.4 KiB
Python
Executable file
#!/usr/bin/env python
|
|
|
|
from raspyrfm import *
|
|
import sys
|
|
import time
|
|
from argparse import ArgumentParser
|
|
import wave, struct
|
|
import threading
|
|
import rcprotocols
|
|
|
|
parser = ArgumentParser()
|
|
parser.add_argument("-t", "--timebase", type=int, help=u"timebase in \u03bcs")
|
|
parser.add_argument("-r", "--repeats", type=int, help=u"number of repetitions")
|
|
parser.add_argument("-m", "--module", type=int, metavar="1-4", help=u"RaspyRFM module 1-4", default=1)
|
|
parser.add_argument("-f", "--frequency", type=float, help=u"frequency in MHz", default=433.92)
|
|
parser.add_argument("-p", "--protocol", help=u"Protocol for sending")
|
|
args, remainargs = parser.parse_known_args()
|
|
|
|
def rxcb(dec, train):
|
|
if dec is None:
|
|
print("raw", train)
|
|
return
|
|
for d in dec:
|
|
print(d)
|
|
|
|
if not raspyrfm_test(args.module, RFM69):
|
|
print("Error! RaspyRFM not found")
|
|
exit()
|
|
|
|
rctrx = rcprotocols.RcTransceiver(args.module, args.frequency, rxcb)
|
|
|
|
if args.protocol:
|
|
proto = rcprotocols.get_protocol(args.protocol)
|
|
if proto:
|
|
parser2 = ArgumentParser()
|
|
for param in proto.params:
|
|
parser2.add_argument("-" + param[0], "--" + param[1], required=True)
|
|
params = parser2.parse_args(remainargs)
|
|
rctrx.send(args.protocol, params.__dict__, args.timebase, args.repeats)
|
|
else:
|
|
print("Unknown protocol.")
|
|
del rctrx
|
|
exit()
|
|
|
|
state = "on"
|
|
while True:
|
|
time.sleep(15)
|
|
|
|
#rctrx.send("ittristate", {"house": "A", "group": 1, "unit": 1, "command": state})
|
|
if (state == "on"):
|
|
state = "off"
|
|
else:
|
|
state = "on"
|