Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Änderungen für 1.3.0
  • Loading branch information
mgerhard74 authored Oct 11, 2024
1 parent 632096b commit ab651d2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
47 changes: 45 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ String lastMonth;
kwhstruct kwh_hist[7];
bool inAPMode,mqttStatus,hwTest;
ADC_MODE(ADC_VCC);
int switch_last = 0;

void setup(){
Serial.begin(9600,SERIAL_8E1); // Schnittstelle zu Amis-Z?er
Expand Down Expand Up @@ -273,16 +274,58 @@ void secTick() {
writeHistFileIn(x,a_result[0]);
kwh_day_out[x]=a_result[1]; // 2.8.0
writeHistFileOut(x,a_result[1]);
dow_local=dow;
dow_local=dow;
if (mon_local != mon) { // Monatswechsel
writeMonthFile(year,mon);
mon_local=mon;
}
first_frame=2; // Wochen- + Monatstabelle Energie neu erzeugen

if ((millis()/1000 > 43200) && (config.reboot0)) // Reboot wenn uptime > 12h
{
writeEvent("INFO", "sys", "Reboot uptime>12h", "");
delay(10);
ESP.restart();
}
}
}

/// Thingspeak aktualisieren
// Wifi Switch on/off
if ((config.switch_url_on != "") && (config.switch_url_off != ""))
{
signed int xsaldo;
xsaldo=(a_result[4]-a_result[5]);
unsigned int sek = (millis()/1000) % 5;

if ((xsaldo < config.switch_on) && (switch_last != 1) && (sek == 0))
{
HTTPClient http;
WiFiClient client;
http.begin(client,config.switch_url_on);
int httpCode = http.GET();
if(httpCode == HTTP_CODE_OK)
{
//writeEvent("INFO", "sys", "Switch on Url sent", "");
}
http.end();
switch_last = 1;
}
if ((xsaldo > config.switch_off) && (switch_last != 2) && (sek == 0))
{
HTTPClient http;
WiFiClient client;
http.begin(client,config.switch_url_off);
int httpCode = http.GET();
if(httpCode == HTTP_CODE_OK)
{
//writeEvent("INFO", "sys", "Switch off Url sent", "");
}
http.end();
switch_last = 2;
}
}

// Thingspeak aktualisieren
if (config.thingspeak_aktiv && things_cycle >= config.thingspeak_iv && new_data && valid==5) {
things_cycle=0;
thingspeak_watch++;
Expand Down
8 changes: 7 additions & 1 deletion src/proj.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "LittleFS.h"
#include <ESP8266mDNS.h>
#include <EEPROM.h>
#include <ESP8266HTTPClient.h>

/// Debug Einstellungen:
/// DEBUGHW 0 keine Ausgaben
Expand All @@ -25,7 +26,7 @@
#define AP_PIN 14
//#define OTA
//#define STROMPREIS
#define VERSION "1.2.9"
#define VERSION "1.3.0"
#define APP_NAME "Amis"
extern String dbg_string;
extern char dbg[128];
Expand Down Expand Up @@ -59,6 +60,11 @@ struct strConfig {
unsigned rest_var;
signed rest_ofs;
bool rest_neg;
bool reboot0;
signed switch_on;
signed switch_off;
String switch_url_on;
String switch_url_off;
};
struct kwhstruct {
unsigned kwh_in;
Expand Down
5 changes: 5 additions & 0 deletions src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ void generalInit() {
config.rest_var=json[F("rest_var")].as<int>();
config.rest_ofs=json[F("rest_ofs")].as<int>();
config.rest_neg=json[F("rest_neg")].as<bool>();
config.reboot0=json[F("reboot0")].as<bool>();
config.switch_on=json[F("switch_on")].as<int>();
config.switch_off=json[F("switch_off")].as<int>();
config.switch_url_on=json[F("switch_url_on")].as<String>();
config.switch_url_off=json[F("switch_url_off")].as<String>();
}

void histInit () {
Expand Down

0 comments on commit ab651d2

Please sign in to comment.