use of org.openhab.binding.innogysmarthome.internal.InnogyWebSocket in project openhab-addons by openhab.
the class InnogyBridgeHandler method createWebSocket.
InnogyWebSocket createWebSocket() throws IOException, AuthenticationException {
final AccessTokenResponse accessTokenResponse = client.getAccessTokenResponse();
final String webSocketUrl = WEBSOCKET_API_URL_EVENTS.replace("{token}", accessTokenResponse.getAccessToken());
logger.debug("WebSocket URL: {}...{}", webSocketUrl.substring(0, 70), webSocketUrl.substring(webSocketUrl.length() - 10));
return new InnogyWebSocket(this, URI.create(webSocketUrl), bridgeConfiguration.websocketidletimeout * 1000);
}
use of org.openhab.binding.innogysmarthome.internal.InnogyWebSocket in project openhab-addons by openhab.
the class InnogyBridgeHandler method startWebsocket.
/**
* Start the websocket connection for receiving permanent update {@link Event}s from the innogy API.
*/
private void startWebsocket() {
try {
InnogyWebSocket localWebSocket = createWebSocket();
if (this.webSocket != null && this.webSocket.isRunning()) {
this.webSocket.stop();
this.webSocket = null;
}
logger.debug("Starting innogy websocket.");
this.webSocket = localWebSocket;
localWebSocket.start();
updateStatus(ThingStatus.ONLINE);
} catch (final Exception e) {
// Catch Exception because websocket start throws Exception
logger.warn("Error starting websocket.", e);
handleClientException(e);
}
}
Aggregations