mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Zendure SolarFlow: support off grid mode settings
This commit is contained in:
+1
@@ -680,6 +680,7 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_BATTERY_MAXIMUM_CHARGE = "battery_maximum_charge";
|
||||
public static final String PREF_BATTERY_ALLOW_PASS_THROUGH = "battery_allow_pass_through";
|
||||
public static final String PREF_OUTPUT_POWER_GRID = "output_power_grid";
|
||||
public static final String PREF_OFFGRID_MODE = "offgrid_mode";
|
||||
|
||||
public static final String PREF_DISPLAY_ENABLED = "display_enabled";
|
||||
public static final String PREF_DISPLAY_ENABLED_ALL_DAY = "display_all_day";
|
||||
|
||||
+1
@@ -1004,6 +1004,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
addPreferenceHandlerFor(PREF_BATTERY_MAXIMUM_CHARGE);
|
||||
addPreferenceHandlerFor(PREF_BATTERY_ALLOW_PASS_THROUGH);
|
||||
addPreferenceHandlerFor(PREF_OUTPUT_POWER_GRID);
|
||||
addPreferenceHandlerFor(PREF_OFFGRID_MODE);
|
||||
|
||||
addPreferenceHandlerFor(PREF_DISPLAY_ENABLED);
|
||||
addPreferenceHandlerFor(PREF_DISPLAY_ENABLED_ALL_DAY);
|
||||
|
||||
+1
@@ -93,6 +93,7 @@ public class SolarFlowDeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
R.xml.devicesettings_battery_minimum_charge,
|
||||
R.xml.devicesettings_battery_maximum_charge,
|
||||
R.xml.devicesettings_output_power_grid,
|
||||
R.xml.devicesettings_offgrid_mode_on_off_eco
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+20
-1
@@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.zendure;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BATTERY_MAXIMUM_CHARGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BATTERY_MINIMUM_CHARGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_OFFGRID_MODE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_OUTPUT_POWER_GRID;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
@@ -58,6 +59,7 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
private int solarPower3 = -1;
|
||||
private int solarPower4 = -1;
|
||||
private int gridOffPower = -1;
|
||||
private int gridOffMode = -1;
|
||||
private int outputHomePower = -1;
|
||||
private int minSoc = -1;
|
||||
private int socSet = -1;
|
||||
@@ -178,6 +180,15 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
if (outputLimit > 2400) outputLimit = 2400;
|
||||
sendWriteProperty("outputLimit", outputLimit);
|
||||
}
|
||||
case PREF_OFFGRID_MODE -> {
|
||||
String offGridMode = devicePrefs.getString(PREF_OFFGRID_MODE, "off");
|
||||
int gridOffMode = switch (offGridMode) {
|
||||
case "on" -> 0;
|
||||
case "eco" -> 1;
|
||||
default -> 2;
|
||||
};
|
||||
sendWriteProperty("gridOffMode", gridOffMode);
|
||||
}
|
||||
default -> LOG.warn("Unknown config changed: {}", config);
|
||||
}
|
||||
}
|
||||
@@ -198,7 +209,6 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void sendMessage(JSONObject message) {
|
||||
@@ -222,6 +232,9 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
if (properties.has("gridOffPower")) {
|
||||
gridOffPower = properties.getInt("gridOffPower");
|
||||
}
|
||||
if (properties.has("gridOffMode")) {
|
||||
gridOffMode = properties.getInt("gridOffMode");
|
||||
}
|
||||
if (properties.has("outputHomePower")) {
|
||||
outputHomePower = properties.getInt("outputHomePower");
|
||||
}
|
||||
@@ -306,6 +319,12 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
devicePrefsEdit.putString(PREF_BATTERY_MINIMUM_CHARGE, String.valueOf(minSoc));
|
||||
devicePrefsEdit.putString(PREF_BATTERY_MAXIMUM_CHARGE, String.valueOf(socSet));
|
||||
devicePrefsEdit.putString(PREF_OUTPUT_POWER_GRID, String.valueOf(outputLimit));
|
||||
String offGridMode = switch (gridOffMode) {
|
||||
case 0 -> "on";
|
||||
case 1 -> "eco";
|
||||
default -> "off";
|
||||
};
|
||||
devicePrefsEdit.putString(PREF_OFFGRID_MODE, offGridMode);
|
||||
devicePrefsEdit.apply();
|
||||
devicePrefsEdit.commit();
|
||||
}
|
||||
|
||||
@@ -5316,4 +5316,15 @@
|
||||
<item>pound</item>
|
||||
<item>stone</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="offgrid_mode_on_off_eco">
|
||||
<item>@string/on</item>
|
||||
<item>@string/off</item>
|
||||
<item>@string/eco</item>
|
||||
</string-array>
|
||||
<string-array name="offgrid_mode_on_off_eco_values">
|
||||
<item>on</item>
|
||||
<item>off</item>
|
||||
<item>eco</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -4483,4 +4483,6 @@
|
||||
<string name="internet_helper_banglejs_permission_missing_title">Permission missing</string>
|
||||
<string name="internet_helper_banglejs_permission_missing_text">Access to the Bangle.js app loader is currently not allowed by your settings. Please go to the internet helper settings in the external integrations settings to enable it.</string>
|
||||
<string name="devicetype_solarflow">SolarFlow</string>
|
||||
<string name="eco">Eco</string>
|
||||
<string name="prefs_title_offgrid_mode">Off-grid mode</string>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<ListPreference
|
||||
android:defaultValue="@string/p_off"
|
||||
android:entries="@array/offgrid_mode_on_off_eco"
|
||||
android:entryValues="@array/offgrid_mode_on_off_eco_values"
|
||||
android:key="offgrid_mode"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
android:title="@string/prefs_title_offgrid_mode" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Reference in New Issue
Block a user