mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-06 20:51:38 +02:00
0.8.970003-zero
This commit is contained in:
parent
dab72f3777
commit
eb3df78b58
4 changed files with 53 additions and 39 deletions
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 8
|
||||
#define VERSION_PATCH 970002
|
||||
#define VERSION_PATCH 970003
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 2024 Ahoy, https://ahoydtu.de
|
||||
// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __POWERMETER_H__
|
||||
#define __POWERMETER_H__
|
||||
|
||||
#include <AsyncJson.h>
|
||||
#include <Base64.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <base64.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "SML.h"
|
||||
#include <Base64.h>
|
||||
#include <SML.h>
|
||||
#include "config/settings.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -18,7 +23,6 @@ typedef struct {
|
|||
float *Arg;
|
||||
} OBISHandler;
|
||||
|
||||
|
||||
class powermeter {
|
||||
public:
|
||||
powermeter() {
|
||||
|
@ -58,11 +62,11 @@ class powermeter {
|
|||
break;
|
||||
case 5:
|
||||
result = getPowermeterWattsTibber(logObj, group);
|
||||
if (result) {
|
||||
logObj["export"] = String(_powerMeterExport);
|
||||
logObj["import"] = String(_powerMeterImport);
|
||||
logObj["power"] = String(_powerMeter1Power);
|
||||
}
|
||||
// if (result) {
|
||||
// logObj["export"] = String(_powerMeterExport);
|
||||
// logObj["import"] = String(_powerMeterImport);
|
||||
// logObj["power"] = String(_powerMeter1Power);
|
||||
// }
|
||||
break;
|
||||
}
|
||||
if (!result) {
|
||||
|
@ -408,9 +412,7 @@ class powermeter {
|
|||
const std::list<OBISHandler> smlHandlerList{
|
||||
{{0x01, 0x00, 0x10, 0x07, 0x00, 0xff}, &smlOBISW, &_powerMeter1Power},
|
||||
{{0x01, 0x00, 0x01, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterImport},
|
||||
{{0x01, 0x00, 0x02, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterExport}
|
||||
};
|
||||
|
||||
{{0x01, 0x00, 0x02, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterExport}};
|
||||
|
||||
bool getPowermeterWattsTibber(JsonObject logObj, uint8_t group) {
|
||||
bool result = false;
|
||||
|
@ -423,8 +425,8 @@ class powermeter {
|
|||
HTTPClient http;
|
||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
http.setUserAgent("Ahoy-Agent");
|
||||
http.setConnectTimeout(500);
|
||||
http.setTimeout(500);
|
||||
http.setConnectTimeout(1000);
|
||||
http.setTimeout(1000);
|
||||
http.addHeader("Content-Type", "application/json");
|
||||
http.addHeader("Accept", "application/json");
|
||||
|
||||
|
@ -434,31 +436,32 @@ class powermeter {
|
|||
http.begin(url);
|
||||
http.addHeader("Authorization", "Basic " + auth);
|
||||
|
||||
if (http.GET() == HTTP_CODE_OK)
|
||||
{
|
||||
if (http.GET() == HTTP_CODE_OK) {
|
||||
String myString = http.getString();
|
||||
|
||||
char floatBuffer[20];
|
||||
double readVal = 0;
|
||||
|
||||
unsigned char c;
|
||||
for (int i = 0; i < http.getSize(); ++i)
|
||||
{
|
||||
for (int i = 0; i < http.getSize(); ++i) {
|
||||
c = myString[i];
|
||||
sml_states_t smlCurrentState = smlState(c);
|
||||
|
||||
switch(smlCurrentState)
|
||||
{
|
||||
switch (smlCurrentState) {
|
||||
case SML_FINAL:
|
||||
mCfg->groups[group].pmPower = _powerMeter1Power;
|
||||
mCfg->groups[group].pmPowerL1 = _powerMeter1Power / 3;
|
||||
mCfg->groups[group].pmPowerL2 = _powerMeter1Power / 3;
|
||||
mCfg->groups[group].pmPowerL3 = _powerMeter1Power / 3;
|
||||
/*mCfg->groups[group].pmPower = _powerMeterImport;
|
||||
mCfg->groups[group].pmPower = _powerMeterExport;*/
|
||||
return true;
|
||||
// TODO: Ein return an dieser Stelle verhindert das ordnungsgemäße http.end()
|
||||
result = true;
|
||||
// return true;
|
||||
break;
|
||||
case SML_LISTEND:
|
||||
// check handlers on last received list
|
||||
for (auto &handler: smlHandlerList)
|
||||
{
|
||||
for (auto &handler : smlHandlerList) {
|
||||
if (smlOBISCheck(handler.OBIS)) {
|
||||
handler.Fn(readVal);
|
||||
*handler.Arg = readVal;
|
||||
|
@ -469,7 +472,13 @@ class powermeter {
|
|||
}
|
||||
}
|
||||
http.end();
|
||||
return false;
|
||||
|
||||
logObj["P"] = mCfg->groups[group].pmPower;
|
||||
logObj["P1"] = mCfg->groups[group].pmPowerL1;
|
||||
logObj["P2"] = mCfg->groups[group].pmPowerL2;
|
||||
logObj["P3"] = mCfg->groups[group].pmPowerL3;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 2024 Ahoy, https://ahoydtu.de
|
||||
// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if defined(PLUGIN_ZEROEXPORT)
|
||||
|
||||
#ifndef __ZEROEXPORT__
|
||||
|
|
|
@ -1355,7 +1355,7 @@
|
|||
),
|
||||
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
|
||||
divRow("ACHTUNG: ",
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
),
|
||||
]),
|
||||
// Powermeter
|
||||
|
@ -1381,7 +1381,7 @@
|
|||
),
|
||||
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
|
||||
divRow("ACHTUNG: ",
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
),
|
||||
]),
|
||||
// Inverter
|
||||
|
@ -1393,7 +1393,7 @@
|
|||
),
|
||||
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
|
||||
divRow("ACHTUNG: ",
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
),
|
||||
]),
|
||||
// Battery
|
||||
|
@ -1408,7 +1408,7 @@
|
|||
),
|
||||
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
|
||||
divRow("ACHTUNG: ",
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
),
|
||||
]),
|
||||
// Advanced
|
||||
|
@ -1426,7 +1426,7 @@
|
|||
),
|
||||
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
|
||||
divRow("ACHTUNG: ",
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
),
|
||||
]),
|
||||
// Global
|
||||
|
@ -1571,7 +1571,7 @@
|
|||
modal("{#ZE_GROUP_DELETE_MODAL}: " + obj.name, html);
|
||||
|
||||
function del() {
|
||||
// TODO: Es w<EFBFBD>re gut, wenn die Defaultwerte nicht hier sondern wie in der settings.h gesetzt w<>rden.
|
||||
// TODO: Es waere gut, wenn die Defaultwerte nicht hier sondern wie in der settings.h gesetzt wuerden.
|
||||
var o = new Object();
|
||||
o.cmd = "ze_save_group";
|
||||
// General
|
||||
|
@ -1667,7 +1667,7 @@
|
|||
]));
|
||||
}
|
||||
|
||||
// TODO: Das Add sollte anders / <EFBFBD>berhaupt gel<65>st werden
|
||||
// TODO: Das Add sollte anders / ueberhaupt geloest werden
|
||||
var add = new Object();
|
||||
add.enabled = true;
|
||||
add.id = obj.groups.length;
|
||||
|
@ -1690,7 +1690,7 @@
|
|||
// TODO: Hinweis Github/Discord - Entfernen wenn erledigt
|
||||
e.append(
|
||||
divRow("ACHTUNG: ",
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
ml("a", {href: "https://discord.com/channels/984173303147155506/1211365440253726851"}, "Bitte auf Github keine Issues zu Zero eröffnen, sondern direkt im Discord melden."),
|
||||
),
|
||||
);
|
||||
if(maxGroups > obj.groups.length) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue