ANEL Net-PwrCtrl Binding for OH3

I have re-written the binding for ANEL Net-PwrCtrl devices (doc of old binding version).
It has already been requested here.

This is an early version which already works fine with my two test devices (HUT2 and HOME).
Please feel free to test it and give feedback: download it here.
It should be sufficient to drop the the jar-file into your addons-folder (maybe OH must be restarted).

All channels of the old version of the binding should be supported, but you have to re-configure them all.
If you have multiple devices, please make sure that each device has its own exclusive UDP ports assigned (preferrably >1024, e.g. 7701 / 7501, 7702 / 7502, etc).

If something does not work as expected, keep an eye on the log and maybe set the log level to DEBUG, e.g. in the console:
openhab> log:set DEBUG org.openhab.binding.anel

If you want to report or discuss an issue, please add related log entries to your post (maybe also your device and firmware version).
There are still some TODOs left:

  • Auto discovery
  • Documentation
  • Dimmers

Hi Patrick

I have downloaded and installed this new version and it works, thanks!

There are a lot of these warnings when I reboot openHAB. Most probably, while the binding is inizializing:

2021-06-09 10:35:59.455 [WARN ] [nding.anel.internal.AnelUdpConnector] - Unexpected error while listening on port 7701
java.net.SocketException: Socket closed
at java.net.PlainDatagramSocketImpl.receive0(Native Method) ~[?:?]
at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:181) ~[?:?]
at java.net.DatagramSocket.receive(DatagramSocket.java:814) ~[?:?]
at org.openhab.binding.anel.internal.AnelUdpConnector.run(AnelUdpConnector.java:120) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]

Anel Power Hut FW7.1

BR
Michael

Strange… I’ve never seen this exception on thing initialization.
This exception should only happen when the thing is deactivated. And during thing shutdown, this warning should not be logged.

How many such warnings are logged during a single initialization phase?
Is the thing initialized once or does it go online and offline multiple times?
(a connection check to the device is currently performed once a minute)

Hi Patrick,

1000 thanks!!

I was able to add 3 HUT’s without any issues, except that I had to restart openhab each time before the new HUT would become online.

From 4th up to 8th HUT I tried to add, there are always max 3-4 HUT’s online. (and the rest gives ERROR:COM)
Even those that were OK before. (HUT 1-3)

17:18:36.082 [INFO ] [inding.anel.internal.AnelUdpConnector] - Anel NET-PwrCtrl listener started for: ‘192.168.5.246:7677’
17:18:36.098 [INFO ] [inding.anel.internal.AnelUdpConnector] - Anel NET-PwrCtrl listener started for: ‘192.168.5.245:7577’
17:18:38.149 [INFO ] [re.automation.internal.RuleEngineImpl] - Rule engine started.
17:18:42.089 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel6’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.246,user=admin,password=XXXX,udpSendPort=7675,udpReceiverPort=7677]
17:18:42.089 [INFO ] [inding.anel.internal.AnelUdpConnector] - Anel NET-PwrCtrl listener started for: ‘192.168.5.248:7877’
17:18:42.106 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel5’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.245,user=admin,password=XXXX,udpSendPort=7575,udpReceiverPort=7577]
17:18:42.122 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel8’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.248,user=admin,password=XXXX,udpSendPort=7875,udpReceiverPort=7877]
17:18:48.127 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel2’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.242,user=admin,password=XXXX,udpSendPort=7275,udpReceiverPort=7277]
17:18:48.143 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel6’ changed from OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.246,user=admin,password=XXXX,udpSendPort=7675,udpReceiverPort=7677] to ONLINE
17:18:48.156 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel7’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=net-control,user=admin,password=XXXX,udpSendPort=7775,udpReceiverPort=7777]
17:18:48.161 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel5’ changed from OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.245,user=admin,password=XXXX,udpSendPort=7575,udpReceiverPort=7577] to ONLINE
17:18:54.150 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel1’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.241,user=admin,password=XXXX,udpSendPort=7175,udpReceiverPort=7177]
17:18:54.167 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel4’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.244,user=admin,password=XXXX,udpSendPort=7475,udpReceiverPort=7477]
17:18:54.178 [INFO ] [inding.anel.internal.AnelUdpConnector] - Anel NET-PwrCtrl listener started for: ‘net-control:7777’
17:18:54.181 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel8’ changed from OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.248,user=admin,password=XXXX,udpSendPort=7875,udpReceiverPort=7877] to ONLINE
17:19:00.154 [INFO ] [inding.anel.internal.AnelUdpConnector] - Anel NET-PwrCtrl listener started for: ‘192.168.5.242:7277’
17:19:00.154 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing ‘anel:advanced-firmware:anel3’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Device does not respond (check IP, ports, and network connection): AnelConfiguration[hostname=192.168.5.243,user=admin,password=XXXX,udpSendPort=7375,udpReceiverPort=7377]

For those offline I see:
17:30:54.360 [DEBUG] [inding.anel.internal.AnelUdpConnector] - Sending message ‘wer da?’ to 192.168.5.241:7175
17:30:54.364 [DEBUG] [inding.anel.internal.AnelUdpConnector] - Sending successful.
But no response …

When I disable the 3 HUT’s that are OK, 3 other HUT’s will become OK

eg HUT 1 now is OK:
17:35:34.332 [DEBUG] [inding.anel.internal.AnelUdpConnector] - Sending message ‘wer da?’ to 192.168.5.241:7175
17:35:34.336 [DEBUG] [inding.anel.internal.AnelUdpConnector] - Sending successful.

And the response is there:

17:35:34.338 [DEBUG] [inding.anel.internal.AnelUdpConnector] - Received data: NET-PwrCtrl:NET-CONTROL 01 :192.168.5.241:255.255.255.0:192.168.5.1:0.4.163.18.5.33:Nr.1,1:Nr.2,1:Nr.3,1:Nr.4,1:Nr.5,1:Nr.6,0:Nr.7,0:Nr.8,0:0:80:IO-1,1,1:IO-2,1,1:IO-3,1,1:IO-4,1,1:IO-5,1,1:IO-6,1,1:IO-7,1,1:IO-8,1,1:25.5�C:NET-PWRCTRL_06.5:h:n:xor:

And the same again when I disable again those OK/Online … the last HUTs will become OK.

So all individual configs are ok. But looks like there’s an issue when there are more than 3 HUT’s enabled?

8x NET-PwrCtrl HUT Ver.: 6.5
Openhab 3.0.2

BR,
Peter

I have now deleted the thing and started from scratch, but still the same. I get hundreds (thousands?) of these warning when I start or restart openHAB:

2021-06-10 18:54:33.828 [WARN ] [nding.anel.internal.AnelUdpConnector] - Unexpected error while listening on port 7701
java.net.SocketException: Socket closed
at java.net.PlainDatagramSocketImpl.receive0(Native Method) ~[?:?]
at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:181) ~[?:?]
at java.net.DatagramSocket.receive(DatagramSocket.java:814) ~[?:?]
at org.openhab.binding.anel.internal.AnelUdpConnector.run(AnelUdpConnector.java:120) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
2021-06-10 18:54:33.830 [WARN ] [nding.anel.internal.AnelUdpConnector] - Unexpected error while listening on port 7701
java.net.SocketException: Socket closed
at java.net.PlainDatagramSocketImpl.receive0(Native Method) ~[?:?]
at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:181) ~[?:?]
at java.net.DatagramSocket.receive(DatagramSocket.java:814) ~[?:?]
at org.openhab.binding.anel.internal.AnelUdpConnector.run(AnelUdpConnector.java:120) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
2021-06-10 18:54:33.831 [WARN ] [nding.anel.internal.AnelUdpConnector] - Unexpected error while listening on port 7701
java.net.SocketException: Socket closed
at java.net.PlainDatagramSocketImpl.receive0(Native Method) ~[?:?]
at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:181) ~[?:?]
at java.net.DatagramSocket.receive(DatagramSocket.java:814) ~[?:?]
at org.openhab.binding.anel.internal.AnelUdpConnector.run(AnelUdpConnector.java:120) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
2021-06-10 18:54:33.832 [WARN ] [nding.anel.internal.AnelUdpConnector] - Unexpected error while listening on port 7701
java.net.SocketException: Socket closed
at java.net.PlainDatagramSocketImpl.receive0(Native Method) ~[?:?]
at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:181) ~[?:?]
at java.net.DatagramSocket.receive(DatagramSocket.java:814) ~[?:?]
at org.openhab.binding.anel.internal.AnelUdpConnector.run(AnelUdpConnector.java:120) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]

Nearly every millisecond :open_mouth:

BTW: openHAB 3.1.0 M5!

Update: It seems that it has nothing to do with “Inizializing”. The Warnings are somehow before that.

Indeed. I can observe a similar behavior. Although I managed to get 4 devices online, communication is not really stable:

For each thing, a listening thread is started on the specifed port (the old bindings does it as well), but after the 4th thing is online, some (if not all) listening threads are blocked. After disabling one of the things, the messages are processed again. This is really weired. It seems as if OH3 only allows a limited number of concurrent threads? I cannot image that this is the case…

The good thing: I can reproduce the issue and try to find a solution.
The bad thing: I won’t have time for the next couple of days to look into it :wink:

This can only happen if the binding fails to listen to the specified port.
The binding tries it over and over again without any delay because it assumes exclusive access to the port.
The only two reasons I could think of is that either (1) the port is already occupied by someone else.
Do you have multiple things configured for the same port which might interfer with each other?
Is another application communicating with the device?
Could you try to use a different port?
Or (2) that your system does not allow OH to listen on the port, maybe some kind of security issue.

I will add a check that multiple subsequent listening failures will log a complete stacktrace (which will hopefully contain the cause of the problem), and that the thing will stop its initialization - without a listening thread, communication is not really possible :wink:

And you say that the device come online anyway and then it works as expected?

Mmmhhh, the PowerHut is the only device I have in my network and openHAB is the only application that connects to it.

I have started again from scratch and with standard and different ports but without success. As soon as openHAB is up and running everything is working as expected. Thing is online and I can control the outputs.

What I have seen → All these warnings are generated even before the events.log is generated by openHAB. So it must be at the very beginning of the startup process of openHAB. As soon as events.log is there, the warnings also disappear.