Skip to content

Commit d0b918e

Browse files
authored
[fronius] Verify battery control time of use successfully set (openhab#18131)
Signed-off-by: Florian Hotze <[email protected]>
1 parent 8f77e16 commit d0b918e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/FroniusBatteryControl.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.jetty.client.HttpClient;
2727
import org.eclipse.jetty.http.HttpHeader;
2828
import org.eclipse.jetty.http.HttpMethod;
29+
import org.openhab.binding.fronius.internal.api.dto.inverter.PostConfigResponse;
2930
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.ScheduleType;
3031
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.TimeOfUseRecord;
3132
import org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.TimeOfUseRecords;
@@ -120,8 +121,13 @@ private void setTimeOfUse(TimeOfUseRecords records)
120121

121122
// Set the time of use settings
122123
String json = gson.toJson(records);
123-
FroniusHttpUtil.executeUrl(HttpMethod.POST, timeOfUseUri.toString(), headers,
124+
String responseString = FroniusHttpUtil.executeUrl(HttpMethod.POST, timeOfUseUri.toString(), headers,
124125
new ByteArrayInputStream(json.getBytes()), "application/json", API_TIMEOUT);
126+
PostConfigResponse response = gson.fromJson(responseString, PostConfigResponse.class);
127+
if (!response.writeSuccess().contains("timeofuse")) {
128+
LOGGER.debug("{}", responseString);
129+
throw new FroniusCommunicationException("Failed to write configuration to inverter");
130+
}
125131
LOGGER.trace("Time of Use settings set successfully");
126132
}
127133

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2010-2025 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.fronius.internal.api.dto.inverter;
14+
15+
import java.util.List;
16+
17+
/**
18+
* Record representing the response of a POST request to a <code>/config</code> endpoint.
19+
*
20+
* @author Florian Hotze - Initial contribution
21+
*/
22+
public record PostConfigResponse(List<String> errors, List<String> permissionFailure, List<String> unknownNodes,
23+
List<String> validationErrors, List<String> writeFailure, List<String> writeSuccess) {
24+
}

0 commit comments

Comments
 (0)