Search in sources :

Example 1 with InnogyWebSocket

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);
}
Also used : InnogyWebSocket(org.openhab.binding.innogysmarthome.internal.InnogyWebSocket) AccessTokenResponse(org.openhab.core.auth.client.oauth2.AccessTokenResponse)

Example 2 with InnogyWebSocket

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);
    }
}
Also used : InnogyWebSocket(org.openhab.binding.innogysmarthome.internal.InnogyWebSocket) TimeoutException(java.util.concurrent.TimeoutException) AuthenticationException(org.openhab.binding.innogysmarthome.internal.client.exception.AuthenticationException) OAuthResponseException(org.openhab.core.auth.client.oauth2.OAuthResponseException) OAuthException(org.openhab.core.auth.client.oauth2.OAuthException) InvalidActionTriggeredException(org.openhab.binding.innogysmarthome.internal.client.exception.InvalidActionTriggeredException) SocketTimeoutException(java.net.SocketTimeoutException) ControllerOfflineException(org.openhab.binding.innogysmarthome.internal.client.exception.ControllerOfflineException) ApiException(org.openhab.binding.innogysmarthome.internal.client.exception.ApiException) IOException(java.io.IOException) RemoteAccessNotAllowedException(org.openhab.binding.innogysmarthome.internal.client.exception.RemoteAccessNotAllowedException) ExecutionException(java.util.concurrent.ExecutionException) SessionExistsException(org.openhab.binding.innogysmarthome.internal.client.exception.SessionExistsException)

Aggregations

InnogyWebSocket (org.openhab.binding.innogysmarthome.internal.InnogyWebSocket)2 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 ApiException (org.openhab.binding.innogysmarthome.internal.client.exception.ApiException)1 AuthenticationException (org.openhab.binding.innogysmarthome.internal.client.exception.AuthenticationException)1 ControllerOfflineException (org.openhab.binding.innogysmarthome.internal.client.exception.ControllerOfflineException)1 InvalidActionTriggeredException (org.openhab.binding.innogysmarthome.internal.client.exception.InvalidActionTriggeredException)1 RemoteAccessNotAllowedException (org.openhab.binding.innogysmarthome.internal.client.exception.RemoteAccessNotAllowedException)1 SessionExistsException (org.openhab.binding.innogysmarthome.internal.client.exception.SessionExistsException)1 AccessTokenResponse (org.openhab.core.auth.client.oauth2.AccessTokenResponse)1 OAuthException (org.openhab.core.auth.client.oauth2.OAuthException)1 OAuthResponseException (org.openhab.core.auth.client.oauth2.OAuthResponseException)1