lower case days, hours, minutes, seconds

This commit is contained in:
Proddy
2022-11-10 22:12:10 +01:00
parent 845681b6dc
commit 57775af24b
10 changed files with 61 additions and 63 deletions

View File

@@ -98,10 +98,10 @@ const en: BaseTranslation = {
NUM_DEVICES: '{num} Device{{s}}',
NUM_TEMP_SENSORS: '{num} Temperature Sensor{{s}}',
NUM_ANALOG_SENSORS: '{num} Analog Sensor{{s}}',
NUM_DAYS: '{num} Day{{s}}',
NUM_SECONDS: '{num} Second{{s}}',
NUM_HOURS: '{num} Hour{{s}}',
NUM_MINUTES: '{num} Minute{{s}}',
NUM_DAYS: '{num} day{{s}}',
NUM_SECONDS: '{num} second{{s}}',
NUM_HOURS: '{num} hour{{s}}',
NUM_MINUTES: '{num} minute{{s}}',
APPLICATION_SETTINGS: 'Application Settings',
CUSTOMIZATION: 'Customization',
APPLICATION_RESTARTING: 'EMS-ESP is restarting',

View File

@@ -98,10 +98,10 @@ const nl: Translation = {
NUM_DEVICES: '{num} Apparaat{{en}}',
NUM_TEMP_SENSORS: '{num} Temperatuursensor{{en}}',
NUM_ANALOG_SENSORS: '{num} Analoge sensor{{en}}',
NUM_DAYS: '{num} Dag{{en}}',
NUM_SECONDS: '{num} Second{{en}}',
NUM_HOURS: '{num} Uur{{en}}',
NUM_MINUTES: '{num} Minuut{{en}}',
NUM_DAYS: '{num} dag{{en}}',
NUM_SECONDS: '{num} second{{en}}',
NUM_HOURS: '{num} uur{{en}}',
NUM_MINUTES: '{num} minuut{{en}}',
APPLICATION_SETTINGS: 'Applicatieinstellingen',
CUSTOMIZATION: 'Custom aanpassingen',
APPLICATION_RESTARTING: 'EMS-ESP herstarten',

View File

@@ -98,10 +98,10 @@ const no: Translation = {
NUM_DEVICES: '{num} Enhet{{er}}',
NUM_TEMP_SENSORS: '{num} Temperatursensor{{er}}',
NUM_ANALOG_SENSORS: '{num} Analogsensor{{er}}',
NUM_DAYS: '{num} Dag{{er}}',
NUM_SECONDS: '{num} Sekund{{er}}',
NUM_HOURS: '{num} Time{{r}}',
NUM_MINUTES: '{num} Minutt{{er}}',
NUM_DAYS: '{num} sag{{er}}',
NUM_SECONDS: '{num} sekund{{er}}',
NUM_HOURS: '{num} time{{r}}',
NUM_MINUTES: '{num} minutt{{er}}',
APPLICATION_SETTINGS: 'Innstillinger',
CUSTOMIZATION: 'Tilpasninger',
APPLICATION_RESTARTING: 'EMS-ESP restarter',

View File

@@ -98,10 +98,10 @@ const se: Translation = {
NUM_DEVICES: '{num} Enhet{{er}}',
NUM_TEMP_SENSORS: '{num} Temperatur-sensor{{er}}',
NUM_ANALOG_SENSORS: '{num} Analoga Sensor{{er}}',
NUM_DAYS: '{num} Dag{{ar}}',
NUM_SECONDS: '{num} Sekund{{er}}',
NUM_HOURS: '{num} Timmar',
NUM_MINUTES: '{num} Minut{{er}}',
NUM_DAYS: '{num} dag{{ar}}',
NUM_SECONDS: '{num} sekund{{er}}',
NUM_HOURS: '{num} timmar',
NUM_MINUTES: '{num} minut{{er}}',
APPLICATION_SETTINGS: 'Inställningar',
CUSTOMIZATION: 'Anpassa',
APPLICATION_RESTARTING: 'EMS-ESP startar om',

View File

@@ -113,7 +113,6 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
if (_state.enabled) {
// emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client");
_mqttClient.disconnect();
// onConfigUpdated();
}
break;

View File

@@ -260,8 +260,8 @@ char * Helpers::render_value(char * result, const float value, const int8_t form
result++;
}
*result++ = '.';
int32_t decimal = abs((int32_t)((value - whole) * p[format]));
*result++ = '.';
auto decimal = abs((int32_t)((value - whole) * p[format]));
for (int8_t i = 1; i < format; i++) {
if (decimal < p[i]) {
*result++ = '0'; // add leading zeros

View File

@@ -537,57 +537,18 @@ bool Mqtt::get_publish_onchange(uint8_t device_type) {
}
// MQTT onConnect - when an MQTT connect is established
// send out some inital MQTT messages
void Mqtt::on_connect() {
if (connecting_) { // prevent duplicated connections
return;
if (connecting_) {
return; // prevent duplicated connections
}
LOG_INFO("MQTT connected");
connecting_ = true;
connectcount_++;
connectcount_++; // count # reconnects. not currently used.
load_settings(); // reload MQTT settings - in case they have changes
// send info topic appended with the version information as JSON
StaticJsonDocument<EMSESP_JSON_SIZE_MEDIUM> doc;
// first time to connect
if (connectcount_ == 1) {
doc["event"] = "start";
} else {
doc["event"] = "reconnect";
}
doc["version"] = EMSESP_APP_VERSION;
#ifndef EMSESP_STANDALONE
if (WiFi.status() == WL_CONNECTED) {
doc["connection"] = "WiFi";
doc["hostname"] = WiFi.getHostname();
doc["SSID"] = WiFi.SSID();
doc["BSSID"] = WiFi.BSSIDstr();
doc["RSSI"] = WiFi.RSSI();
doc["MAC"] = WiFi.macAddress();
doc["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask());
doc["IPv4 gateway"] = uuid::printable_to_string(WiFi.gatewayIP());
doc["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP());
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
}
} else if (EMSESP::system_.ethernet_connected()) {
doc["connection"] = "Ethernet";
doc["hostname"] = ETH.getHostname();
doc["MAC"] = ETH.macAddress();
doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask());
doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP());
doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP());
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6());
}
}
#endif
publish(F_(info), doc.as<JsonObject>()); // topic called "info"
if (ha_enabled_) {
queue_unsubscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");
EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any
@@ -595,7 +556,8 @@ void Mqtt::on_connect() {
ha_climate_reset(true);
} else {
// with disabled HA we subscribe and the broker sends all stored HA-emsesp-configs.
// In line 272 they are removed. If HA is enabled the subscriptions are removed.
// Around line 272 they are removed (search for "// remove HA topics if we don't use discover")
// If HA is enabled the subscriptions are removed.
// As described in the doc (https://emsesp.github.io/docs/#/Troubleshooting?id=home-assistant):
// disable HA, wait 5 minutes (to allow the broker to send all), than reenable HA again.
queue_subscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");

View File

@@ -535,6 +535,40 @@ void System::loop() {
#endif
}
// send MQTT info topic appended with the version information as JSON, as a retained flag
void System::send_info_mqtt(const char * event_str) {
StaticJsonDocument<EMSESP_JSON_SIZE_MEDIUM> doc;
doc["event"] = event_str;
doc["version"] = EMSESP_APP_VERSION;
#ifndef EMSESP_STANDALONE
if (WiFi.status() == WL_CONNECTED) {
doc["connection"] = "wifi";
doc["hostname"] = WiFi.getHostname();
doc["SSID"] = WiFi.SSID();
doc["BSSID"] = WiFi.BSSIDstr();
doc["RSSI"] = WiFi.RSSI();
doc["MAC"] = WiFi.macAddress();
doc["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask());
doc["IPv4 gateway"] = uuid::printable_to_string(WiFi.gatewayIP());
doc["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP());
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
}
} else if (EMSESP::system_.ethernet_connected()) {
doc["connection"] = "ethernet";
doc["hostname"] = ETH.getHostname();
doc["MAC"] = ETH.macAddress();
doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask());
doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP());
doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP());
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6());
}
}
#endif
Mqtt::publish_retain(F_(info), doc.as<JsonObject>(), true); // topic called "info" and it's Retained
}
// create the json for heartbeat
bool System::heartbeat_json(JsonObject & output) {
uint8_t bus_status = EMSESP::bus_status();

View File

@@ -77,6 +77,7 @@ class System {
bool check_upgrade();
bool heartbeat_json(JsonObject & output);
void send_heartbeat();
void send_info_mqtt(const char * event_str);
bool syslog_enabled() {
return syslog_enabled_;

View File

@@ -44,6 +44,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
#endif
EMSESP::system_.syslog_init();
mDNS_start();
EMSESP::system_.send_info_mqtt("connected");
break;
case ARDUINO_EVENT_ETH_START:
@@ -69,6 +70,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
EMSESP::system_.syslog_init();
EMSESP::system_.ethernet_connected(true);
mDNS_start();
EMSESP::system_.send_info_mqtt("connected");
}
break;
@@ -106,9 +108,9 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
} else {
EMSESP::logger().info("WiFi connected with IPv6=%s, hostname=%s", WiFi.localIPv6().toString().c_str(), WiFi.getHostname());
}
// EMSESP::system_.send_heartbeat();
EMSESP::system_.syslog_init();
mDNS_start();
EMSESP::system_.send_info_mqtt("connected");
break;
#endif