From 7211154c6c1ff3412fd824b7c300200878ef5a85 Mon Sep 17 00:00:00 2001 From: pvtom Date: Sun, 24 Sep 2023 17:55:42 +0200 Subject: [PATCH] 2.1: force mode fixed --- s10m.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/s10m.c b/s10m.c index 79ad058..fcc5ad5 100644 --- a/s10m.c +++ b/s10m.c @@ -321,28 +321,28 @@ int main(int argc, char **argv) { if ((regs[70] == 0) && (regs[83] == 0)) { if (strcmp(bstate, "EMPTY")) { publish("battery/state", "EMPTY"); - strcpy(bstate, "EMPTY"); + if (!force) strcpy(bstate, "EMPTY"); } } else if ((regs[70] == 0) && (regs[83] == 100)) { if (strcmp(bstate, "FULL")) { publish("battery/state", "FULL"); - strcpy(bstate, "FULL"); + if (!force) strcpy(bstate, "FULL"); } } else if (regs[70] == 0) { if (strcmp(bstate, "PENDING")) { publish("battery/state", "PENDING"); - strcpy(bstate, "PENDING"); + if (!force) strcpy(bstate, "PENDING"); } } else { if (strcmp(bstate, "CHARGING")) { publish("battery/state", "CHARGING"); - strcpy(bstate, "CHARGING"); + if (!force) strcpy(bstate, "CHARGING"); } } } else { if (strcmp(bstate, "DISCHARGING")) { publish("battery/state", "DISCHARGING"); - strcpy(bstate, "DISCHARGING"); + if (!force) strcpy(bstate, "DISCHARGING"); } } } @@ -368,12 +368,12 @@ int main(int argc, char **argv) { if (regs[75] < 0) { if (strcmp(gstate, "IN")) { publish("grid/state", "IN"); - strcpy(gstate, "IN"); + if (!force) strcpy(gstate, "IN"); } } else { if (strcmp(gstate, "OUT")) { publish("grid/state", "OUT"); - strcpy(gstate, "OUT"); + if (!force) strcpy(gstate, "OUT"); } } }