diff --git a/meter/shelly/switch.go b/meter/shelly/switch.go index c7052fc9d..6627ba0fd 100644 --- a/meter/shelly/switch.go +++ b/meter/shelly/switch.go @@ -3,6 +3,7 @@ package shelly import ( "errors" "fmt" + "math" "strings" ) @@ -56,7 +57,8 @@ func (sh *Switch) CurrentPower() (float64, error) { } } - return power, nil + // Assure positive power response (Gen 1 EM devices can provide negative values) + return math.Abs(power), nil } // Enabled implements the api.Charger interface @@ -141,7 +143,7 @@ func (sh *Switch) TotalEnergy() (float64, error) { // gen1Energy in kWh func gen1Energy(devicetype string, energy float64) float64 { - // Gen 1 Shelly EM devices are providing Watt hours, Shelly EM devices are providing Watt minutes + // Gen 1 Shelly EM devices are providing Watt hours, Gen 1 Shelly PM devices are providing Watt minutes if !strings.Contains(devicetype, "EM") { energy = energy / 60 } diff --git a/templates/definition/meter/shelly-1pm.yaml b/templates/definition/meter/shelly-1pm.yaml index 8f6d9101a..1c8d38c34 100644 --- a/templates/definition/meter/shelly-1pm.yaml +++ b/templates/definition/meter/shelly-1pm.yaml @@ -6,7 +6,7 @@ products: group: switchsockets params: - name: usage - choice: ["pv"] + choice: ["pv", "charge"] - name: host default: 192.0.2.2 - name: user diff --git a/templates/docs/meter/shelly-1pm_0.yaml b/templates/docs/meter/shelly-1pm_0.yaml index f1faa5153..3faa20b26 100644 --- a/templates/docs/meter/shelly-1pm_0.yaml +++ b/templates/docs/meter/shelly-1pm_0.yaml @@ -12,3 +12,12 @@ render: user: # Benutzerkonto (bspw. E-Mail Adresse, User Id, etc.) # Optional password: # Passwort des Benutzerkontos (bei führenden Nullen bitte in einfache Hochkommata setzen) # Optional channel: # Optional + - usage: charge + default: | + type: template + template: shelly-1pm + usage: charge + host: 192.0.2.2 # IP-Adresse oder Hostname + user: # Benutzerkonto (bspw. E-Mail Adresse, User Id, etc.) # Optional + password: # Passwort des Benutzerkontos (bei führenden Nullen bitte in einfache Hochkommata setzen) # Optional + channel: # Optional