mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[fronius] Thing Actions: Add string overrides for actions requiring enum (#19367)
This eases use of these actions from script environments. Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
@@ -206,6 +206,7 @@ The `ScheduleType` enum has the following members:
|
||||
- `DISCHARGE_MAX`
|
||||
|
||||
Its full class name is `org.openhab.binding.fronius.internal.api.dto.inverter.batterycontrol.ScheduleType`.
|
||||
You can also provide the name of the enum member as string and the binding will parse the enum member from it.
|
||||
|
||||
All methods return a boolean value indicating whether the action was successful.
|
||||
|
||||
@@ -222,9 +223,11 @@ froniusInverterActions.resetBatteryControl();
|
||||
froniusInverterActions.addHoldBatteryChargeSchedule(time.toZDT('18:00'), time.toZDT('22:00'));
|
||||
froniusInverterActions.addForcedBatteryChargingSchedule(time.toZDT('22:00'), time.toZDT('23:59'), Quantity('5 kW'));
|
||||
froniusInverterActions.addForcedBatteryChargingSchedule(time.toZDT('00:00'), time.toZDT('06:00'), Quantity('5 kW'));
|
||||
froniusInverterActions.addForcesBatteryDischargingSchedule(time.toZDT('07:00'), time.toZDT('09:00'));
|
||||
froniusInverterActions.addForcedBatteryDischargingSchedule(time.toZDT('07:00'), time.toZDT('09:00'));
|
||||
froniusInverterActions.addPreventBatteryChargingSchedule(time.toZDT('09:00'), time.toZDT('12:00'));
|
||||
|
||||
froniusInverterActions.addSchedule(time.toZDT('10:00'), time.toZDT('11:00'), 'DISCHARGE_MAX', Quantity('500 W'));
|
||||
|
||||
froniusInverterActions.setBackupReservedBatteryCapacity(50);
|
||||
```
|
||||
|
||||
|
||||
+20
-5
@@ -69,11 +69,21 @@ public class FroniusSymoInverterActions implements ThingActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean addSchedule(ThingActions actions, LocalTime from, LocalTime until, String scheduleType,
|
||||
QuantityType<Power> power) {
|
||||
return addSchedule(actions, from, until, ScheduleType.valueOf(scheduleType), power);
|
||||
}
|
||||
|
||||
public static boolean addSchedule(ThingActions actions, ZonedDateTime from, ZonedDateTime until,
|
||||
ScheduleType scheduleType, QuantityType<Power> power) {
|
||||
return addSchedule(actions, from.toLocalTime(), until.toLocalTime(), scheduleType, power);
|
||||
}
|
||||
|
||||
public static boolean addSchedule(ThingActions actions, ZonedDateTime from, ZonedDateTime until,
|
||||
String scheduleType, QuantityType<Power> power) {
|
||||
return addSchedule(actions, from.toLocalTime(), until.toLocalTime(), ScheduleType.valueOf(scheduleType), power);
|
||||
}
|
||||
|
||||
public static boolean holdBatteryCharge(ThingActions actions) {
|
||||
if (actions instanceof FroniusSymoInverterActions froniusSymoInverterActions) {
|
||||
return froniusSymoInverterActions.holdBatteryCharge();
|
||||
@@ -228,11 +238,6 @@ public class FroniusSymoInverterActions implements ThingActions {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addSchedule(ZonedDateTime from, ZonedDateTime until, ScheduleType scheduleType,
|
||||
QuantityType<Power> power) {
|
||||
return addSchedule(from.toLocalTime(), until.toLocalTime(), scheduleType, power);
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/actions.add-schedule.label", description = "@text/actions.add-schedule.description")
|
||||
public @ActionOutput(type = "boolean", label = "Success") boolean addSchedule(
|
||||
@ActionInput(name = "from", label = "@text/actions.from.label", description = "@text/actions.from.description", required = true) LocalTime from,
|
||||
@@ -242,6 +247,16 @@ public class FroniusSymoInverterActions implements ThingActions {
|
||||
return addSchedule(from, until, ScheduleType.valueOf(scheduleType), power);
|
||||
}
|
||||
|
||||
public boolean addSchedule(ZonedDateTime from, ZonedDateTime until, ScheduleType scheduleType,
|
||||
QuantityType<Power> power) {
|
||||
return addSchedule(from.toLocalTime(), until.toLocalTime(), scheduleType, power);
|
||||
}
|
||||
|
||||
public boolean addSchedule(ZonedDateTime from, ZonedDateTime until, String scheduleType,
|
||||
QuantityType<Power> power) {
|
||||
return addSchedule(from.toLocalTime(), until.toLocalTime(), ScheduleType.valueOf(scheduleType), power);
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/actions.hold-battery-charge.label", description = "@text/actions.hold-battery-charge.description")
|
||||
public @ActionOutput(type = "boolean", label = "Success") boolean holdBatteryCharge() {
|
||||
FroniusBatteryControl batteryControl = getBatteryControl();
|
||||
|
||||
Reference in New Issue
Block a user