Skip to content

Commit

Permalink
Add support for MPPT string values (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jan 20, 2020
1 parent e696b1d commit 15555ae
Show file tree
Hide file tree
Showing 11 changed files with 634 additions and 614 deletions.
682 changes: 353 additions & 329 deletions assets/index.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var dataapp = new Vue({
el: '#data',
el: '#realtime',
delimiters: ['${', '}'],
data: {
meters: {},
Expand All @@ -18,9 +18,9 @@ var dataapp = new Vue({
}
},
methods: {
// populated returns true if it was called with any non-null argumnt
populated: function () {
for(var i = 0; i<arguments.length; i++) {
// pop returns true if it was called with any non-null argumnt
pop: function () {
for(var i=0; i<arguments.length; i++) {
if (arguments[i] !== undefined && arguments[i] !== null && arguments[i] !== "") {
return true;
}
Expand Down
16 changes: 10 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -109,12 +110,15 @@ func initConfig() {
if err := viper.ReadInConfig(); err == nil {
// using config file
cfgFile = viper.ConfigFileUsed()
} else if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
// parsing failed - exit
fmt.Println(err)
os.Exit(1)
} else {
// not using config file
cfgFile = ""
var configFileNotFound *viper.ConfigFileNotFoundError
var unsupportedConfig viper.UnsupportedConfigError
if errors.As(err, &configFileNotFound) || errors.As(err, &unsupportedConfig) {
// not using config file
cfgFile = ""
} else {
fmt.Println(err)
os.Exit(1)
}
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/volkszaehler/mbmd

require (
github.com/andig/gosunspec v0.0.0-20191120114235-802a74abaa2d
github.com/andig/gosunspec v0.0.0-20200108222136-fbcd239096dd
github.com/eclipse/paho.mqtt.golang v1.2.0
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/andig/gosunspec v0.0.0-20191120114235-802a74abaa2d h1:IX1Jqj7owJlsaDtsxPlRjI/JdHQJ8BIM/rXL2j1ILyA=
github.com/andig/gosunspec v0.0.0-20191120114235-802a74abaa2d/go.mod h1:YkshK8WMzYn1iXAZzHUO75gIqhMSan2ctgBVtBkRIyA=
github.com/andig/gosunspec v0.0.0-20200108222136-fbcd239096dd h1:VZkq2qD4psG6luOzmPdvpO3tcoCQtn3UCe2b/8f7RBU=
github.com/andig/gosunspec v0.0.0-20200108222136-fbcd239096dd/go.mod h1:YkshK8WMzYn1iXAZzHUO75gIqhMSan2ctgBVtBkRIyA=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
Expand Down
20 changes: 16 additions & 4 deletions meters/measurement_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions meters/measurements.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ const (
DCPower
HeatSinkTemp

// Strings
DCCurrentS1
DCVoltageS1
DCPowerS1
DCEnergyS1
DCCurrentS2
DCVoltageS2
DCPowerS2
DCEnergyS2
DCCurrentS3
DCVoltageS3
DCPowerS3
DCEnergyS3

// Battery
ChargeState
BatteryVoltage
Expand Down Expand Up @@ -204,6 +218,18 @@ var iec = map[Measurement][]string{
DCVoltage: {"DC Voltage", "V"},
DCPower: {"DC Power", "W"},
HeatSinkTemp: {"Heat Sink Temperature", "°C"},
DCCurrentS1: {"String 1 Current", "A"},
DCVoltageS1: {"String 1 Voltage", "V"},
DCPowerS1: {"String 1 Power", "W"},
DCEnergyS1: {"String 1 Generation", "kWh"},
DCCurrentS2: {"String 2 Current", "A"},
DCVoltageS2: {"String 2 Voltage", "V"},
DCPowerS2: {"String 2 Power", "W"},
DCEnergyS2: {"String 2 Generation", "kWh"},
DCCurrentS3: {"String 3 Current", "A"},
DCVoltageS3: {"String 3 Voltage", "V"},
DCPowerS3: {"String 3 Power", "W"},
DCEnergyS3: {"String 3 Generation", "kWh"},
ChargeState: {"Charge State", "%"},
BatteryVoltage: {"Battery Voltage", "V"},
}
Expand Down
Loading

0 comments on commit 15555ae

Please sign in to comment.