Add envoy support to solar logger
This commit is contained in:
@@ -3,22 +3,29 @@
|
||||
#include <sqlite3.h>
|
||||
#include <string>
|
||||
|
||||
struct Row
|
||||
struct ZeverRow
|
||||
{
|
||||
time_t epochTime;
|
||||
std::int32_t watt;
|
||||
double kilowattPerHour;
|
||||
};
|
||||
|
||||
struct EnvoyRow
|
||||
{
|
||||
time_t epochTime;
|
||||
std::int32_t inverterCount;
|
||||
std::int32_t currentWatt;
|
||||
std::int64_t lifetimeWattHour;
|
||||
std::int64_t inverterTime;
|
||||
};
|
||||
|
||||
class Database {
|
||||
private:
|
||||
sqlite3 * connectionPtr;
|
||||
|
||||
std::string ToSqlInsertStatement(Row const & row) const;
|
||||
std::string ToSqlUpsertStatement(Row const & row) const;
|
||||
|
||||
public:
|
||||
bool Insert(Row & row);
|
||||
bool Insert(ZeverRow & row);
|
||||
bool Insert(EnvoyRow & row);
|
||||
|
||||
Database(std::string const & databasePath);
|
||||
~Database();
|
||||
|
||||
14
include/solar/logger/envoydata.hpp
Normal file
14
include/solar/logger/envoydata.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
struct EnvoyData
|
||||
{
|
||||
std::string type;
|
||||
std::int32_t activeCount;
|
||||
std::int64_t readingTime;
|
||||
std::int32_t wNow;
|
||||
std::int64_t whLifetime;
|
||||
|
||||
static std::optional<EnvoyData> ParseJson(std::string const & json);
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <curl/curl.h> // tested with libcurl4-openSSH
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@@ -25,9 +26,7 @@ struct ZeverData
|
||||
std::string OKmsg, ERRORmsg;
|
||||
|
||||
// Parses the data string coming from the zeverlution home.cgi webpage
|
||||
bool ParseString(const std::string & str);
|
||||
|
||||
bool FetchDataFromURL(const std::string & url, const unsigned int timeout);
|
||||
static std::optional<ZeverData> ParseString(const std::string & str);
|
||||
|
||||
ZeverData();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user