Problems with Amazon Echo Control Binding if internet connection lost

I have a running openhab 2.4 installation with Ubuntu 18.04.2 LTS (GNU/Linux 4.18.0-20-generic x86_64). The Amazon Echo Control Binding is working well as long as the internet connection not lost.
Last night the internet connection lost caused by a DSL provider problem. In this case the Amazon Echo Control Binding throws a hughe amount of error messages

2019-05-23 00:56:33.852 [WARN ] [mazonechocontrol.internal.Connection] - Request to url 'https://alexa.amazon.de/api/content-skills/enabled-feeds' fails with unkown error
java.net.UnknownHostException: alexa.amazon.de

Finally openhab server does not resond to any request. Rules are not working, UI’s are not working, karaf console not working. Needed to restart openhab service after internet connection restored.

Is there a way to prevent such problems?
My solutuion is not to use the Amazon Echo Control Binding any more.

Your solution should be to file an issue on the binding so this problem can be fixed. The repo is the openhab2-addons I think. See How to file an Issue.

I’m a big fan of the Amazon Echo binding; this is NOT the only binding that has issues when the internet connection drops. Here’s how I handle this . . .

  • Install network binding
    Things:
Thing network:servicedevice:netconnect													[ hostname="208.67.220.220", port=53 ]	// resolver2.opendns.com

Items:

Switch	InternetConnection					   				"[%s]"													(NetworkStuff)	{ channel="network:servicedevice:netconnect:online" }

Rules:

Any rule that uses the internet; I wrap this logic around it.

if (InternetConnection.state == ON) {
    . . . . .
}

This will NOT completely resolve the error logging issues when the internet is not reachable because bindings will still want to talk outbound but the rules will stop executing now due to it.

Here’s the logging I have for the Amazon Binding:

#
# Amazon
#
log4j2.logger.Amazon.name = org.openhab.binding.amazonechocontrol
log4j2.logger.Amazon.level = INFO
log4j2.logger.Amazon.additivity = false
log4j2.logger.Amazon.appenderRefs = Amazon
log4j2.logger.Amazon.appenderRef.Amazon.ref = Amazon

# File appender - Amazon.log
log4j2.appender.Amazon.type = RollingRandomAccessFile
log4j2.appender.Amazon.name = Amazon
log4j2.appender.Amazon.fileName = ${openhab.logdir}/Amazon.log
log4j2.appender.Amazon.filePattern = ${openhab.logdir}/Amazon.log.%i
log4j2.appender.Amazon.immediateFlush = true
log4j2.appender.Amazon.append = true
log4j2.appender.Amazon.layout.type = PatternLayout
log4j2.appender.Amazon.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j2.appender.Amazon.policies.type = Policies
log4j2.appender.Amazon.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.Amazon.policies.size.size = 3MB
log4j2.appender.Amazon.strategy.type = DefaultRolloverStrategy
log4j2.appender.Amazon.strategy.max = 10

All your errors for the Amazon binding will go into a separate log going forward.

Best, Jay

If you can detect the failure (e.g. with network binding) you should be able to use REST API to disable the Amazon Thing (the account thing perhaps?) and stop it complaining.

Could you provide the technical framework for this concept? Maybe use one of my bindings below that maybe you have an example (network, amazon, open weather, ring, sonos, nest, dark sky, air quality, unifi and ip camera)?

Best, Jay

Searching forum “rest api disable thing” throws up a few candidates.

You’d need to work out which (if any) amazon thing is the “master” thing. Probably the one that doesn’t go offline in a fault situation.

Install the REST API docs. Open them and scroll down to “things”. Open it up and you will see

Open that up and experiment. This will give you the HTTP calls you need to make to enable/disable the Thing which you can implement using the sendHttpPutRequest Action from a Rule.

I am on openhab 3.2 and this is still a problem. Log fills up when the internet becomes unavailable. I would like the binding to recognise that situation and make the error in the log simple and plain instead of verbose and difficult to work out what happened. I did ask the devloper a while ago but he wasn’t supportive at the time.

So, I wrote a rule and some scripts that monitor the network access to the internet and when the internet is unreachable a script runs that stops the binding (uses karaf) or disable the the amazon echo account thing (uses REST api). When the network is back the rule enables the thing or restarts the binding. Enabling,disabling the thing is the preferred method as I found sometimes restarting the binding didn’t always work in OH2. I have the monitoring now also running in OH3

I’ve been doing this also since OH 2.x and now with OH 3.x A combination of checking a group of internet connection values and the Alexa status value on ALL Alexa related commands.

If my internet goes down, the inline logic rules kick in above so they don’t execute. When the internet comes back online, I restart the binding also via Karaf and then check if it worked by the Alexa Status, if Alexa Status != ONLINE, I do it again if necessary.

It would be nice if the binding could provide some sort of this Internet connectivity switch logic.

Best, Jay

1 Like