Problems with Amazon Echo Control Binding if internet connection lost

Tags: #<Tag:0x00007f38790e0b38> #<Tag:0x00007f38790e09f8> #<Tag:0x00007f38790e0890>

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.