Feature: Allow setting of an inverter limit of 0% and 0W
Thanks to @madmartin in #1270
This commit is contained in:
parent
1d9c91c0fb
commit
b4ead9d6ec
@ -102,3 +102,5 @@
|
||||
#define REACHABLE_THRESHOLD 2U
|
||||
|
||||
#define LED_BRIGHTNESS 100U
|
||||
|
||||
#define MAX_INVERTER_LIMIT 2250
|
||||
@ -6,6 +6,7 @@
|
||||
#include "MqttHandleInverter.h"
|
||||
#include "MqttSettings.h"
|
||||
#include "NetworkSettings.h"
|
||||
#include "defaults.h"
|
||||
|
||||
MqttHandleHassClass MqttHandleHass;
|
||||
|
||||
@ -59,11 +60,11 @@ void MqttHandleHassClass::publishConfig()
|
||||
publishInverterButton(inv, "Turn Inverter On", "mdi:power-plug", "config", "", "cmd/power", "1");
|
||||
publishInverterButton(inv, "Restart Inverter", "", "config", "restart", "cmd/restart", "1");
|
||||
|
||||
publishInverterNumber(inv, "Limit NonPersistent Relative", "mdi:speedometer", "config", "cmd/limit_nonpersistent_relative", "status/limit_relative", "%");
|
||||
publishInverterNumber(inv, "Limit Persistent Relative", "mdi:speedometer", "config", "cmd/limit_persistent_relative", "status/limit_relative", "%");
|
||||
publishInverterNumber(inv, "Limit NonPersistent Relative", "mdi:speedometer", "config", "cmd/limit_nonpersistent_relative", "status/limit_relative", "%", 0, 100);
|
||||
publishInverterNumber(inv, "Limit Persistent Relative", "mdi:speedometer", "config", "cmd/limit_persistent_relative", "status/limit_relative", "%", 0, 100);
|
||||
|
||||
publishInverterNumber(inv, "Limit NonPersistent Absolute", "mdi:speedometer", "config", "cmd/limit_nonpersistent_absolute", "status/limit_absolute", "W", 10, 2250);
|
||||
publishInverterNumber(inv, "Limit Persistent Absolute", "mdi:speedometer", "config", "cmd/limit_persistent_absolute", "status/limit_absolute", "W", 10, 2250);
|
||||
publishInverterNumber(inv, "Limit NonPersistent Absolute", "mdi:speedometer", "config", "cmd/limit_nonpersistent_absolute", "status/limit_absolute", "W", 0, MAX_INVERTER_LIMIT);
|
||||
publishInverterNumber(inv, "Limit Persistent Absolute", "mdi:speedometer", "config", "cmd/limit_persistent_absolute", "status/limit_absolute", "W", 0, MAX_INVERTER_LIMIT);
|
||||
|
||||
publishInverterBinarySensor(inv, "Reachable", "status/reachable", "1", "0");
|
||||
publishInverterBinarySensor(inv, "Producing", "status/producing", "1", "0");
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
#include "WebApi_limit.h"
|
||||
#include "WebApi.h"
|
||||
#include "WebApi_errors.h"
|
||||
#include "defaults.h"
|
||||
#include "helper.h"
|
||||
#include <AsyncJson.h>
|
||||
#include <Hoymiles.h>
|
||||
|
||||
@ -112,10 +114,10 @@ void WebApiLimitClass::onLimitPost(AsyncWebServerRequest* request)
|
||||
return;
|
||||
}
|
||||
|
||||
if (root["limit_value"].as<uint16_t>() == 0 || root["limit_value"].as<uint16_t>() > 2250) {
|
||||
retMsg["message"] = "Limit must between 1 and 2250!";
|
||||
if (root["limit_value"].as<uint16_t>() > MAX_INVERTER_LIMIT) {
|
||||
retMsg["message"] = "Limit must between 0 and " STR(MAX_INVERTER_LIMIT) "!";
|
||||
retMsg["code"] = WebApiError::LimitInvalidLimit;
|
||||
retMsg["param"]["max"] = 2250;
|
||||
retMsg["param"]["max"] = MAX_INVERTER_LIMIT;
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
return;
|
||||
|
||||
@ -431,7 +431,7 @@ export default defineComponent({
|
||||
currentLimitList: {} as LimitStatus,
|
||||
targetLimitList: {} as LimitConfig,
|
||||
|
||||
targetLimitMin: 2,
|
||||
targetLimitMin: 0,
|
||||
targetLimitMax: 100,
|
||||
targetLimitTypeText: this.$t('home.Relative'),
|
||||
targetLimitType: 1,
|
||||
@ -679,11 +679,11 @@ export default defineComponent({
|
||||
onSelectType(type: number) {
|
||||
if (type == 1) {
|
||||
this.targetLimitTypeText = this.$t('home.Relative');
|
||||
this.targetLimitMin = 2;
|
||||
this.targetLimitMin = 0;
|
||||
this.targetLimitMax = 100;
|
||||
} else {
|
||||
this.targetLimitTypeText = this.$t('home.Absolute');
|
||||
this.targetLimitMin = 10;
|
||||
this.targetLimitMin = 0;
|
||||
this.targetLimitMax = (this.currentLimitList.max_power > 0 ? this.currentLimitList.max_power : 2250);
|
||||
}
|
||||
this.targetLimitType = type;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user