Search in sources :

Example 1 with GroupResponse

use of com.bwssystems.HABridge.api.hue.GroupResponse in project ha-bridge by bwssytems.

the class HueMulator method groupsIdHandler.

private Object groupsIdHandler(String groupId, String userId, String requestIp) {
    log.debug("hue group id: <" + groupId + "> requested: " + userId + " from " + requestIp);
    HueError[] theErrors = null;
    theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
    if (theErrors == null) {
        if (bridgeSettingMaster.getBridgeSecurity().isSettingsChanged())
            bridgeSettingMaster.updateConfigFile();
        if (groupId.equalsIgnoreCase("0")) {
            GroupResponse theResponse = GroupResponse.createDefaultGroupResponse(repository.findActive());
            return theResponse;
        }
        if (!groupId.equalsIgnoreCase("0")) {
            GroupResponse theResponse = GroupResponse.createOtherGroupResponse(repository.findActive());
            return theResponse;
        }
        theErrors = HueErrorResponse.createResponse("3", userId + "/groups/" + groupId, "Object not found", null, null, null).getTheErrors();
    }
    return theErrors;
}
Also used : HueError(com.bwssystems.HABridge.api.hue.HueError) GroupResponse(com.bwssystems.HABridge.api.hue.GroupResponse)

Example 2 with GroupResponse

use of com.bwssystems.HABridge.api.hue.GroupResponse in project ha-bridge by bwssytems.

the class HueMulator method getFullState.

@SuppressWarnings("unchecked")
private Object getFullState(String userId, String ipAddress) {
    log.debug("hue api full state requested: " + userId + " from " + ipAddress);
    HueError[] theErrors = bridgeSettingMaster.getBridgeSecurity().validateWhitelistUser(userId, null, bridgeSettingMaster.getBridgeSecurity().isUseLinkButton());
    if (theErrors != null)
        return theErrors;
    HueApiResponse apiResponse = new HueApiResponse("Philips hue", bridgeSettings.getUpnpConfigAddress(), bridgeSettings.getWhitelist(), bridgeSettings.getHubversion());
    apiResponse.setLights((Map<String, DeviceResponse>) this.lightsListHandler(userId, ipAddress));
    apiResponse.setGroups((Map<String, GroupResponse>) this.groupsListHandler(userId, ipAddress));
    return apiResponse;
}
Also used : DeviceResponse(com.bwssystems.HABridge.api.hue.DeviceResponse) HueError(com.bwssystems.HABridge.api.hue.HueError) HueApiResponse(com.bwssystems.HABridge.api.hue.HueApiResponse) GroupResponse(com.bwssystems.HABridge.api.hue.GroupResponse)

Aggregations

GroupResponse (com.bwssystems.HABridge.api.hue.GroupResponse)2 HueError (com.bwssystems.HABridge.api.hue.HueError)2 DeviceResponse (com.bwssystems.HABridge.api.hue.DeviceResponse)1 HueApiResponse (com.bwssystems.HABridge.api.hue.HueApiResponse)1