Skip to content

Commit

Permalink
Feature: decode more OBIS values in SML power meters
Browse files Browse the repository at this point in the history
supersedes #951.
  • Loading branch information
schlimmchen committed Jun 26, 2024
1 parent 75c07c1 commit e78f584
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
22 changes: 20 additions & 2 deletions include/PowerMeterSml.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ class PowerMeterSml : public PowerMeterProvider {
private:
mutable std::mutex _mutex;

float _activePower = 0.0;
float _activePowerTotal = 0.0;
float _activePowerL1 = 0.0;
float _activePowerL2 = 0.0;
float _activePowerL3 = 0.0;
float _voltageL1 = 0.0;
float _voltageL2 = 0.0;
float _voltageL3 = 0.0;
float _currentL1 = 0.0;
float _currentL2 = 0.0;
float _currentL3 = 0.0;
float _energyImport = 0.0;
float _energyExport = 0.0;

Expand All @@ -33,7 +42,16 @@ class PowerMeterSml : public PowerMeterProvider {
} OBISHandler;

const std::list<OBISHandler> smlHandlerList{
{{0x01, 0x00, 0x10, 0x07, 0x00, 0xff}, &smlOBISW, &_activePower, "active power"},
{{0x01, 0x00, 0x10, 0x07, 0x00, 0xff}, &smlOBISW, &_activePowerTotal, "active power total"},
{{0x01, 0x00, 0x24, 0x07, 0x00, 0xff}, &smlOBISW, &_activePowerL1, "active power L1"},
{{0x01, 0x00, 0x38, 0x07, 0x00, 0xff}, &smlOBISW, &_activePowerL2, "active power L2"},
{{0x01, 0x00, 0x4c, 0x07, 0x00, 0xff}, &smlOBISW, &_activePowerL3, "active power L3"},
{{0x01, 0x00, 0x20, 0x07, 0x00, 0xff}, &smlOBISVolt, &_voltageL1, "voltage L1"},
{{0x01, 0x00, 0x34, 0x07, 0x00, 0xff}, &smlOBISVolt, &_voltageL2, "voltage L2"},
{{0x01, 0x00, 0x48, 0x07, 0x00, 0xff}, &smlOBISVolt, &_voltageL3, "voltage L3"},
{{0x01, 0x00, 0x1f, 0x07, 0x00, 0xff}, &smlOBISAmpere, &_currentL1, "current L1"},
{{0x01, 0x00, 0x33, 0x07, 0x00, 0xff}, &smlOBISAmpere, &_currentL2, "current L2"},
{{0x01, 0x00, 0x47, 0x07, 0x00, 0xff}, &smlOBISAmpere, &_currentL3, "current L3"},
{{0x01, 0x00, 0x01, 0x08, 0x00, 0xff}, &smlOBISWh, &_energyImport, "energy import"},
{{0x01, 0x00, 0x02, 0x08, 0x00, 0xff}, &smlOBISWh, &_energyExport, "energy export"}
};
Expand Down
11 changes: 10 additions & 1 deletion src/PowerMeterSml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@
float PowerMeterSml::getPowerTotal() const
{
std::lock_guard<std::mutex> l(_mutex);
return _activePower;
return _activePowerTotal;
}

void PowerMeterSml::doMqttPublish() const
{
std::lock_guard<std::mutex> l(_mutex);
mqttPublish("power1", _activePowerL1);
mqttPublish("power2", _activePowerL2);
mqttPublish("power3", _activePowerL3);
mqttPublish("voltage1", _voltageL1);
mqttPublish("voltage2", _voltageL2);
mqttPublish("voltage3", _voltageL3);
mqttPublish("current1", _currentL1);
mqttPublish("current2", _currentL2);
mqttPublish("current3", _currentL3);
mqttPublish("import", _energyImport);
mqttPublish("export", _energyExport);
}
Expand Down

0 comments on commit e78f584

Please sign in to comment.