Skip to content

Commit

Permalink
MQTT Hass: Change parameter order for publishDtuSensor
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Sep 24, 2024
1 parent 96e83f3 commit 1c3e7de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/MqttHandleHass.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MqttHandleHassClass {
private:
void loop();
void publish(const String& subtopic, const String& payload);
void publishDtuSensor(const String& name, const String& device_class, const String& category, const String& icon, const String& unit_of_measure, const String& subTopic);
void publishDtuSensor(const String& name, const String& subTopic, const String& unit_of_measure, const String& icon, const String& device_class, const String& category);
void publishDtuBinarySensor(const String& name, const String& device_class, const String& category, const String& payload_on, const String& payload_off, const String& subTopic = "");
void publishInverterField(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const byteAssign_fieldDeviceClass_t fieldType, const bool clear = false);
void publishInverterButton(std::shared_ptr<InverterAbstract> inv, const String& name, const String& icon, const String& category, const String& deviceClass, const String& subTopic, const String& payload);
Expand Down
19 changes: 10 additions & 9 deletions src/MqttHandleHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ void MqttHandleHassClass::publishConfig()
const CONFIG_T& config = Configuration.get();

// publish DTU sensors
publishDtuSensor("IP", "", "diagnostic", "mdi:network-outline", "", "");
publishDtuSensor("WiFi Signal", "signal_strength", "diagnostic", "", "dBm", "rssi");
publishDtuSensor("Uptime", "duration", "diagnostic", "", "s", "");
publishDtuSensor("Temperature", "temperature", "diagnostic", "mdi:thermometer", "°C", "temperature");
publishDtuSensor("Heap Size", "", "diagnostic", "mdi:memory", "Bytes", "heap/size");
publishDtuSensor("Heap Free", "", "diagnostic", "mdi:memory", "Bytes", "heap/free");
publishDtuSensor("Largest Free Heap Block", "", "diagnostic", "mdi:memory", "Bytes", "heap/maxalloc");
publishDtuSensor("Lifetime Minimum Free Heap", "", "diagnostic", "mdi:memory", "Bytes", "heap/minfree");
publishDtuSensor("IP", "ip", "", "mdi:network-outline", "", "diagnostic");
publishDtuSensor("WiFi Signal", "rssi", "dBm", "", "signal_strength", "diagnostic");
publishDtuSensor("Uptime", "uptime", "s", "", "duration", "diagnostic");
publishDtuSensor("Temperature", "temperature", "°C", "mdi:thermometer", "temperature", "diagnostic");
publishDtuSensor("Heap Size", "heap/size", "Bytes", "mdi:memory", "", "diagnostic");
publishDtuSensor("Heap Free", "heap/free", "Bytes", "mdi:memory", "", "diagnostic");
publishDtuSensor("Largest Free Heap Block", "heap/maxalloc", "Bytes", "mdi:memory", "", "diagnostic");
publishDtuSensor("Lifetime Minimum Free Heap", "heap/minfree", "Bytes", "mdi:memory", "", "diagnostic");

publishDtuBinarySensor("Status", "connectivity", "diagnostic", config.Mqtt.Lwt.Value_Online, config.Mqtt.Lwt.Value_Offline, config.Mqtt.Lwt.Topic);

yield();
Expand Down Expand Up @@ -355,7 +356,7 @@ void MqttHandleHassClass::publishInverterSensor(std::shared_ptr<InverterAbstract
publish(configTopic, buffer);
}

void MqttHandleHassClass::publishDtuSensor(const String& name, const String& device_class, const String& category, const String& icon, const String& unit_of_measure, const String& subTopic)
void MqttHandleHassClass::publishDtuSensor(const String& name, const String& subTopic, const String& unit_of_measure, const String& icon, const String& device_class, const String& category)
{
String id = name;
id.toLowerCase();
Expand Down

0 comments on commit 1c3e7de

Please sign in to comment.