Afternoon,
Probably a simple question - but - i have a UDP listener, listening for evt_precip. It picks up my tempest device and my sky. The Tempest gives a lot of false rain readings (I’m working on it) - so the question is, can i filter the UDP to only look for evt_precip from my Sky unit?
The scripts rings a physical bell twice when it rains
import socket
import json
import time
import paho.mqtt.publish as publish
#Set Output Message - Number relates to the angle to move the servo to hit the bell
#Set up and listen to UDP Broadcasts
while True:
UDP_IP = “”
UDP_PORT = 50222
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('0.0.0.0', UDP_PORT))
data, addr = s.recvfrom(1024)
parsed_data = json.loads(data.decode("utf-8"))
if parsed_data["type"] == "evt_precip":
rainevent = (parsed_data)
output = int(47)
time.sleep(1)
print("Publishing message to topic")
publish.single("ringbell/ring", output, hostname="192.168.1.76")
time.sleep(2)
print (output)
publish.single("ringbell/ring", output, hostname="mymqtt")
time.sleep(1)
print (output)
publish.single("led/home", "It has started to Rain", hostname="mymqtt")
print ("It has started to Rain")