diff --git a/AutoConfig.cpp b/AutoConfig.cpp index f03ae6e..7bb52d6 100644 --- a/AutoConfig.cpp +++ b/AutoConfig.cpp @@ -41,13 +41,13 @@ void AutoConfig::SendConfig() device["manufacturer"] = "Bram2202"; device["model"] = "ESP-DSMR"; device["name"] = _identifier; - device["sw_version"] = "v1.3.0"; + device["sw_version"] = "v1.3.1"; // power_consumption autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/consumption/status"; autoconfPayload["state_topic"] = _identifier + "/power/consumption"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/consumption"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/consumption/reset"; autoconfPayload["name"] = _identifier + "_power_consumption"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "power_consumption"; @@ -62,7 +62,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/production/status"; autoconfPayload["state_topic"] = _identifier + "/power/production"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/production"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/production/reset"; autoconfPayload["name"] = _identifier + "_power_production"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "power_production"; @@ -78,7 +78,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/total_consumption_tariff_1/status"; autoconfPayload["state_topic"] = _identifier + "/power/total_consumption_tariff_1"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/total_consumption_tariff_1"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/total_consumption_tariff_1/reset"; autoconfPayload["name"] = _identifier + "_total_consumption_tariff_1"; autoconfPayload["unit_of_measurement"] = "kWh"; autoconfPayload["unique_id"] = "total_consumption_tariff_1"; @@ -94,7 +94,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/total_consumption_tariff_2/status"; autoconfPayload["state_topic"] = _identifier + "/power/total_consumption_tariff_2"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/total_consumption_tariff_2"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/total_consumption_tariff_2/reset"; autoconfPayload["name"] = _identifier + "_total_consumption_tariff_2"; autoconfPayload["unit_of_measurement"] = "kWh"; autoconfPayload["unique_id"] = "total_consumption_tariff_2"; @@ -110,7 +110,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/total_production_tariff_1/status"; autoconfPayload["state_topic"] = _identifier + "/power/total_production_tariff_1"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/total_production_tariff_1"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/total_production_tariff_1/reset"; autoconfPayload["name"] = _identifier + "_total_production_tariff_1"; autoconfPayload["unit_of_measurement"] = "kWh"; autoconfPayload["unique_id"] = "total_production_tariff_1"; @@ -126,7 +126,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/total_production_tariff_2/status"; autoconfPayload["state_topic"] = _identifier + "/power/total_production_tariff_2"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/total_production_tariff_2"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/total_production_tariff_2/reset"; autoconfPayload["name"] = _identifier + "_total_production_tariff_2"; autoconfPayload["unit_of_measurement"] = "kWh"; autoconfPayload["unique_id"] = "total_production_tariff_2"; @@ -141,7 +141,7 @@ void AutoConfig::SendConfig() // power_tariff autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/power_tariff/status"; - autoconfPayload["state_topic"] = _identifier + "/power/power_tariff"; + autoconfPayload["state_topic"] = _identifier + "/power/power_tariff/reset"; autoconfPayload["name"] = _identifier + "_power_tariff"; autoconfPayload["unique_id"] = "power_tariff"; serializeJson(autoconfPayload, mqttPayload); @@ -155,7 +155,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/short_power_outages/status"; autoconfPayload["state_topic"] = _identifier + "/power/short_power_outages"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/short_power_outages"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/short_power_outages/reset"; autoconfPayload["name"] = _identifier + "_short_power_outages"; autoconfPayload["unique_id"] = "short_power_outages"; autoconfPayload["icon"] = "mdi:flash-off"; @@ -167,7 +167,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/long_power_outages/status"; autoconfPayload["state_topic"] = _identifier + "/power/long_power_outages"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/long_power_outages"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/long_power_outages/reset"; autoconfPayload["name"] = _identifier + "_long_power_outages"; autoconfPayload["unique_id"] = "long_power_outages"; autoconfPayload["icon"] = "mdi:flash-off"; @@ -179,7 +179,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_1/current/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_1/current"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/current"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/current/reset"; autoconfPayload["name"] = _identifier + "_phase_1_current"; autoconfPayload["unit_of_measurement"] = "A"; autoconfPayload["unique_id"] = "phase_1_current"; @@ -194,7 +194,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_2/current/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_2/current"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/current"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/current/reset"; autoconfPayload["name"] = _identifier + "_phase_2_current"; autoconfPayload["unit_of_measurement"] = "A"; autoconfPayload["unique_id"] = "phase_2_current"; @@ -209,7 +209,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_3/current/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_3/current"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/current"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/current/reset"; autoconfPayload["name"] = _identifier + "_phase_3_current"; autoconfPayload["unit_of_measurement"] = "A"; autoconfPayload["unique_id"] = "phase_3_current"; @@ -224,7 +224,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_1/consumption/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_1/consumption"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/consumption"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/consumption/reset"; autoconfPayload["name"] = _identifier + "_phase_1_consumption"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "phase_1_consumption"; @@ -239,7 +239,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_2/consumption/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_2/consumption"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/consumption"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/consumption/reset"; autoconfPayload["name"] = _identifier + "_phase_2_consumption"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "phase_2_consumption"; @@ -254,7 +254,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_3/consumption/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_3/consumption"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/consumption"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/consumption/reset"; autoconfPayload["name"] = _identifier + "_phase_3_consumption"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "phase_3_consumption"; @@ -269,7 +269,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_1/production/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_1/production"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/production"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/production/reset"; autoconfPayload["name"] = _identifier + "_phase_1_production"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "phase_1_production"; @@ -284,7 +284,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_2/production/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_2/production"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/production"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/production/reset"; autoconfPayload["name"] = _identifier + "_phase_2_production"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "phase_2_production"; @@ -299,7 +299,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_3/production/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_3/production"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/production"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/production/reset"; autoconfPayload["name"] = _identifier + "_phase_3_production"; autoconfPayload["unit_of_measurement"] = "kW"; autoconfPayload["unique_id"] = "phase_3_production"; @@ -314,7 +314,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_1/drops/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_1/drops"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/drops"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/drops/reset"; autoconfPayload["name"] = _identifier + "_phase_1_drops"; autoconfPayload["unique_id"] = "phase_1_drops"; autoconfPayload["icon"] = "mdi:chart-sankey"; @@ -326,7 +326,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_2/drops/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_2/drops"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/drops"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/drops/reset"; autoconfPayload["name"] = _identifier + "_phase_2_drops"; autoconfPayload["unique_id"] = "phase_2_drops"; autoconfPayload["icon"] = "mdi:chart-sankey"; @@ -338,7 +338,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_3/drops/status"; autoconfPayload["state_topic"] = _identifier + "/power/phase_3/drops"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/drops"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/drops/reset"; autoconfPayload["name"] = _identifier + "_phase_3_drops"; autoconfPayload["unique_id"] = "phase_3_drops"; autoconfPayload["icon"] = "mdi:chart-sankey"; @@ -350,7 +350,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_1/drops/peaks"; autoconfPayload["state_topic"] = _identifier + "/power/phase_1/peaks"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/peaks"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_1/peaks/reset"; autoconfPayload["name"] = _identifier + "_phase_1_peaks"; autoconfPayload["unique_id"] = "phase_1_peaks"; autoconfPayload["icon"] = "mdi:chart-bell-curve"; @@ -362,7 +362,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_2/drops/peaks"; autoconfPayload["state_topic"] = _identifier + "/power/phase_2/peaks"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/peaks"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_2/peaks/reset"; autoconfPayload["name"] = _identifier + "_phase_2_peaks"; autoconfPayload["unique_id"] = "phase_2_peaks"; autoconfPayload["icon"] = "mdi:chart-bell-curve"; @@ -374,7 +374,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "/power/phase_3/drops/peaks"; autoconfPayload["state_topic"] = _identifier + "/power/phase_3/peaks"; - autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/peaks"; + autoconfPayload["last_reset_topic"] = _identifier + "/power/phase_3/peaks/reset"; autoconfPayload["name"] = _identifier + "_phase_3_peaks"; autoconfPayload["unique_id"] = "phase_3_peaks"; autoconfPayload["icon"] = "mdi:chart-bell-curve"; @@ -389,7 +389,7 @@ void AutoConfig::SendConfig() autoconfPayload["device"] = device.as(); autoconfPayload["availability_topic"] = _identifier + "gas/total/status"; autoconfPayload["state_topic"] = _identifier + "gas/total"; - autoconfPayload["last_reset_topic"] = _identifier + "gas/total"; + autoconfPayload["last_reset_topic"] = _identifier + "gas/total/reset"; autoconfPayload["name"] = _identifier + "_total_gas"; autoconfPayload["unit_of_measurement"] = "kWh"; autoconfPayload["unique_id"] = "gas/total"; diff --git a/MQTTPublisher.cpp b/MQTTPublisher.cpp index decc29a..3d5a5e1 100644 --- a/MQTTPublisher.cpp +++ b/MQTTPublisher.cpp @@ -19,7 +19,7 @@ bool MQTTPublisher::reconnect() { lastConnectionAttempt = millis(); - logger.debug("Attempt connection to server: " + String(MQTT_HOST_NAME)); + logger.debug("Attempt connection to server: " + String(MQTT_BROKER)); // Attempt to connect bool clientConnected; @@ -56,7 +56,7 @@ bool MQTTPublisher::reconnect() void MQTTPublisher::start() { - if (String(MQTT_HOST_NAME).length() == 0 || MQTT_PORT == 0) + if (String(MQTT_BROKER).length() == 0 || MQTT_PORT == 0) { logger.warn("disabled. No hostname or port set."); return; //not configured @@ -64,7 +64,7 @@ void MQTTPublisher::start() logger.debug("enabled. Connecting."); - client.setServer(MQTT_HOST_NAME, MQTT_PORT); + client.setServer(MQTT_BROKER, MQTT_PORT); client.setKeepAlive(10); client.setBufferSize(2048); diff --git a/README.md b/README.md index e04fbf8..45a2c5f 100644 --- a/README.md +++ b/README.md @@ -96,13 +96,12 @@ Copy `Settings.example.h` to `Settings.h` and fill in the correct data. | WIFI_HOSTNAME | ESP-DSMR | device name on network | | WIFI_SSID | - | Wifi name to connect to | | WIFI_PASSWORD | - | Wifi password | -| MQTT_HOST_NAME | - | MQTT broker address | +| MQTT_BROKER | - | MQTT broker address | | MQTT_PORT | 1883 | MQTT broker port | | MQTT_USER_NAME| - | MQTT user name | | MQTT_PASSWORD | - | MQTT password | -| MQTT_HOSTNAME| ESP-DSMR | MQTT name | -| AUTOCONFIG_GAS | true | setup gas entity in HA | -| AUTOCONFIG_POWER_EXTENDED | true | setup all power entities in HA | +| AUTOCONFIG_GAS | true | Setup gas entity in HA | +| AUTOCONFIG_POWER_EXTENDED | true | Setup all power entities in HA | | LOG_LEVEL | INFO | ( DEBUG / INFO / WARN ) | diff --git a/Settings.example.h b/Settings.example.h index 1f647fd..0c25044 100644 --- a/Settings.example.h +++ b/Settings.example.h @@ -1,26 +1,29 @@ -//Hostname of ESP8266 -#define WIFI_HOSTNAME "ESP-DSMR" - -//Wifi SSID to connect to -#define WIFI_SSID "" - -//Passowrd for WIFI -#define WIFI_PASSWORD "" - -//set the mqqt host name or ip address to your mqqt host. Leave empty to disable mqtt. -#define MQTT_HOST_NAME "" - -//mqtt port for the above host -#define MQTT_PORT 1883 - -//if authentication is enabled for mqtt, set the username below. Leave empty to disable authentication -#define MQTT_USER_NAME "" - -//password for above user -#define MQTT_PASSWORD "" - -//publish online status name -#define MQTT_HOSTNAME "ESP-DSMR" - -//for debugging, print info on serial (DEBUG, INFO, WARN) -#define LOG_LEVEL INFO +// Hostname of ESP8266 +#define WIFI_HOSTNAME "ESP-DSMR" + +// Wifi SSID to connect to +#define WIFI_SSID "" + +// Passowrd for WIFI +#define WIFI_PASSWORD "" + +// Set the mqqt host name or ip address to your mqqt host. Leave empty to disable mqtt. +#define MQTT_BROKER "" + +// Mqtt port for the above host +#define MQTT_PORT 1883 + +// If authentication is enabled for mqtt, set the username below. Leave empty to disable authentication +#define MQTT_USER_NAME "" + +// Password for above user +#define MQTT_PASSWORD "" + +// Setup gas entity in HA +#define AUTOCONFIG_GAS true + +// Setup all power entities in HA +#define AUTOCONFIG_POWER_EXTENDED true + +//for debugging, print info on serial (DEBUG, INFO, WARN) +#define LOG_LEVEL INFO