|
|
@@ -13,6 +13,7 @@ def on_connect(client, userdata, flags, reason_code, properties):
|
|
|
client.subscribe('request/+',0)
|
|
|
client.subscribe('Irrigatore/#',0)
|
|
|
client.subscribe('Pompa/#',0)
|
|
|
+ client.subscribe('Valvola/#',0)
|
|
|
#client.subscribe('$SYS/#',0)
|
|
|
client.publish('message',"{'message':'avvio'}")
|
|
|
|
|
|
@@ -38,11 +39,27 @@ def on_message(client,userdata,msg):
|
|
|
print('payload',msg.payload)
|
|
|
|
|
|
if ok:
|
|
|
- print(data['irrigatore'],data['status'],type(data['irrigatore']))
|
|
|
- if data['status'] == 1:
|
|
|
- GPIO.output(data['irrigatore'],GPIO.HIGH)
|
|
|
- else:
|
|
|
- GPIO.output(data['irrigatore'],GPIO.LOW)
|
|
|
+ if 'irrigatore' in data:
|
|
|
+ print(data['irrigatore'],data['status'],type(data['irrigatore']))
|
|
|
+ if data['status'] == 1:
|
|
|
+ GPIO.output(data['irrigatore'],GPIO.HIGH)
|
|
|
+ else:
|
|
|
+ GPIO.output(data['irrigatore'],GPIO.LOW)
|
|
|
+
|
|
|
+ if 'pompa' in data:
|
|
|
+ print(data['pompa'],data['status'],type(data['pompa']))
|
|
|
+ if data['status'] == 1:
|
|
|
+ GPIO.output(data['pompa'],GPIO.HIGH)
|
|
|
+ else:
|
|
|
+ GPIO.output(data['pompa'],GPIO.LOW)
|
|
|
+
|
|
|
+ if 'valvola' in data:
|
|
|
+ print(data['valvola'],data['status'],type(data['valvola']))
|
|
|
+ if data['status'] == 1:
|
|
|
+ GPIO.output(data['valvola'],GPIO.HIGH)
|
|
|
+ else:
|
|
|
+ GPIO.output(data['valvola'],GPIO.LOW)
|
|
|
+
|
|
|
|
|
|
GPIO.setmode(GPIO.BCM)
|
|
|
|