Skip to content

Commit

Permalink
fixes the timestamp for HA integration + startup value for dtuStateOb…
Browse files Browse the repository at this point in the history
…server
  • Loading branch information
ohAnd committed Nov 25, 2024
1 parent 4190066 commit 954686c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/dtuInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct connectionControl
{
boolean preventCloudErrors = true;
boolean dtuActiveOffToCloudUpdate = false;
boolean dtuConnectionOnline = true; // true if connection is online as valued a summary
boolean dtuConnectionOnline = false; // true if connection is online as a valued summary
uint8_t dtuConnectState = DTU_STATE_OFFLINE;
uint8_t dtuErrorState = DTU_ERROR_NO_ERROR;
uint8_t dtuTxRxState = DTU_TXRX_STATE_IDLE;
Expand Down
6 changes: 3 additions & 3 deletions include/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define VERSION "2.0.274_localDev"
#define BUILDTIME "27.10.2024 - 18:39:49"
#define BUILDTIMESTAMP "1730050789"
#define VERSION "2.0.338_localDev"
#define BUILDTIME "25.11.2024 - 11:14:29"
#define BUILDTIMESTAMP "1732529669"
8 changes: 4 additions & 4 deletions include/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "2.0.274_localDev",
"versiondate": "27.10.2024 - 18:39:49",
"linksnapshot": "https://github.com/ohAnd/dtuGateway/releases/download/snapshot/dtuGateway_snapshot_2.0.274_localDev.bin",
"link": "https://github.com/ohAnd/dtuGateway/releases/latest/download/dtuGateway_release_2.0.274_localDev.bin"
"version": "2.0.338_localDev",
"versiondate": "25.11.2024 - 11:14:29",
"linksnapshot": "https://github.com/ohAnd/dtuGateway/releases/download/snapshot/dtuGateway_snapshot_2.0.338_localDev.bin",
"link": "https://github.com/ohAnd/dtuGateway/releases/latest/download/dtuGateway_release_2.0.338_localDev.bin"
}
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ platform = espressif8266
board = esp07s
framework = arduino
monitor_speed = 115200
monitor_port = COM17
upload_port = COM17
monitor_port = COM18
upload_port = COM18
upload_speed = 921600
lib_deps =
arduino-libraries/NTPClient @ ^3.2.1
Expand Down
2 changes: 1 addition & 1 deletion src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void UserConfigManager::printConfigdata()
Serial.println(userConfig.remoteDisplayActive);

Serial.println(F("\ndisplay"));
Serial.print(F("connected: \t\t\t"));
Serial.print(F("connected type: \t\t\t"));
Serial.println(userConfig.displayConnected);
Serial.print(F("orientation: \t\t\t"));
Serial.println(userConfig.displayOrientation);
Expand Down
11 changes: 10 additions & 1 deletion src/dtuGateway.ino
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ boolean scanNetworksResult()
// }

// APIs (non REST)
String getTimeStringByTimestamp(unsigned long timestamp)
{
UnixTime stamp(1);
char buf[31];
stamp.getDateTime(timestamp - 3600);
// should have the format "2023-11-11T18:11:17+00:00"
snprintf(buf, sizeof(buf), "%04i-%02i-%02iT%02i:%02i:%02i%+03i:00", stamp.year, stamp.month, stamp.day, stamp.hour, stamp.minute, stamp.second, userConfig.timezoneOffest / 3600);
return String(buf);
}

// openhab
// send item to openhab
Expand Down Expand Up @@ -641,7 +650,7 @@ void updateValuesToMqtt(boolean haAutoDiscovery = false)
{
Serial.println("MQTT:\t\t publish data (HA autoDiscovery = " + String(haAutoDiscovery) + ")");
std::map<std::string, std::string> keyValueStore;
keyValueStore["time_stamp"] = String(dtuGlobalData.currentTimestamp).c_str();
keyValueStore["time_stamp"] = getTimeStringByTimestamp(platformData.currentNTPtime).c_str();
// grid
keyValueStore["grid_U"] = String(dtuGlobalData.grid.voltage).c_str();
keyValueStore["grid_I"] = String(dtuGlobalData.grid.current).c_str();
Expand Down

0 comments on commit 954686c

Please sign in to comment.