To avoid collision with scripts that I'm using to control and get the status of the air conditioner (so I can capture any changes made by the wall mounted Daikin control panel), I am attempting to use the Daikin UDP broadcast to trigger a status update. My first thought was to use the Cynical Network plugin, but discovered that this doesn't support UDP (clearly stated in the plugin documentation, thank you!).
After a bit of hunting on the internet, I have attempted the following script:
- Code: Select all
import socket
UDP_IP = "XXX.XXX.XXX.XXX" #tried both the sending IP and the 255.255.255.255 destination address
UDP_PORT = 55222
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
indigo.server.log(data,"Received Message") ## interim code for testing purposes!
but get the following error:
- Code: Select all
Script Error embedded script: [Errno 49] Can't assign requested address
Script Error Exception Traceback (most recent call shown last):
embedded script, line 8, at top level
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
error: [Errno 49] Can't assign requested address
Any suggestions as to how I can achieve this by improving the script or by other means of Indigo detecting the UDP broadcast (not really interested in the package contents, only the presence of the broadcast!)
Thanks in anticipation!
mclass