Fixes (#8). Power values on CH0 are published twice
The larger value was DC the smaller one AC. Now the values are published to different topics
This commit is contained in:
parent
839720ee8a
commit
d5f32d8325
@ -11,7 +11,7 @@ public:
|
|||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void publishField(String subtopic, std::shared_ptr<InverterAbstract> inv, uint8_t channel, uint8_t fieldId);
|
void publishField(String subtopic, std::shared_ptr<InverterAbstract> inv, uint8_t channel, uint8_t fieldId, String topic = "");
|
||||||
|
|
||||||
uint32_t _lastPublishStats[INV_MAX_COUNT];
|
uint32_t _lastPublishStats[INV_MAX_COUNT];
|
||||||
uint32_t _lastPublish;
|
uint32_t _lastPublish;
|
||||||
|
|||||||
@ -39,7 +39,11 @@ void MqttPublishingClass::loop()
|
|||||||
for (uint8_t c = 0; c <= inv->getChannelCount(); c++) {
|
for (uint8_t c = 0; c <= inv->getChannelCount(); c++) {
|
||||||
publishField(subtopic, inv, c, FLD_UDC);
|
publishField(subtopic, inv, c, FLD_UDC);
|
||||||
publishField(subtopic, inv, c, FLD_IDC);
|
publishField(subtopic, inv, c, FLD_IDC);
|
||||||
|
if (c == 0) {
|
||||||
|
publishField(subtopic, inv, c, FLD_PDC, "dcpower");
|
||||||
|
} else {
|
||||||
publishField(subtopic, inv, c, FLD_PDC);
|
publishField(subtopic, inv, c, FLD_PDC);
|
||||||
|
}
|
||||||
publishField(subtopic, inv, c, FLD_YD);
|
publishField(subtopic, inv, c, FLD_YD);
|
||||||
publishField(subtopic, inv, c, FLD_YT);
|
publishField(subtopic, inv, c, FLD_YT);
|
||||||
publishField(subtopic, inv, c, FLD_UAC);
|
publishField(subtopic, inv, c, FLD_UAC);
|
||||||
@ -60,10 +64,15 @@ void MqttPublishingClass::loop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublishingClass::publishField(String subtopic, std::shared_ptr<InverterAbstract> inv, uint8_t channel, uint8_t fieldId)
|
void MqttPublishingClass::publishField(String subtopic, std::shared_ptr<InverterAbstract> inv, uint8_t channel, uint8_t fieldId, String topic)
|
||||||
{
|
{
|
||||||
if (inv->hasChannelFieldValue(channel, fieldId)) {
|
if (inv->hasChannelFieldValue(channel, fieldId)) {
|
||||||
String chanName(inv->getChannelFieldName(channel, fieldId));
|
String chanName;
|
||||||
|
if (topic == "") {
|
||||||
|
chanName = inv->getChannelFieldName(channel, fieldId);
|
||||||
|
} else {
|
||||||
|
chanName = topic;
|
||||||
|
}
|
||||||
chanName.toLowerCase();
|
chanName.toLowerCase();
|
||||||
MqttSettings.publish(subtopic + "/" + String(channel) + "/" + chanName, String(inv->getChannelFieldValue(channel, fieldId)));
|
MqttSettings.publish(subtopic + "/" + String(channel) + "/" + chanName, String(inv->getChannelFieldValue(channel, fieldId)));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user