Skip to content

Commit

Permalink
Feature: OneMoreThing Step II
Browse files Browse the repository at this point in the history
Feature: OneMoreThing Step II
  • Loading branch information
Robert-Schimanek committed Sep 23, 2024
1 parent 65ff4be commit a18c29b
Show file tree
Hide file tree
Showing 45 changed files with 296 additions and 1,438 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ logs/device-monitor*.log
platformio_override.ini
.DS_Store
platformio_override.ini
/webapp/src/Hoywei-Turbo-WebApp
2 changes: 1 addition & 1 deletion Hoywei-Turbo
15 changes: 11 additions & 4 deletions include/WebApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
#include <ESPAsyncWebServer.h>
#include <TaskSchedulerDeclarations.h>

#include "WebApi_PriceProvider.h"

class WebApiClass {

friend class HoyweiWebApiClass;

public:
WebApiClass();
void init(Scheduler& scheduler);
Expand Down Expand Up @@ -69,9 +74,6 @@ class WebApiClass {
WebApiNtpClass _webApiNtp;
WebApiPowerClass _webApiPower;
WebApiPowerMeterClass _webApiPowerMeter;
WebApiPowerMeterClass _webApiPowerMeterInverter;
WebApiPowerMeterClass _webApiPowerMeterCharger;
WebApiPowerMeterClass _webApiPowerMeterSolar;
WebApiPowerLimiterClass _webApiPowerLimiter;
WebApiPrometheusClass _webApiPrometheus;
WebApiSecurityClass _webApiSecurity;
Expand All @@ -84,6 +86,11 @@ class WebApiClass {
WebApiHuaweiClass _webApiHuaweiClass;
WebApiWsHuaweiLiveClass _webApiWsHuaweiLive;
WebApiWsBatteryLiveClass _webApiWsBatteryLive;

//WebApiPowerMeterClass _webApiPowerMeterInverter;
//WebApiPowerMeterClass _webApiPowerMeterCharger;
//WebApiPowerMeterClass _webApiPowerMeterSolar;
//WebApiPriceProviderClass _webApiPriceProvider;
};

extern WebApiClass WebApi;
// extern WebApiClass WebApi;
14 changes: 4 additions & 10 deletions src/WebApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

WebApiClass::WebApiClass()
: _server(HTTP_PORT),
_webApiPowerMeter(PowerMeterSource::HOME,"/api/powermeter"),
_webApiPowerMeterInverter(PowerMeterSource::INVERTER_BATTERY,"/api/powermeterinverter"),
_webApiPowerMeterCharger(PowerMeterSource::CHARGER,"/api/powermetercharger"),
_webApiPowerMeterSolar(PowerMeterSource::INVERTER_PV,"/api/powermetersolar")
_webApiPowerMeter(PowerMeterSource::HOME,"/api/powermeter")
{
}

Expand Down Expand Up @@ -41,9 +38,6 @@ void WebApiClass::init(Scheduler& scheduler)
_webApiWsLive.init(_server, scheduler);
_webApiBattery.init(_server, scheduler);
_webApiPowerMeter.init(_server, scheduler);
_webApiPowerMeterInverter.init(_server, scheduler);
_webApiPowerMeterCharger.init(_server, scheduler);
_webApiPowerMeterSolar.init(_server, scheduler);
_webApiPowerLimiter.init(_server, scheduler);
_webApiWsVedirectLive.init(_server, scheduler);
_webApiVedirect.init(_server, scheduler);
Expand Down Expand Up @@ -109,7 +103,7 @@ bool WebApiClass::parseRequestData(AsyncWebServerRequest* request, AsyncJsonResp
if (!request->hasParam("data", true)) {
retMsg["message"] = "No values found!";
retMsg["code"] = WebApiError::GenericNoValueFound;
WebApi.sendJsonResponse(request, response, __FUNCTION__, __LINE__);
sendJsonResponse(request, response, __FUNCTION__, __LINE__);
return false;
}

Expand All @@ -118,7 +112,7 @@ bool WebApiClass::parseRequestData(AsyncWebServerRequest* request, AsyncJsonResp
if (error) {
retMsg["message"] = "Failed to parse data!";
retMsg["code"] = WebApiError::GenericParseError;
WebApi.sendJsonResponse(request, response, __FUNCTION__, __LINE__);
sendJsonResponse(request, response, __FUNCTION__, __LINE__);
return false;
}

Expand Down Expand Up @@ -155,4 +149,4 @@ bool WebApiClass::sendJsonResponse(AsyncWebServerRequest* request, AsyncJsonResp
return ret_val;
}

WebApiClass WebApi;
//WebApiClass WebApi;
2 changes: 1 addition & 1 deletion src/WebApi_Huawei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <HoyweiConfiguration.h>
#include "MessageOutput.h"
#include "HoyweiPinMapping.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include <AsyncJson.h>
#include <Hoymiles.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <HoyweiConfiguration.h>
#include <HoyweiMqttHandleBatteryHass.h>
#include <HoyweiMqttHandlePowerLimiterHass.h>
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_battery.h"
#include "WebApi_errors.h"
#include "helper.h"
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "WebApi_config.h"
#include <HoyweiConfiguration.h>
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include <AsyncJson.h>
#include <LittleFS.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Display_Graphic.h"
#include "HoyweiPinMapping.h"
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "helper.h"
#include <AsyncJson.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_devinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2022-2024 Thomas Basler and others
*/
#include "WebApi_devinfo.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include <AsyncJson.h>
#include <Hoymiles.h>
#include <ctime>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_dtu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
#include "WebApi_dtu.h"
#include <HoyweiConfiguration.h>
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include <AsyncJson.h>
#include <Hoymiles.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_eventlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2022-2024 Thomas Basler and others
*/
#include "WebApi_eventlog.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include <AsyncJson.h>
#include <Hoymiles.h>

Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <HoyweiConfiguration.h>
#include "Update.h"
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "helper.h"
#include <AsyncJson.h>
#include "esp_partition.h"
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_gridprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2022-2024 Thomas Basler and others
*/
#include "WebApi_gridprofile.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include <AsyncJson.h>
#include <Hoymiles.h>

Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_inverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "WebApi_inverter.h"
#include <HoyweiConfiguration.h>
#include "MqttHandleHass.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "defaults.h"
#include "helper.h"
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_limit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2022-2024 Thomas Basler and others
*/
#include "WebApi_limit.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "defaults.h"
#include "helper.h"
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_maintenance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "WebApi_maintenance.h"
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include <AsyncJson.h>

Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "MqttHandleVedirectHass.h"
#include "MqttHandleVedirect.h"
#include "MqttSettings.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "helper.h"
#include "PowerLimiter.h"
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "WebApi_network.h"
#include <HoyweiConfiguration.h>
#include "NetworkSettings.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "helper.h"
#include <AsyncJson.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_ntp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <HoyweiConfiguration.h>
#include "NtpSettings.h"
#include "SunPosition.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "helper.h"
#include <AsyncJson.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2022-2024 Thomas Basler and others
*/
#include "WebApi_power.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include <AsyncJson.h>
#include <Hoymiles.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_powerlimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <HoyweiConfiguration.h>
#include <HoyweiMqttHandlePowerLimiterHass.h>
#include <PowerLimiters.h>
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "helper.h"
#include "WebApi_errors.h"

Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_powermeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <PowerMeters.h>
#include "PowerMeterHttpJson.h"
#include "PowerMeterHttpSml.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "helper.h"


Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_prometheus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <HoyweiConfiguration.h>
#include "MessageOutput.h"
#include "NetworkSettings.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include <Hoymiles.h>
#include "__compiled_constants.h"

Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
#include "WebApi_security.h"
#include <HoyweiConfiguration.h>
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "helper.h"
#include <AsyncJson.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_sysstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <HoyweiConfiguration.h>
#include "NetworkSettings.h"
#include "HoyweiPinMapping.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "__compiled_constants.h"
#include <AsyncJson.h>
#include <CpuTemperature.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_vedirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "ArduinoJson.h"
#include "AsyncJson.h"
#include <HoyweiConfiguration.h>
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "WebApi_errors.h"
#include "helper.h"
#include <HoyweiMqttHandlePowerLimiterHass.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_ws_Huawei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <HoyweiHuaweiCan.h>
#include "MessageOutput.h"
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "defaults.h"

WebApiWsHuaweiLiveClass::WebApiWsHuaweiLiveClass()
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_ws_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <HoyweiConfiguration.h>
#include <HoyweiBattery.h>
#include "MessageOutput.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "defaults.h"
#include "Utils.h"

Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_ws_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "WebApi_ws_console.h"
#include <HoyweiConfiguration.h>
#include "MessageOutput.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "defaults.h"

WebApiWsConsoleClass::WebApiWsConsoleClass()
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_ws_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "Datastore.h"
#include "MessageOutput.h"
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include <HoyweiBattery.h>
#include <HoyweiHuaweiCan.h>
#include <PowerMeters.h>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_ws_vedirect_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <HoyweiConfiguration.h>
#include "MessageOutput.h"
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "defaults.h"
#include <PowerLimiters.h>
#include "VictronMppt.h"
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "Scheduler.h"
#include "SunPosition.h"
#include "Utils.h"
#include "WebApi.h"
#include "HoyweiWebApi.h"
#include "PowerMeter.h"
#include <PowerMeters.h>
#include <PowerLimiters.h>
Expand Down Expand Up @@ -207,7 +207,7 @@ void setup()

Battery.init(scheduler);

//OneMoreThing.init(scheduler); If you want to test one more thing you must uncomment this
OneMoreThing.init(scheduler); // If you want to test one more thing you must uncomment this
}

void loop()
Expand Down
2 changes: 1 addition & 1 deletion webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="apple-touch-icon" href="/favicon.png">
<link rel="manifest" href='/site.webmanifest' />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenDTU-OnBattery</title>
<title>Hoywei-Turbo</title>
</head>
<body>
<noscript>
Expand Down
Loading

0 comments on commit a18c29b

Please sign in to comment.