Mqtt: revert publishing phase values as array instead of slice

This commit is contained in:
andig 2022-12-26 00:02:05 +01:00
parent a885f39d18
commit c9e8ee27ae
2 changed files with 2 additions and 2 deletions

View file

@ -442,7 +442,7 @@ func (site *Site) updateMeters() error {
i1, i2, i3, err := phaseMeter.Currents()
if err == nil {
site.log.DEBUG.Printf("grid currents: %.3gA", []float64{i1, i2, i3})
site.publish("gridCurrents", [3]float64{i1, i2, i3}) // array[3] for mqtt special-casing phases
site.publish("gridCurrents", []float64{i1, i2, i3})
} else {
site.log.ERROR.Printf("grid meter currents: %v", err)
}

View file

@ -63,7 +63,7 @@ func (m *MQTT) publishSingleValue(topic string, retained bool, payload interface
func (m *MQTT) publish(topic string, retained bool, payload interface{}) {
// publish phase values
if slice, ok := payload.([3]float64); ok {
if slice, ok := payload.([]float64); ok && len(slice) == 3 {
var total float64
for i, v := range slice {
total += v