Skip to content

Commit

Permalink
v2.3.1, fixed units for HA (PR #10)
Browse files Browse the repository at this point in the history
- fixed unit of measurement on mqtt values for home assistant
- fixed another typo in mqtt.cpp
- bumped to version 2.3.1
  • Loading branch information
DirkBaumeister authored Jan 31, 2023
1 parent ad8e2df commit 6f1fc11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
// to make Arduino IDE happy
// version number is set in platformio.ini
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION 230
#define FIRMWARE_VERSION 231
#endif

// set default port for MQTT over TLS
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default_envs = d1_mini
description = Firmware for ESP8266 power meter

[common]
firmware_version = 230
firmware_version = 231
upload_speed = 460800
monitor_speed = 115200
port = /dev/tty.wchusbserial1410
Expand Down
7 changes: 4 additions & 3 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void publishHADiscoveryMessage(bool publish) {
"%s%s/runtime/config", MQTT_TOPIC_DISCOVER, systemID);

if (publish) {
Serial.printf("Sending Home Asssistant MQTT discovery message for %s...\n", devTopic);
Serial.printf("Sending Home Assistant MQTT discovery message for %s...\n", devTopic);

JSON["name"] = "WiFi Power Meter " + String(settings.systemID) + " Ferraris Impuls Counter";
JSON["unique_id"] = "wifipowermeter-" + String(settings.systemID)+ "-impuls-counter";
Expand Down Expand Up @@ -138,7 +138,7 @@ static void publishHADiscoveryMessage(bool publish) {

JSON["name"] = "WiFi Power Meter " + String(settings.systemID) + " WiFi Signal Strength";
JSON["unique_id"] = "wifipowermeter-" + String(settings.systemID)+ "-rssi";
JSON["unit_of_meas"] = "dbm";
JSON["unit_of_meas"] = "dBm";
JSON["dev_cla"] = "signal_strength";
JSON["stat_t"] = devTopic;
JSON["val_tpl"] = "{{ value_json."+ String(MQTT_SUBTOPIC_RSSI) +" }}";
Expand All @@ -155,6 +155,7 @@ static void publishHADiscoveryMessage(bool publish) {

JSON["name"] = "WiFi Power Meter " + String(settings.systemID) + " Uptime";
JSON["unique_id"] = "wifipowermeter-" + String(settings.systemID)+ "-uptime";
JSON["unit_of_meas"] = "d";
JSON["ic"] = "mdi:clock-outline";
JSON["dev_cla"] = "duration";
JSON["stat_t"] = devTopic;
Expand All @@ -165,7 +166,7 @@ static void publishHADiscoveryMessage(bool publish) {

} else if (strlen(devTopic) > 1) {
// send empty (retained) message to delete sensor autoconfiguration
Serial.printf("Removing Home Asssistant MQTT discovery message for %s...\n", devTopic);
Serial.printf("Removing Home Assistant MQTT discovery message for %s...\n", devTopic);

mqtt->publish(topicCount, "", true);
delay(50);
Expand Down

0 comments on commit 6f1fc11

Please sign in to comment.