# \[ST Edge\] UDP Broadcast Listener

**URL:** <https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375>\
**Category:** Writing Edge Drivers\
**Created:** [November 11, 2021, 9:22pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375 "2021-11-11T21:22:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrCapitalQ](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@MrCapitalQ](https://community.smartthings.com/u/MrCapitalQ)\
**Post date:** [November 11, 2021, 9:22pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/1 "2021-11-11T21:22:17Z")

</div>

I’m attempting to write a LAN edge driver where the device broadcasts a message over UDP whenever its state changes. However, I’m struggling to even get the UDP socket to receive messages when running on the hub. When I run basically the same code locally, it seems to work as I would expect.

Here is my listener code.

```auto
local udp = socket.udp()
assert(udp:setoption('broadcast', true)) -- Is this needed just for listening?
assert(udp:settimeout(2))
assert(udp:setsockname('*', 0)) -- Would love to specify port but I can't
local _, p = udp:getsockname() -- Instead, for now, grab the port that was assigned for testing purposes
log.debug('Listening on port ' .. p .. '...')

while true do
    local data, ip, port = udp:receivefrom()
    log.debug('Received from ' .. tostring(ip) .. ':' .. tostring(port) .. ' ' .. tostring(data))
end

```

When running on the hub, I only receive a message if I send a UDP message to the hub’s IP address and the generated port. If I send it to the broadcast IP (255.255.255.255) on the generated port, the message doesn’t show up. But, if I run locally on my machine, I get messages sent to either that machine IP or the broadcast IP.

**It seems that when running on the hub, broadcast messages are ignored. Is this expected? Am I doing this all wrong?**

Bonus question: Is there no way around passing 0 as the port number? Alternatively, is it possible to listen for UDP messages on all ports (this is a reach, I know).

---

<div class="post-metadata">

**Author:** ![JDRoberts](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jdroberts/32/56577_2.png) [@JDRoberts](https://community.smartthings.com/u/JDRoberts)\
**Post date:** [November 11, 2021, 10:19pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/2 "2021-11-11T22:19:40Z")

</div>

You might take a look at what @TAustin has been doing… he’s been exploring a lot of the extra driver options.

> [@\[ST Edge\] Web Requestor: a driver to issue local POST and GET HTTP requests](https://community.smartthings.com/t/st-edge-web-requestor-a-driver-to-issue-local-post-and-get-http-requests/232911/):
>
> I have a new Edge driver to share that provides the ability to issue POST and GET web requests to a specified URL. This functionality can help users that may today depend on webCoRE or other cloud-based means to do a similar task. Of course being an Edge driver it enables you to have fast & local automations. There are two ways this driver can be used: Pre-configure up to 50 different POST/GET URL strings, which can then be individually triggered through Automations/Rules or via a button in the mobile app. Issue custom URL POST/GET commands from within a Rule \>\>\>\>\>UPDATE: Please go to [this readme file](https://github.com/toddaustin07/webrequestor/blob/main/README.md) for the latest instructions Limitations Although GET method is supported, it currently does not actually do anything with the returned data from the server. I’m open to ideas he…

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [November 11, 2021, 10:35pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/3 "2021-11-11T22:35:43Z")

</div>

Even more relevant to what you are doing than my web requestor driver is my UPnP control point library. It is [on github](https://github.com/toddaustin07/edge_upnp) if you want to take a look at it. UPnP uses the gamut of TCP, UDP and multicast communications so it’s all covered in there.

This is how I create a socket for SSDP-type discovery:

```auto
local multicast_ip = "239.255.255.250"
  local multicast_port = 1900
  local listen_ip = "0.0.0.0"
  local listen_port = 0
  
  local s = assert(socket.udp(), "create discovery socket")
  
  assert(s:setsockname(listen_ip, listen_port), "discovery socket setsockname")

```

Not sure if the broadcast IP you’re trying to use is functional on the hub. The above should work both on hub and off.

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [November 13, 2021, 12:26am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/4 "2021-11-13T00:26:08Z")

</div>

@MrCapitalQ

My prior code snippet was for sending things out on the multicast address. I realized you probably really want this, which is how to listen on the multicast address:

```auto
-- initialize multicast socket
  m = assert(socket.udp(), "create discovery socket")
  assert(m:setoption('reuseaddr', true))
  assert(m:setsockname(multicast_ip, multicast_port))
  assert(m:setoption("ip-add-membership", {multiaddr = multicast_ip, interface = "0.0.0.0"}), "join multicast group")
  m:settimeout(0)

```

---

<div class="post-metadata">

**Author:** ![MrCapitalQ](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@MrCapitalQ](https://community.smartthings.com/u/MrCapitalQ)\
**Post date:** [November 15, 2021, 7:43pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/5 "2021-11-15T19:43:50Z")

</div>

I really appreciate you taking the time to reply and point me to your library as well as the code snippets you posted. Unfortunately I couldn’t get it to work. I suspect you’re onto something with your comment about not being sure if the broadcast IP is functional on the hub. I don’t really have control over that on the broadcasting device so I can’t address that.

The good news is I was able to accomplish my goal (pushing events to the hub) with a different mechanism that was available.

Again, super thankful for those that chimed in and much love for this community.

---

<div class="post-metadata">

**Author:** ![schwark](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/schwark/32/134026_2.png) [@schwark](https://community.smartthings.com/u/schwark)\
**Post date:** [August 23, 2022, 11:58pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/6 "2022-08-23T23:58:44Z")

</div>

Just getting started on Lua to port my old device drivers to Lua. I am building the guts on my Mac and then will move them into device drivers. In doing so, I am having trouble getting UDP broadcast sent out on all interfaces. On my Mac, the code below is only sending it out on loopback but not on en0. Have not tried it on the hub as that is much harder to debug than getting it work on the Mac first.

```auto
local udp = socket.udp()
udp:setoption("broadcast", true)
udp:setsockname("*",0)
udp:settimeout(2)
udp:sendto(data, "255.255.255.255", 137)

```

The above code only transmits on loopback interface, but not on en0 (verified via WireShark). I tried changing setsockname to the IP address on en0, but still no dice.

I have also tried using network-prefix.255 instead of 255.255.255.255 - does not make a difference either.

Similar code written in python on the same machine works just fine! Seems like some Lua specific thing I am not doing right - any help?

---

<div class="post-metadata">

**Author:** ![edleno](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/edleno/32/154882_2.png) [@edleno](https://community.smartthings.com/u/edleno)\
**Post date:** [September 3, 2022, 6:16am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/7 "2022-09-03T06:16:56Z")

</div>

I haven’t tried to get any LUA to run on my development machine, so my mileage may differ, but the hub LUA is pretty limited on udp - it must be multicast and NOT broadcast. Here’s a snip of my code to set up to receive and send on multicast:

```auto
(global)
local udpSocket = socket.udp()
local multicastIP = "239.192.1.1"
local multicastPort = 2290

(in my handle_discovery for example)
    ... other code ...
    udpSocket = assert(socket.udp(), "recreate the socket")
    assert(udpSocket:setoption('reuseaddr', true))
    assert(udpSocket:setsockname(multicastIP, multicastPort))
    assert(udpSocket:setoption("ip-add-membership", {multiaddr = multicastIP, interface = "0.0.0.0"}), "join multicast group")
    assert(udpSocket:settimeout(0))  
       
    udpSocket:sendto("DiscoverMotor", multicastIP, multicastPort)
    local beginTime = os.time()
    while os.time() - beginTime < 20 do
      local parseResult, returnIp, returnPort = udpSocket:receivefrom()
      if parseResult then
         -- handle the result data 
      end
    end

```

---

<div class="post-metadata">

**Author:** ![MABeatty1978](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/mabeatty1978/32/53192_2.png) [@MABeatty1978](https://community.smartthings.com/u/MABeatty1978)\
**Post date:** [February 17, 2023, 6:01pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/8 "2023-02-17T18:01:30Z")

</div>

Hello,

I’ve installed that driver in it’s basic form onto my hub. I’m running it in discovery and it’s not seeing the device I’m wanting to discover. The device is broadcasting UDP messages on port 50222. I’ve modified the watcher.lua cod to setup the socket defs for both multicas and listen (I saw that listen was doing what appeared to be UPD messages) but I’m still not seeing my device show up. Is there any guidance you can provide?

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [February 17, 2023, 6:53pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/9 "2023-02-17T18:53:12Z")

</div>

Are you referring to my UPnP driver? If so, UPnP uses port 1900 on multicast IP 239.255.255.250. Sounds like your device is doing something custom, so you’d have to make some changes.

If all you really want is the SSDP (discovery) part of UPnP, then you might want to use [this code](https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/bose/src/disco.lua) and modify it for your needs.

---

<div class="post-metadata">

**Author:** ![MABeatty1978](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/mabeatty1978/32/53192_2.png) [@MABeatty1978](https://community.smartthings.com/u/MABeatty1978)\
**Post date:** [February 17, 2023, 6:58pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/10 "2023-02-17T18:58:37Z")

</div>

Yes, that is what I’m referring to. To give you my use case, I have a personal weather device that broadcasts data on my LAN on port 50222. I’d like to have a listener on my hub pulling that data and parsing it out to populate a virtual weather device in SmartThings, specifically the temperature, humidity, and illuminance capabilities.

Here is listener I wrote that I have running on a pi, it’s basically what I’d like replicate on the hub [tempestListenerPicoW/tempestListenerPicoW.py at master · MABeatty1978/tempestListenerPicoW · GitHub](https://github.com/MABeatty1978/tempestListenerPicoW/blob/master/tempestListenerPicoW.py)

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [February 18, 2023, 1:55am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/11 "2023-02-18T01:55:13Z")

</div>

As @edleno mentioned above, the hub supports multicast, but I don’t think you can listen for broadcast messages. In the Edge environment, drivers cannot request a specific port. Listening on a multicast address is the one exception to this.

You might want to check with @nayelyz to see if she can find out if there is any way to make this work in an Edge driver, but I don’t think so.

---

<div class="post-metadata">

**Author:** ![MABeatty1978](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/mabeatty1978/32/53192_2.png) [@MABeatty1978](https://community.smartthings.com/u/MABeatty1978)\
**Post date:** [February 18, 2023, 2:29am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/12 "2023-02-18T02:29:41Z")

</div>

I wonder if that’s why the manufacturer of my personal weather station stuck the “Works With SmartThings” logo on it’s website in 2020. Then took it down a few weeks later. Then said, “SmartThings integration coming soon in 2021”. Then in 2022 said, “SmartThings support coming late 2022”… and now more crickets.

In any regard, I appreciate you taking the time to response and greatly appreciate all the work you have done for this community. 👍

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [February 19, 2023, 5:48am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/13 "2023-02-19T05:48:26Z")

</div>

Is this a Weatherflow Tempest system? FYI, I’m adding this source to my Edge weather driver.

I know keeping it local would be ideal, but you’d need to use your Pi as an intermediary. My driver will be using their cloud-based REST API.

---

<div class="post-metadata">

**Author:** ![MABeatty1978](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/mabeatty1978/32/53192_2.png) [@MABeatty1978](https://community.smartthings.com/u/MABeatty1978)\
**Post date:** [February 20, 2023, 1:15am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/14 "2023-02-20T01:15:31Z")

</div>

Yes, it is Tempest. I’m doing some fun stuff with the API (not SmartThings related), and got tired of waiting for them to release their own integration they have been promising. I figured I’d use this as an opportunity to dive into the Edge ecosystem. I was hoping to just use the UDP data it broadcasts to update an edge driver, but I guess that isn’t possible. Tempest integrates with Weather Underground, which integrates with SmartThings, but that’s a Groovy integration, so who knows how long that will survive.

If there is anything I can help with, I would love to do so.

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [February 20, 2023, 3:02am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/15 "2023-02-20T03:02:53Z")

</div>

My Edge driver already supports WU too.

---

<div class="post-metadata">

**Author:** ![wrutnam](https://avatars.discourse-cdn.com/v4/letter/w/46a35a/32.png) [@wrutnam](https://community.smartthings.com/u/wrutnam)\
**Post date:** [June 10, 2026, 3:18pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/16 "2026-06-10T15:18:23Z")

</div>

Hi Todd,

I am new to this community, but have been a long time user of SmartThings. I am very new to Edge as I was previously using Groovy for drivers. I am trying to setup your Edge Weather driver to connect SmartThings to PI to my Tempest weather station, but I am having trouble. I have used CoPilot for guidance with my setup, but it keeps stating that I have the wrong driver. It states that you created an Edge Weather V2 driver. Is this correct? If so, how can I access it? I would appreciate your assistance with this as I want to pull in my local forecast data from Tempest into SmartThings for automation.

Thanks.

- Bill

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [June 10, 2026, 5:21pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/17 "2026-06-10T17:21:06Z")

</div>

Hi there. Welcome to the community.

Another case of AI hallucination, I’m afraid! The latest driver is:

| Edge Weather V1 | 52498ca5-55b3-47a2-859e-5d9159c751f2 | 2025-12-11T19:08:48.430475188 |
| --- | --- | --- |

This is available on my [test channel](https://bestow-regional.api.smartthings.com/invite/Q1jP7BqnNNlL).

If you are having problems, I think the first thing to ask is this: This of course requires my edgebridge app running on your Pi. Have you gotten that all set up and running? Have you been able to test it with any other driver to be sure everything is working?

Tell me a little more about the issue you are having. We may need to get logs from either the driver itself (using the SmartThings CLI), or you can also view the edgebridge logs on your Pi.

---

<div class="post-metadata">

**Author:** ![wrutnam](https://avatars.discourse-cdn.com/v4/letter/w/46a35a/32.png) [@wrutnam](https://community.smartthings.com/u/wrutnam)\
**Post date:** [June 10, 2026, 7:02pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/18 "2026-06-10T19:02:37Z")

</div>

Thank you Todd for the quick reply. I was worried that AI was leading me down the wrong path since I could not find Edge Weather version 2 anywhere on your GitHub page or on your SmartThings community page. I didn’t think you would have it behind a paywall since you share all your hard work with the broader community which we appreciate. I am not very technical so tried to follow your steps from the original GitHub invitation link to setup the bridge and driver. AI is claiming my edge bridge is running based on a bunch of tests it asked me to run. I am new to PI too as I just recently purchased a device to access my Tempest data since the company never created a direct integration with SmartThings like other brands have. I downloaded your Edgebridge Monitor driver today and the device originally showed as offline in SmartThings, but I was able to fix it. I moved all of your files to the main root folder. I originally created a sub-folder and some files were stored there. I have since deleted the sub-folder so everything is in one place. The Edge Weather device in SmartThings is still not pulling data from my Tempest weather station. I believe I have updated all the settings correctly including the URLs. What do you recommend to fix this issue? I will stop using AI. LOL!!!

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [June 10, 2026, 8:47pm UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/19 "2026-06-10T20:47:54Z")

</div>

I think the easiest thing for you to do now is check the edgebridge log file. Go to the directory on your Pi where you installed it and dump the contents using the command:

`cat edgebridge.log`

If for some reason it doesn’t exist, paste here the contents of your edgebridge.cfg file:

`cat edgebridge.cat`

You can also display a continuous output of the log file with this command:

`tail -f edgebridge.log`

While that is running, try refreshing the device control screen back in the SmartThings app for the whether device you created. You should see a transaction pop up on the edgebridge log.

As an aside, make sure that your Pi is on the same subnet as your SmartThings hub.

It would also be helpful to tell me all the settings values you have configured for the SmartThings weather device (weather source, URLs, proxy server address and type, etc.)

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [June 11, 2026, 12:04am UTC](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375/22 "2026-06-11T00:04:53Z")

</div>

Stand by… I plugged your URL into a test device and the data is causing an error in the driver - seems to be related to one of the values being returned. Let me get back to you. This may require a code fix!

[Next page](https://community.smartthings.com/t/st-edge-udp-broadcast-listener/234375.md?page=2)
