UDP Listener Plugin

Posted on
Mon Apr 30, 2018 7:05 pm
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

UDP Listener Plugin


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue May 01, 2018 2:31 am
MartinG offline
Posts: 116
Joined: Aug 19, 2016

Re: UDP Listener Plugin

Thanks - downloaded and installed. Will post back here as soon as I have some events to share and analyse.

Posted on
Tue May 01, 2018 6:26 am
agame offline
Posts: 514
Joined: Jul 13, 2017
Location: Melbourne, Australia

Re: UDP Listener Plugin

likewise. having no luck receiving events but will wait to see if its (presumably) just a problem at my end.

Posted on
Tue May 01, 2018 6:43 am
agame offline
Posts: 514
Joined: Jul 13, 2017
Location: Melbourne, Australia

Re: UDP Listener Plugin

saw you comment on the original thread regarding multicast requiring different config not yet implemented.
I've double checked, and the Global Cache device does use multicast for the sensor notify messages (not just the discovery message). So explains my lack of success. Will sit tight for now!
cheers.

Posted on
Tue May 01, 2018 7:15 am
Different Computers offline
User avatar
Posts: 2541
Joined: Jan 02, 2016
Location: East Coast

Re: UDP Listener Plugin

For those of us who may not realize how much we need this, could you describe a use case?

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue May 01, 2018 7:16 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: UDP Listener Plugin

Different Computers wrote:
For those of us who may not realize how much we need this, could you describe a use case?


Not me. I'm doing this one on request. I don't have a use case.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue May 01, 2018 7:36 am
MartinG offline
Posts: 116
Joined: Aug 19, 2016

Re: UDP Listener Plugin

FlyingDiver wrote:
Different Computers wrote:
For those of us who may not realize how much we need this, could you describe a use case?


Not me. I'm doing this one on request. I don't have a use case.


Here's mine

My (mostly) hardwired Rako lighting system broadcasts scene changes over UDP.

There are some lights in my house which are controlled via Z-Wave, mostly because we didn't anticipate every lighting need when rewiring.

By spotting scene changes initiated by Rako, I can then integrate the Z-Wave controlled lights into the scenes. eg "movie mode in the lounge", "night time TV mode in the kitchen/family area", "all on" or "all off"

I already have a python script running outside Indigo that monitors the Rako system for exactly this reason.

Posted on
Tue May 01, 2018 7:55 am
agame offline
Posts: 514
Joined: Jul 13, 2017
Location: Melbourne, Australia

Re: UDP Listener Plugin

here's mine:

Global Cache Flex with Sensor/Relay accessory cable provides a WIFI gateway with 4 relays and four sensor inputs (dry contact or voltage). Sensor state is broadcast via UDP on state change (and optionally at a user-defined interval). Its a great device but there's a challenge integrating with Indigo without using UDP.

I have a farm front gate that's too remote for z-wave device range; but within range of a long range wifi access point. it also has low voltage power. So a usb-voltage wifi interface is perfect. I want to detect gate open state changing, detect a 'doorbell' press, detect an IR beam sensor being activated. I also control a couple of cameras and a light located at the gate.

Whilst polling the device via TCP is feasible for extended events (eg gate is open), as well as activating the relays to open the gate etc; this approach doesn't work for momentary events (button press; IR beam break). UDP is the only way to capture these transient events (and probably more efficient for the remainder).

(to anticipate the question. - , the 'Cynical Cache' plugin isn't compatible with the Sensor/Relay accessory cable - however the Cynical Networks plugin works really well for polling the device, albeit with a bit of config - no support for listening on UDP however.)
Last edited by agame on Tue May 01, 2018 3:44 pm, edited 1 time in total.

Posted on
Tue May 01, 2018 8:07 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: UDP Listener Plugin

Version 0.0.3 with working multicast listening: https://github.com/FlyingDiver/Indigo-U ... r/releases

Logging of received data is still suspect. Simple ascii and unicode strings work fine. Binary data could be an issue.

I tested multicast using a simple Python script to send multicast messages:

Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import socket
import struct

message = u"Unicode Message é î ø ó á å"
multicast_group = ('224.3.29.71', 10000)

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ttl = struct.pack('b', 1)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
sock.sendto(message.encode('utf-8'), multicast_group)
sock.close()
 

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue May 01, 2018 8:32 am
agame offline
Posts: 514
Joined: Jul 13, 2017
Location: Melbourne, Australia

Re: UDP Listener Plugin

oh wow...IT WORKS!

late here in AU so will need to fiddle with events more tomorrow but definitely receiving and processing as you would hope.
I'm only anticipating text, so don't expect binary will be an issue for me.

thanks indeed!!!

Posted on
Tue May 01, 2018 9:12 am
Different Computers offline
User avatar
Posts: 2541
Joined: Jan 02, 2016
Location: East Coast

Re: UDP Listener Plugin

FlyingDiver wrote:

Not me. I'm doing this one on request. I don't have a use case.


You sir, are a coding saint!

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue May 01, 2018 9:35 pm
mclass offline
Posts: 314
Joined: May 13, 2015
Location: Melbourne, Australia

Re: UDP Listener Plugin

Joe,

Thanks for persisting with this despite not even having a user case :o

My user case is that I have a Daikin ducted AC fitted with their "SkyFI" wifi controller (evidently only available in the Australian market). This broadcasts a message every 8 secs (approx). As this system is flakey (Daikin have withdrawn it from the market) I am interacting with the system directly. To account for the possibility that users may use the standard Daikin wall mounted controller to operate the system, I have a schedule that periodically (30 seconds at the moment) requests the status of the system. Every now and then, (I'm guessing) my (Indigo) requests collide with the Daikin UDP broadcast, resulting in one or more "address in use" errors in the event log from my request script. Status updates eventually occur, but all those error messages in the log look untidy!!

My "grand plan" is to use the Daikin's UDP broadcast to trigger my request, so that it is sent (and hopefully replied to) in the intervening periods between the Daikin broadcasts.

I have now had a chance to download and try the latest version, but it would appear that some non-ASCII characters in the Daikin payload is presenting problems to the plug in.

Here's the event log with the error appearing every 6-8 seconds - the period that the Daikin AC sends the message. Only the IP and port numbers have been changed to protect the innocent!!
Code: Select all
Starting plugin "UDP Listener 0.0.3" (pid 8397)
   UDP Listener Debug              logLevel = 5
   Started plugin "UDP Listener 0.0.3"
   UDP Listener                    Starting UDP Listener
   UDP Listener Debug              Daikin Listener: Device Current Version = 0
   UDP Listener Debug              Daikin Listener: Device Version is up to date
   UDP Listener Debug              Daikin Listener: Starting device (udpListener)
   UDP Listener Debug              Daikin Listener: UDP msg from: ('192.XXX.XX.XXX', YYYY), data: c0:25:06:bd:4b:3b:04:3d:07:d0:00:00:0a:5d:0b:f9:0d:11:54:69:6d:65:20:4e:4f:54:20:53:45:54:00:00:77:69:66:6c:79:2d:45:5a:58:20:56:65:72:20:34:2e:30:30:2e:31:2c:20:41:70:72:20:31:39:44:61:69:6b:69:6e:41:43:3a:31:30:36:32:34:30:35:39:34:00:00:00:00:00:00:00:00:00:00:00:00:00:00:f5:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
   Error                           XML Parse Error: not well-formed (invalid token)
   Error                           On character 580 of line number 1.
   UDP Listener Debug              Daikin Listener: UDP msg from: ('192.XXX.XX.XXX', YYYY), data: c0:25:06:bd:4b:3b:04:3d:07:d0:00:00:0a:5d:0b:f9:0d:11:54:69:6d:65:20:4e:4f:54:20:53:45:54:00:00:77:69:66:6c:79:2d:45:5a:58:20:56:65:72:20:34:2e:30:30:2e:31:2c:20:41:70:72:20:31:39:44:61:69:6b:69:6e:41:43:3a:31:30:36:32:34:30:35:39:34:00:00:00:00:00:00:00:00:00:00:00:00:00:00:f5:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
   Error                           XML Parse Error: not well-formed (invalid token)
   Error                           On character 580 of line number 1.


As far as I can tell each message is identical.

Thoughts?

mclass

Posted on
Tue May 01, 2018 11:55 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: UDP Listener Plugin

My use case is on behalf of other users and other plugin devs.

Half a dozen plugins use UDP listening to locate devices - Rogue’s TV Plugins, my abandoned Sky+ plugin, SecuritySpy I believe.

They can’t all listen at once as they all need to bind to the same port, so they have to bind then unbind when not actively searching.

I want a central plugin or core that can receive requests from other plugins to “listen for broadcasts containing ‘SkyHD’ and pass them to me” or “stop listening for broadcasts containing ‘SonyTV’ until I ask again”, etc etc.

This means only the one plugin needs to bind to the UDP port, and it only binds while it has one or more active requests; once the last active request sends a stop command, it unbinds until a new request comes in.

Peter


Sent from my iPhone using Tapatalk Pro

Posted on
Wed May 02, 2018 6:10 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: UDP Listener Plugin

mclass wrote:
Here's the event log with the error appearing every 6-8 seconds - the period that the Daikin AC sends the message. Only the IP and port numbers have been changed to protect the innocent!!
Code: Select all
Starting plugin "UDP Listener 0.0.3" (pid 8397)
   UDP Listener Debug              logLevel = 5
   Started plugin "UDP Listener 0.0.3"
   UDP Listener                    Starting UDP Listener
   UDP Listener Debug              Daikin Listener: Device Current Version = 0
   UDP Listener Debug              Daikin Listener: Device Version is up to date
   UDP Listener Debug              Daikin Listener: Starting device (udpListener)
   UDP Listener Debug              Daikin Listener: UDP msg from: ('192.XXX.XX.XXX', YYYY), data: c0:25:06:bd:4b:3b:04:3d:07:d0:00:00:0a:5d:0b:f9:0d:11:54:69:6d:65:20:4e:4f:54:20:53:45:54:00:00:77:69:66:6c:79:2d:45:5a:58:20:56:65:72:20:34:2e:30:30:2e:31:2c:20:41:70:72:20:31:39:44:61:69:6b:69:6e:41:43:3a:31:30:36:32:34:30:35:39:34:00:00:00:00:00:00:00:00:00:00:00:00:00:00:f5:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
   Error                           XML Parse Error: not well-formed (invalid token)
   Error                           On character 580 of line number 1.
   UDP Listener Debug              Daikin Listener: UDP msg from: ('192.XXX.XX.XXX', YYYY), data: c0:25:06:bd:4b:3b:04:3d:07:d0:00:00:0a:5d:0b:f9:0d:11:54:69:6d:65:20:4e:4f:54:20:53:45:54:00:00:77:69:66:6c:79:2d:45:5a:58:20:56:65:72:20:34:2e:30:30:2e:31:2c:20:41:70:72:20:31:39:44:61:69:6b:69:6e:41:43:3a:31:30:36:32:34:30:35:39:34:00:00:00:00:00:00:00:00:00:00:00:00:00:00:f5:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
   Error                           XML Parse Error: not well-formed (invalid token)
   Error                           On character 580 of line number 1.



The error lines are not coming from the plugin. I don't do any kind of XML parsing. Do you have some other script running that does?

Other than that, does the output look like the right data? I'm printing it as hex bytes because it's not an ascii or unicode string.

Hmm. I bet the error is coming from the Indigo client. I expect that's what happens when I use ValueType of String and put in binary data. I need to change it to the hex string first.

Try release 0.0.4: https://github.com/FlyingDiver/Indigo-U ... r/releases

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed May 02, 2018 6:55 am
MartinG offline
Posts: 116
Joined: Aug 19, 2016

Re: UDP Listener Plugin

I had a stream of errors yesterday with 0.0.1 Beta 2. Here's one:

Code: Select all
   UDP Listener Error              Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 107, in runConcurrentThread
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 8: ordinal not in range(128)

   UDP Listener Error              plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)


And today, running 0.0.4:

Code: Select all
Starting plugin "UDP Listener 0.0.4" (pid 99716)
   UDP Listener Debug              logLevel = 5
   Started plugin "UDP Listener 0.0.4"
   UDP Listener                    Starting UDP Listener
   UDP Listener Debug              BETA RakoListener: Device Current Version = 0
   UDP Listener Debug              BETA RakoListener: Device Version is up to date
   UDP Listener Debug              BETA RakoListener: Starting device (udpListener)
   UDP Listener Error              exception in deviceStartComm(BETA RakoListener): 'key multiGroup not found in dict'

Who is online

Users browsing this forum: No registered users and 1 guest

cron