Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #17 from bram2202/develop
Browse files Browse the repository at this point in the history
version/1.3.1 release
  • Loading branch information
bram2202 authored Aug 25, 2021
2 parents 17aae4d + d3974c1 commit 873b71a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 59 deletions.
52 changes: 26 additions & 26 deletions AutoConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsonObject>();
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";
Expand All @@ -62,7 +62,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -78,7 +78,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -94,7 +94,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -110,7 +110,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -126,7 +126,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -141,7 +141,7 @@ void AutoConfig::SendConfig()
// power_tariff
autoconfPayload["device"] = device.as<JsonObject>();
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);
Expand All @@ -155,7 +155,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -167,7 +167,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -179,7 +179,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -194,7 +194,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -209,7 +209,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -224,7 +224,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -239,7 +239,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -254,7 +254,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -269,7 +269,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -284,7 +284,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -299,7 +299,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -314,7 +314,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -326,7 +326,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -338,7 +338,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -350,7 +350,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -362,7 +362,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -374,7 +374,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand All @@ -389,7 +389,7 @@ void AutoConfig::SendConfig()
autoconfPayload["device"] = device.as<JsonObject>();
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";
Expand Down
6 changes: 3 additions & 3 deletions MQTTPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,15 +56,15 @@ 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
}

logger.debug("enabled. Connecting.");

client.setServer(MQTT_HOST_NAME, MQTT_PORT);
client.setServer(MQTT_BROKER, MQTT_PORT);
client.setKeepAlive(10);
client.setBufferSize(2048);

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) |


Expand Down
55 changes: 29 additions & 26 deletions Settings.example.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
//Hostname of ESP8266
#define WIFI_HOSTNAME "ESP-DSMR"

//Wifi SSID to connect to
#define WIFI_SSID "<wifi name>"

//Passowrd for WIFI
#define WIFI_PASSWORD "<wifi password>"

//set the mqqt host name or ip address to your mqqt host. Leave empty to disable mqtt.
#define MQTT_HOST_NAME "<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 "<MQTT user name>"

//password for above user
#define MQTT_PASSWORD "<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 "<wifi name>"

// Passowrd for WIFI
#define WIFI_PASSWORD "<wifi password>"

// Set the mqqt host name or ip address to your mqqt host. Leave empty to disable mqtt.
#define MQTT_BROKER "<MQTT broker address>"

// 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 "<MQTT user name>"

// Password for above user
#define MQTT_PASSWORD "<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

0 comments on commit 873b71a

Please sign in to comment.