mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
lower case days, hours, minutes, seconds
This commit is contained in:
@@ -98,10 +98,10 @@ const en: BaseTranslation = {
|
|||||||
NUM_DEVICES: '{num} Device{{s}}',
|
NUM_DEVICES: '{num} Device{{s}}',
|
||||||
NUM_TEMP_SENSORS: '{num} Temperature Sensor{{s}}',
|
NUM_TEMP_SENSORS: '{num} Temperature Sensor{{s}}',
|
||||||
NUM_ANALOG_SENSORS: '{num} Analog Sensor{{s}}',
|
NUM_ANALOG_SENSORS: '{num} Analog Sensor{{s}}',
|
||||||
NUM_DAYS: '{num} Day{{s}}',
|
NUM_DAYS: '{num} day{{s}}',
|
||||||
NUM_SECONDS: '{num} Second{{s}}',
|
NUM_SECONDS: '{num} second{{s}}',
|
||||||
NUM_HOURS: '{num} Hour{{s}}',
|
NUM_HOURS: '{num} hour{{s}}',
|
||||||
NUM_MINUTES: '{num} Minute{{s}}',
|
NUM_MINUTES: '{num} minute{{s}}',
|
||||||
APPLICATION_SETTINGS: 'Application Settings',
|
APPLICATION_SETTINGS: 'Application Settings',
|
||||||
CUSTOMIZATION: 'Customization',
|
CUSTOMIZATION: 'Customization',
|
||||||
APPLICATION_RESTARTING: 'EMS-ESP is restarting',
|
APPLICATION_RESTARTING: 'EMS-ESP is restarting',
|
||||||
|
|||||||
@@ -98,10 +98,10 @@ const nl: Translation = {
|
|||||||
NUM_DEVICES: '{num} Apparaat{{en}}',
|
NUM_DEVICES: '{num} Apparaat{{en}}',
|
||||||
NUM_TEMP_SENSORS: '{num} Temperatuursensor{{en}}',
|
NUM_TEMP_SENSORS: '{num} Temperatuursensor{{en}}',
|
||||||
NUM_ANALOG_SENSORS: '{num} Analoge sensor{{en}}',
|
NUM_ANALOG_SENSORS: '{num} Analoge sensor{{en}}',
|
||||||
NUM_DAYS: '{num} Dag{{en}}',
|
NUM_DAYS: '{num} dag{{en}}',
|
||||||
NUM_SECONDS: '{num} Second{{en}}',
|
NUM_SECONDS: '{num} second{{en}}',
|
||||||
NUM_HOURS: '{num} Uur{{en}}',
|
NUM_HOURS: '{num} uur{{en}}',
|
||||||
NUM_MINUTES: '{num} Minuut{{en}}',
|
NUM_MINUTES: '{num} minuut{{en}}',
|
||||||
APPLICATION_SETTINGS: 'Applicatieinstellingen',
|
APPLICATION_SETTINGS: 'Applicatieinstellingen',
|
||||||
CUSTOMIZATION: 'Custom aanpassingen',
|
CUSTOMIZATION: 'Custom aanpassingen',
|
||||||
APPLICATION_RESTARTING: 'EMS-ESP herstarten',
|
APPLICATION_RESTARTING: 'EMS-ESP herstarten',
|
||||||
|
|||||||
@@ -98,10 +98,10 @@ const no: Translation = {
|
|||||||
NUM_DEVICES: '{num} Enhet{{er}}',
|
NUM_DEVICES: '{num} Enhet{{er}}',
|
||||||
NUM_TEMP_SENSORS: '{num} Temperatursensor{{er}}',
|
NUM_TEMP_SENSORS: '{num} Temperatursensor{{er}}',
|
||||||
NUM_ANALOG_SENSORS: '{num} Analogsensor{{er}}',
|
NUM_ANALOG_SENSORS: '{num} Analogsensor{{er}}',
|
||||||
NUM_DAYS: '{num} Dag{{er}}',
|
NUM_DAYS: '{num} sag{{er}}',
|
||||||
NUM_SECONDS: '{num} Sekund{{er}}',
|
NUM_SECONDS: '{num} sekund{{er}}',
|
||||||
NUM_HOURS: '{num} Time{{r}}',
|
NUM_HOURS: '{num} time{{r}}',
|
||||||
NUM_MINUTES: '{num} Minutt{{er}}',
|
NUM_MINUTES: '{num} minutt{{er}}',
|
||||||
APPLICATION_SETTINGS: 'Innstillinger',
|
APPLICATION_SETTINGS: 'Innstillinger',
|
||||||
CUSTOMIZATION: 'Tilpasninger',
|
CUSTOMIZATION: 'Tilpasninger',
|
||||||
APPLICATION_RESTARTING: 'EMS-ESP restarter',
|
APPLICATION_RESTARTING: 'EMS-ESP restarter',
|
||||||
|
|||||||
@@ -98,10 +98,10 @@ const se: Translation = {
|
|||||||
NUM_DEVICES: '{num} Enhet{{er}}',
|
NUM_DEVICES: '{num} Enhet{{er}}',
|
||||||
NUM_TEMP_SENSORS: '{num} Temperatur-sensor{{er}}',
|
NUM_TEMP_SENSORS: '{num} Temperatur-sensor{{er}}',
|
||||||
NUM_ANALOG_SENSORS: '{num} Analoga Sensor{{er}}',
|
NUM_ANALOG_SENSORS: '{num} Analoga Sensor{{er}}',
|
||||||
NUM_DAYS: '{num} Dag{{ar}}',
|
NUM_DAYS: '{num} dag{{ar}}',
|
||||||
NUM_SECONDS: '{num} Sekund{{er}}',
|
NUM_SECONDS: '{num} sekund{{er}}',
|
||||||
NUM_HOURS: '{num} Timmar',
|
NUM_HOURS: '{num} timmar',
|
||||||
NUM_MINUTES: '{num} Minut{{er}}',
|
NUM_MINUTES: '{num} minut{{er}}',
|
||||||
APPLICATION_SETTINGS: 'Inställningar',
|
APPLICATION_SETTINGS: 'Inställningar',
|
||||||
CUSTOMIZATION: 'Anpassa',
|
CUSTOMIZATION: 'Anpassa',
|
||||||
APPLICATION_RESTARTING: 'EMS-ESP startar om',
|
APPLICATION_RESTARTING: 'EMS-ESP startar om',
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
if (_state.enabled) {
|
if (_state.enabled) {
|
||||||
// emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client");
|
// emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client");
|
||||||
_mqttClient.disconnect();
|
_mqttClient.disconnect();
|
||||||
// onConfigUpdated();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ 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]));
|
auto decimal = abs((int32_t)((value - whole) * p[format]));
|
||||||
for (int8_t i = 1; i < format; i++) {
|
for (int8_t i = 1; i < format; i++) {
|
||||||
if (decimal < p[i]) {
|
if (decimal < p[i]) {
|
||||||
*result++ = '0'; // add leading zeros
|
*result++ = '0'; // add leading zeros
|
||||||
|
|||||||
48
src/mqtt.cpp
48
src/mqtt.cpp
@@ -537,57 +537,18 @@ bool Mqtt::get_publish_onchange(uint8_t device_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MQTT onConnect - when an MQTT connect is established
|
// MQTT onConnect - when an MQTT connect is established
|
||||||
// send out some inital MQTT messages
|
|
||||||
void Mqtt::on_connect() {
|
void Mqtt::on_connect() {
|
||||||
if (connecting_) { // prevent duplicated connections
|
if (connecting_) {
|
||||||
return;
|
return; // prevent duplicated connections
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("MQTT connected");
|
LOG_INFO("MQTT connected");
|
||||||
|
|
||||||
connecting_ = true;
|
connecting_ = true;
|
||||||
connectcount_++;
|
connectcount_++; // count # reconnects. not currently used.
|
||||||
|
|
||||||
load_settings(); // reload MQTT settings - in case they have changes
|
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_) {
|
if (ha_enabled_) {
|
||||||
queue_unsubscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");
|
queue_unsubscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");
|
||||||
EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any
|
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);
|
ha_climate_reset(true);
|
||||||
} else {
|
} else {
|
||||||
// with disabled HA we subscribe and the broker sends all stored HA-emsesp-configs.
|
// 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):
|
// 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.
|
// disable HA, wait 5 minutes (to allow the broker to send all), than reenable HA again.
|
||||||
queue_subscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");
|
queue_subscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");
|
||||||
|
|||||||
@@ -535,6 +535,40 @@ void System::loop() {
|
|||||||
#endif
|
#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
|
// create the json for heartbeat
|
||||||
bool System::heartbeat_json(JsonObject & output) {
|
bool System::heartbeat_json(JsonObject & output) {
|
||||||
uint8_t bus_status = EMSESP::bus_status();
|
uint8_t bus_status = EMSESP::bus_status();
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ class System {
|
|||||||
bool check_upgrade();
|
bool check_upgrade();
|
||||||
bool heartbeat_json(JsonObject & output);
|
bool heartbeat_json(JsonObject & output);
|
||||||
void send_heartbeat();
|
void send_heartbeat();
|
||||||
|
void send_info_mqtt(const char * event_str);
|
||||||
|
|
||||||
bool syslog_enabled() {
|
bool syslog_enabled() {
|
||||||
return syslog_enabled_;
|
return syslog_enabled_;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
#endif
|
#endif
|
||||||
EMSESP::system_.syslog_init();
|
EMSESP::system_.syslog_init();
|
||||||
mDNS_start();
|
mDNS_start();
|
||||||
|
EMSESP::system_.send_info_mqtt("connected");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARDUINO_EVENT_ETH_START:
|
case ARDUINO_EVENT_ETH_START:
|
||||||
@@ -69,6 +70,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
EMSESP::system_.syslog_init();
|
EMSESP::system_.syslog_init();
|
||||||
EMSESP::system_.ethernet_connected(true);
|
EMSESP::system_.ethernet_connected(true);
|
||||||
mDNS_start();
|
mDNS_start();
|
||||||
|
EMSESP::system_.send_info_mqtt("connected");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -106,9 +108,9 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
} else {
|
} else {
|
||||||
EMSESP::logger().info("WiFi connected with IPv6=%s, hostname=%s", WiFi.localIPv6().toString().c_str(), WiFi.getHostname());
|
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();
|
EMSESP::system_.syslog_init();
|
||||||
mDNS_start();
|
mDNS_start();
|
||||||
|
EMSESP::system_.send_info_mqtt("connected");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user