diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/SecurityApi.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/SecurityApi.java index 3640144ff..3b4977117 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/SecurityApi.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/SecurityApi.java @@ -101,10 +101,12 @@ public class SecurityApi extends RestManager { post(uriBuilder, ApiResponse.Ok.class, null, null); } - public void changeFloodLightMode(String localCameraURL, FloodLightMode mode) throws NetatmoException { - UriBuilder uriBuilder = UriBuilder.fromUri(localCameraURL).path(PATH_COMMAND).path(SUB_PATH_FLOODLIGHTSET); - uriBuilder.queryParam("config", "%7B%22mode%22:%22" + mode.toString() + "%22%7D"); - get(uriBuilder, ApiResponse.Ok.class); + public void changeFloodLightMode(String homeId, String cameraId, FloodLightMode mode) throws NetatmoException { + UriBuilder uriBuilder = getAppUriBuilder(PATH_STATE); + String payload = String.format( + "{\"home\": {\"id\":\"%s\",\"modules\": [ {\"id\":\"%s\",\"floodlight\":\"%s\"} ]}}", homeId, cameraId, + mode.name().toLowerCase()); + post(uriBuilder, ApiResponse.Ok.class, payload, "application/json;charset=utf-8"); } public void setPersonAwayStatus(String homeId, String personId, boolean away) throws NetatmoException { diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/NetatmoConstants.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/NetatmoConstants.java index 65829a0e1..1a066b9a5 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/NetatmoConstants.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/NetatmoConstants.java @@ -119,6 +119,7 @@ public class NetatmoConstants { public static final String PATH_OAUTH = "oauth2/token"; public static final String PATH_API = "api"; public static final String PATH_COMMAND = "command"; + public static final String PATH_STATE = "setstate"; public static final String SUB_PATH_PERSON_AWAY = "setpersonsaway"; public static final String SUB_PATH_PERSON_HOME = "setpersonshome"; public static final String SUB_PATH_HOMES_DATA = "homesdata"; @@ -134,7 +135,6 @@ public class NetatmoConstants { public static final String SUB_PATH_GETEVENTS = "getevents"; public static final String SUB_PATH_PING = "ping"; public static final String SUB_PATH_CHANGESTATUS = "changestatus"; - public static final String SUB_PATH_FLOODLIGHTSET = "floodlight_set_config"; public static final String PARAM_DEVICEID = "device_id"; public static final String PARAM_MODULEID = "module_id"; public static final String PARAM_HOMEID = "home_id"; diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PresenceCapability.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PresenceCapability.java index d800dccf5..6b381782c 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PresenceCapability.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PresenceCapability.java @@ -62,6 +62,6 @@ public class PresenceCapability extends CameraCapability { } private void changeFloodlightMode(FloodLightMode mode) { - securityCapability.ifPresent(cap -> cap.changeFloodlightMode(localUrl, mode)); + securityCapability.ifPresent(cap -> cap.changeFloodlightMode(handler.getId(), mode)); } } diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/SecurityCapability.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/SecurityCapability.java index 80e0c0fbf..b488348dd 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/SecurityCapability.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/SecurityCapability.java @@ -158,14 +158,10 @@ class SecurityCapability extends RestCapability { }); } - public void changeFloodlightMode(@Nullable String localURL, FloodLightMode mode) { - if (localURL == null) { - logger.info("Changing floodlight mode can only be done on local camera."); - return; - } + public void changeFloodlightMode(String cameraId, FloodLightMode mode) { getApi().ifPresent(api -> { try { - api.changeFloodLightMode(localURL, mode); + api.changeFloodLightMode(handler.getId(), cameraId, mode); handler.expireData(); } catch (NetatmoException e) { logger.warn("Error changing Presence floodlight mode '{}' : {}", mode, e.getMessage());