Search in sources :

Example 1 with NgResponse

use of org.openhab.binding.hyperion.internal.protocol.ng.NgResponse in project openhab-addons by openhab.

the class HyperionNgHandler method sendCommand.

public NgResponse sendCommand(HyperionCommand command) throws IOException, CommandUnsuccessfulException {
    String commandJson = gson.toJson(command);
    String jsonResponse = connection.send(commandJson);
    NgResponse response = gson.fromJson(jsonResponse, NgResponse.class);
    if (!response.isSuccess()) {
        throw new CommandUnsuccessfulException(gson.toJson(command) + " - Reason: " + response.getError());
    }
    return response;
}
Also used : NgResponse(org.openhab.binding.hyperion.internal.protocol.ng.NgResponse) CommandUnsuccessfulException(org.openhab.binding.hyperion.internal.protocol.CommandUnsuccessfulException)

Aggregations

CommandUnsuccessfulException (org.openhab.binding.hyperion.internal.protocol.CommandUnsuccessfulException)1 NgResponse (org.openhab.binding.hyperion.internal.protocol.ng.NgResponse)1