Shelly gen1 EM: return positive power (#7088)

This commit is contained in:
Markus Thierolf 2023-03-28 07:30:30 +02:00 • committed by GitHub
parent ecec839320
commit 62dcbfd6fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -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
}

View file

@ -6,7 +6,7 @@ products:
group: switchsockets
params:
- name: usage
choice: ["pv"]
choice: ["pv", "charge"]
- name: host
default: 192.0.2.2
- name: user

View file

@ -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