Skip to content

Commit

Permalink
Add Key/Value fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard committed Apr 2, 2024
1 parent 39c113e commit 43591ee
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ Receive:
decoded:
`<Imax [A]>,<aktual Power [kW]>,<Status>,<aktual Work [kW/h]>,<Sum Work [W/h]>,<charge-time>`

### Fetch actual Values and State in key=value pair

This includes the "Status" as an Integer Value, too.

`http:<your-ip>/fetchkv`

Receive:
```
Imax=16 A
ActPower=11 kW
Status=C2
IntStatus=194
ActWork=0.92 kW/h
SumWork=2926 W/h
ChargeTime=00:15:02
```

### Set value Imax

`http:<your-ip>/fetch?imax=xx` (xx= 6,8,10,12,14,16)
Expand Down
20 changes: 20 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,13 @@ static String readString(File s)
return ret;
}

int getIntStatus()
{
long intValue = strtol(ABL_rx_status.c_str(), NULL, 16);
return intValue;
}


// -------------------- WEBSERVER ----------------------------------------------
// -----------------------------------------------------------------------------
//
Expand Down Expand Up @@ -1066,6 +1073,19 @@ void initWebServer()
//debug_println("server.on /fetch: "+ s);
});

// fetch GET
server.on("/fetchkv", HTTP_GET, [](AsyncWebServerRequest *request)
{
String s = "Imax=" + String(ABL_rx_Ipwm) + " A \n" +
"ActPower=" + String(ABL_rx_kW) + " kW\n" +
"Status=" + String(ABL_rx_status) + "\n" +
"IntStatus=" + String(getIntStatus()) + "\n" +
"ActWork=" + String(ABL_rx_Wh/1000.0) + " kW/h\n" +
"SumWork=" + String(ABL_Wh_Sum_akt) + " W/h\n" +
"ChargeTime=" + String(ABL_sChargeTime) + "\n";
request->send(200, "text/plain", s);
});

// config.txt GET
server.on("/config.txt", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/config.txt", "text/html", false);
Expand Down

0 comments on commit 43591ee

Please sign in to comment.