mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-06 20:34:35 +01:00
[fronius] Verify battery control time of use successfully set (#18131)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
parent
8f77e16e18
commit
d0b918e448
@ -26,6 +26,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpMethod;
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
|
import org.openhab.binding.fronius.internal.api.dto.inverter.PostConfigResponse;
|
||||||
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.ScheduleType;
|
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.ScheduleType;
|
||||||
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.TimeOfUseRecord;
|
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.TimeOfUseRecord;
|
||||||
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.TimeOfUseRecords;
|
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.TimeOfUseRecords;
|
||||||
@ -120,8 +121,13 @@ public class FroniusBatteryControl {
|
|||||||
|
|
||||||
// Set the time of use settings
|
// Set the time of use settings
|
||||||
String json = gson.toJson(records);
|
String json = gson.toJson(records);
|
||||||
FroniusHttpUtil.executeUrl(HttpMethod.POST, timeOfUseUri.toString(), headers,
|
String responseString = FroniusHttpUtil.executeUrl(HttpMethod.POST, timeOfUseUri.toString(), headers,
|
||||||
new ByteArrayInputStream(json.getBytes()), "application/json", API_TIMEOUT);
|
new ByteArrayInputStream(json.getBytes()), "application/json", API_TIMEOUT);
|
||||||
|
PostConfigResponse response = gson.fromJson(responseString, PostConfigResponse.class);
|
||||||
|
if (!response.writeSuccess().contains("timeofuse")) {
|
||||||
|
LOGGER.debug("{}", responseString);
|
||||||
|
throw new FroniusCommunicationException("Failed to write configuration to inverter");
|
||||||
|
}
|
||||||
LOGGER.trace("Time of Use settings set successfully");
|
LOGGER.trace("Time of Use settings set successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2025 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.fronius.internal.api.dto.inverter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Record representing the response of a POST request to a <code>/config</code> endpoint.
|
||||||
|
*
|
||||||
|
* @author Florian Hotze - Initial contribution
|
||||||
|
*/
|
||||||
|
public record PostConfigResponse(List<String> errors, List<String> permissionFailure, List<String> unknownNodes,
|
||||||
|
List<String> validationErrors, List<String> writeFailure, List<String> writeSuccess) {
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user