2020-12-16 02:32:32 +01:00
|
|
|
#!/usr/bin/env python
|
2020-02-11 20:05:33 +01:00
|
|
|
|
|
|
|
import rcprotocols
|
|
|
|
import time
|
|
|
|
import paho.mqtt.client as mqtt
|
|
|
|
|
|
|
|
mqttClient = mqtt.Client()
|
|
|
|
mqttClient.connect("localhost", 1883, 60)
|
|
|
|
mqttClient.loop_start()
|
|
|
|
|
2020-12-16 02:32:32 +01:00
|
|
|
def publish(proto, params):
|
|
|
|
print("Publish: " + str(proto) + " / " + params)
|
|
|
|
mqttClient.publish("home/rcbuttons/" + proto, params)
|
2020-02-11 20:05:33 +01:00
|
|
|
|
2020-12-16 02:32:32 +01:00
|
|
|
def rxcb(dec, train):
|
|
|
|
if dec is None:
|
|
|
|
print("raw", train)
|
|
|
|
return
|
|
|
|
for d in dec:
|
|
|
|
publish(d["protocol"], str(d["params"]))
|
|
|
|
|
|
|
|
rctrx = rcprotocols.RcTransceiver(1, 433.92, rxcb)
|
2020-02-11 20:05:33 +01:00
|
|
|
|
|
|
|
while True:
|
2020-12-16 02:32:32 +01:00
|
|
|
time.sleep(1)
|