Hi,
I want to replace my existing HomeAutomation Server with OpenHAB.
At the heart of my system, there are sevral Arduino’s with Ethernet connection, to control the following functions: Shutters, Weather Station, Heating System, SmartMeter and a Network of OneWire Temerature Sensors.
However, the Arduino’s are all over the House, and it can happen sometimes that due to a mains power failure, they disconnect from the Network shortly to be available agin moments later.
Therefore, I need to make sure, that I have an error tolreant and reliable comminicatuiion with my Arduinos.
But that seems to be not that easy with OpenHAB…
I created an ordinariy TCP binding:
String Arduino “Arduino [%s]” (arduino) {tcp=">[192.168.1.123:23:‘REGEX((.*))’]"}
Switch Arduino_Sw1 “Arduino Schalter”
And a very simple rule, to test the connection:
rule “Arduino_Send”
when
Item Arduino_Sw1 received command
then
if(receivedCommand==ON) {
sendCommand (Arduino , “Lights=ON”)
} else {
sendCommand (Arduino , “Lights=OFF”)
}
end
Everything is running fine, if the Arduino is on the Network, and when I start up OpenHAB. I can talk to it, using my switch. Here is the Startup Script, and the operation of the Switch.
The receiveing end at the Arduino is also working well.
Launching the openHAB runtime…
osgi> 2015-09-07 03:49:58.494 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.7.1).
… more …
2015-09-07 03:50:16.458 [INFO ] [t.AbstractSocketChannelBinding] - The maximum buffer will be set to the default value of 1024
2015-09-07 03:50:16.464 [INFO ] [t.AbstractSocketChannelBinding] - The interval to retry connection setups will be set to the default value of 5
2015-09-07 03:50:16.465 [INFO ] [t.AbstractSocketChannelBinding] - The cron job to reset connections will be set to the default value of 0 0 0 * * ?
2015-09-07 03:50:16.466 [INFO ] [t.AbstractSocketChannelBinding] - The setting to queue write operation until a channel gets connected will be set to the defaul
t value of true
2015-09-07 03:50:16.466 [INFO ] [t.AbstractSocketChannelBinding] - The port to listen for incoming connections will be set to the default value of 0
2015-09-07 03:50:16.466 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels within an Item will be set to the default value of true
2015-09-07 03:50:16.467 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels between the items with the same direction will be set to the de
fault value of true
2015-09-07 03:50:16.467 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels between directions will be set to the default value of true
2015-09-07 03:50:16.467 [INFO ] [t.AbstractSocketChannelBinding] - The setting to use address masks for incoming connections will be set to the default value of
true
2015-09-07 03:50:16.468 [INFO ] [t.AbstractSocketChannelBinding] - The refresh interval of the worker thread will be set to the default value of 250
2015-09-07 03:50:16.469 [INFO ] [t.protocol.internal.TCPBinding] - The maximum time out for blocking write operations will be set to the default vaulue of 3000
2015-09-07 03:50:16.470 [INFO ] [t.protocol.internal.TCPBinding] - The blocking nature of read/write operations will be set to the default vaulue of false
2015-09-07 03:50:16.471 [INFO ] [t.protocol.internal.TCPBinding] - The preamble for all write operations will be set to the default vaulue of
2015-09-07 03:50:16.472 [INFO ] [t.protocol.internal.TCPBinding] - The postamble for all write operations will be set to the default vaulue of
2015-09-07 03:50:16.472 [INFO ] [t.protocol.internal.TCPBinding] - Updating states with returned values will be set to the default vaulue of true
2015-09-07 03:50:16.471 [INFO ] [.service.AbstractActiveService] - TCP Refresh Service has been started
2015-09-07 03:50:16.475 [INFO ] [t.AbstractSocketChannelBinding] - Connecting the channel Channel [item=Arduino, command=0, direction=OUT, remote=/192.168.1.123:23, buffer=, isBlocking=false, isReconnecting=false, channel=, host=192.168.1.123, port=23]
2015-09-07 03:50:16.497 [INFO ] [.service.AbstractActiveService] - HTTP Refresh Service has been started
2015-09-07 03:50:16.728 [INFO ] [t.AbstractSocketChannelBinding] - The channel for /192.168.1.123:23 is now connected
2015-09-07 03:50:16.754 [INFO ] [.service.AbstractActiveService] - NTP Refresh Service has been started
… more …
2015-09-07 03:50:40.561 [INFO ] [runtime.busevents ] - Arduino_Sw1 received command ON
2015-09-07 03:50:40.636 [INFO ] [runtime.busevents ] - Arduino received command Lights=ON
2015-09-07 03:50:40.649 [INFO ] [runtime.busevents ] - Arduino state updated to Lights=ON
2015-09-07 03:50:40.698 [INFO ] [runtime.busevents ] - Arduino_Function state updated to Lights=ON
2015-09-07 03:50:43.425 [INFO ] [runtime.busevents ] - Arduino_Sw1 received command OFF
2015-09-07 03:50:43.456 [INFO ] [runtime.busevents ] - Arduino received command Lights=OFF
2015-09-07 03:50:43.458 [INFO ] [runtime.busevents ] - Arduino state updated to Lights=OFF
2015-09-07 03:50:43.469 [INFO ] [runtime.busevents ] - Arduino_Function state updated to Lights=OFF
However, once I reset the Ardunino Board, I can not recover from the error… the log is running full with Warnings, but I never get a connection again… What am I doing wrong? Or have overlooked.
2015-09-07 03:53:47.640 [WARN ] [t.AbstractSocketChannelBinding] - The channel for /192.168.1.123:23 has encountered an unknown IO Exception: An existing connection was forcibly closed by the remote host
2015-09-07 03:53:47.892 [WARN ] [t.AbstractSocketChannelBinding] - The channel for /192.168.1.123:23 has encountered an unknown IO Exception: An existing connection was forcibly closed by the remote host
2015-09-07 03:53:48.143 [WARN ] [t.AbstractSocketChannelBinding] - The channel for /192.168.1.123:23 has encountered an unknown IO Exception: An existing connection was forcibly closed by the remote host
2015-09-07 03:53:48.394 [WARN ] [t.AbstractSocketChannelBinding] - The channel for /192.168.1.123:23 has encountered an unknown IO Exception: An existing connection was forcibly closed by the remote host
I am greateful for any tip.