Browse Source

Add files via upload

Configuration added for SML/OBIS
pull/1080/head
oberfritze 2 years ago
committed by GitHub
parent
commit
4cda315aee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/config/config.h
  2. 29
      src/config/settings.h

6
src/config/config.h

@ -111,11 +111,9 @@
#define NTP_REFRESH_INTERVAL 12 * 3600 * 1000
#define AHOY_SML_OBIS_SUPPORT
#ifdef AHOY_SML_OBIS_SUPPORT
#define AHOY_CHARTDATA_HDR "Time, AC Power, Grid Power"
#else
#define AHOY_CHARTDATA_WITH_GRID_HDR "Time, AC Power, Grid Power"
#define AHOY_CHARTDATA_HDR "Time, AC Power"
#endif
// #define AHOY_MQTT_SUPPORT

29
src/config/settings.h

@ -151,6 +151,10 @@ typedef struct {
uint8_t disp_dc;
} display_t;
typedef struct {
bool ir_connected;
} cfgSML_t;
typedef struct {
display_t display;
} plugins_t;
@ -164,6 +168,7 @@ typedef struct {
cfgMqtt_t mqtt;
cfgLed_t led;
cfgInst_t inst;
cfgSML_t sml_obis;
plugins_t plugin;
bool valid;
} settings_t;
@ -255,8 +260,13 @@ class settings {
if(root.containsKey(F("ntp"))) jsonNtp(root[F("ntp")]);
if(root.containsKey(F("sun"))) jsonSun(root[F("sun")]);
if(root.containsKey(F("serial"))) jsonSerial(root[F("serial")]);
#ifdef AHOY_MQTT_SUPPORT
if(root.containsKey(F("mqtt"))) jsonMqtt(root[F("mqtt")]);
#endif
if(root.containsKey(F("led"))) jsonLed(root[F("led")]);
#ifdef AHOY_SML_OBIS_SUPPORT
if(root.containsKey(F("sml_obis"))) jsonSML(root[F("sml_obis")]);
#endif
if(root.containsKey(F("plugin"))) jsonPlugin(root[F("plugin")]);
if(root.containsKey(F("inst"))) jsonInst(root[F("inst")]);
}
@ -279,8 +289,13 @@ class settings {
jsonNtp(root.createNestedObject(F("ntp")), true);
jsonSun(root.createNestedObject(F("sun")), true);
jsonSerial(root.createNestedObject(F("serial")), true);
#ifdef AHOY_MQTT_SUPPORT
jsonMqtt(root.createNestedObject(F("mqtt")), true);
#endif
jsonLed(root.createNestedObject(F("led")), true);
#ifdef AHOY_SML_OBIS_SUPPORT
jsonSML(root.createNestedObject(F("sml_obis")), true);
#endif
jsonPlugin(root.createNestedObject(F("plugin")), true);
jsonInst(root.createNestedObject(F("inst")), true);
@ -388,6 +403,8 @@ class settings {
memset(&mCfg.inst, 0, sizeof(cfgInst_t));
mCfg.sml_obis.ir_connected = false;
mCfg.plugin.display.pwrSaveAtIvOffline = false;
mCfg.plugin.display.contrast = 60;
mCfg.plugin.display.pxShift = true;
@ -501,6 +518,7 @@ class settings {
}
}
#ifdef AHOY_MQTT_SUPPORT
void jsonMqtt(JsonObject obj, bool set = false) {
if(set) {
obj[F("broker")] = mCfg.mqtt.broker;
@ -519,6 +537,7 @@ class settings {
getChar(obj, F("topic"), mCfg.mqtt.topic, MQTT_TOPIC_LEN);
}
}
#endif
void jsonLed(JsonObject obj, bool set = false) {
if(set) {
@ -532,6 +551,16 @@ class settings {
}
}
#ifdef AHOY_SML_OBIS_SUPPORT
void jsonSML(JsonObject obj, bool set = false) {
if(set) {
obj[F("show")] = mCfg.sml_obis.ir_connected;
} else {
getVal<bool>(obj, F("show"), &mCfg.sml_obis.ir_connected);
}
}
#endif
void jsonPlugin(JsonObject obj, bool set = false) {
if(set) {
JsonObject disp = obj.createNestedObject("disp");

Loading…
Cancel
Save