anhaehne / hhnl.HomeAssistantNet

48 stars 6 forks source link

Cannot use UDP port #60

Closed PockyBum522 closed 1 year ago

PockyBum522 commented 2 years ago

Hello! Loving the AddOn. I'm moving some of my node-red flows to C# and I've run into a problem. I am trying to use a UdpClient in .Net to listen on a specific port to one of my IoT devices directly. But I don't believe the C# AddOn exposes any ports by default.

Can I set this anywhere? I found the TCP port option in the AddOn config in HA, but changing it and saving it doesn't seem to stick. It reverts back to 20777. Not to mention I need a UDP port anyways.

Thank you!

PockyBum522 commented 2 years ago

I forked the repo, and made this change:

image

Just adding the new udp port in the config.json.

I then uninstalled the original AddOn, and installed my fork. Waited for it to build, then started it.

It works now. I'd love to expose this in the config so that you can add a port through the HA C# AddOn config tab in ingress.

PockyBum522 commented 2 years ago

Simplest option seems to be something like exposing a few ports with null as the given outside port value. Here's an example of a UDP port like I'd need:

(The port assigned to null is what I'm talking about.) image

These will show up in the config tab as disabled until the user chooses what host port to associate (all or any) of them with. In this case, I just change my C# code to look at port 40365, then in the config tab I set it to associate with whatever port number I have my UDP device sending packets to, but until I do that in the config tab, it defaults to disabled.

IMHO, it would be helpful to do this with a few UDP ports and a few TCP ports, they'd all just be disabled by default, but if a user wanted to use one or more, they would just need to type in a port number, save, and restart the addin. Thoughts?

If you'd like to, I'll make the change and throw it in as a pull request. I was thinking ports starting at 10,000 for UDP and maybe 5 of them by default, all pointing to null externally, and perhaps 20,000 and up for TCP, maybe 5 of them? If this would be helpful, lmk. Thanks!

DavidDeSloovere commented 2 years ago

I think the author of the project has gone dark. If there is no reply in #58 then we could fork it?

PockyBum522 commented 2 years ago

I have ended up using https://netdaemon.xyz/ and it is quite good and has good active support.