Homewizard p1: add more measurements (#14708)
This commit is contained in:
parent
f9213665d7
commit
5db2d5402c
3 changed files with 25 additions and 1 deletions
|
|
@ -108,3 +108,15 @@ func (c *Connection) TotalEnergy() (float64, error) {
|
|||
res, err := c.dataG.Get()
|
||||
return res.TotalPowerImportT1kWh + res.TotalPowerImportT2kWh + res.TotalPowerImportT3kWh + res.TotalPowerImportT4kWh, err
|
||||
}
|
||||
|
||||
// Currents implements the api.PhaseCurrents interface
|
||||
func (c *Connection) Currents() (float64, float64, float64, error) {
|
||||
res, err := c.dataG.Get()
|
||||
return res.ActiveCurrentL1A, res.ActiveCurrentL2A, res.ActiveCurrentL3A, err
|
||||
}
|
||||
|
||||
// Voltages implements the api.PhaseVoltages interface
|
||||
func (c *Connection) Voltages() (float64, float64, float64, error) {
|
||||
res, err := c.dataG.Get()
|
||||
return res.ActiveVoltageL1V, res.ActiveVoltageL2V, res.ActiveVoltageL3V, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,10 @@ type DataResponse struct {
|
|||
TotalPowerImportT2kWh float64 `json:"total_power_import_t2_kwh"`
|
||||
TotalPowerImportT3kWh float64 `json:"total_power_import_t3_kwh"`
|
||||
TotalPowerImportT4kWh float64 `json:"total_power_import_t4_kwh"`
|
||||
ActiveCurrentL1A float64 `json:"active_current_l1_a"`
|
||||
ActiveCurrentL2A float64 `json:"active_current_l2_a"`
|
||||
ActiveCurrentL3A float64 `json:"active_current_l3_a"`
|
||||
ActiveVoltageL1V float64 `json:"active_voltage_l1_v"`
|
||||
ActiveVoltageL2V float64 `json:"active_voltage_l2_v"`
|
||||
ActiveVoltageL3V float64 `json:"active_voltage_l3_v"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,10 +38,16 @@ func TestUnmarshalDataResponse(t *testing.T) {
|
|||
{
|
||||
var res DataResponse
|
||||
|
||||
jsonstr := `{"wifi_ssid": "My Wi-Fi","wifi_strength": 100,"total_power_import_t1_kwh": 30.511,"total_power_export_t1_kwh": 85.951,"active_power_w": 543,"active_power_l1_w": 676}`
|
||||
jsonstr := `{"wifi_ssid": "My Wi-Fi","wifi_strength": 100,"total_power_import_t1_kwh": 30.511,"total_power_export_t1_kwh": 85.951,"active_power_w": 543,"active_power_l1_w": 28,"active_power_l2_w": 0,"active_power_l3_w": -181,"active_voltage_l1_v": 235.4,"active_voltage_l2_v": 235.8,"active_voltage_l3_v": 236.1,"active_current_l1_a": 1.19,"active_current_l2_a": 0.37,"active_current_l3_a": -0.93}`
|
||||
require.NoError(t, json.Unmarshal([]byte(jsonstr), &res))
|
||||
|
||||
assert.Equal(t, float64(30.511), res.TotalPowerImportT1kWh+res.TotalPowerImportT2kWh+res.TotalPowerImportT3kWh+res.TotalPowerImportT4kWh)
|
||||
assert.Equal(t, float64(543), res.ActivePowerW)
|
||||
assert.Equal(t, float64(235.4), res.ActiveVoltageL1V)
|
||||
assert.Equal(t, float64(235.8), res.ActiveVoltageL2V)
|
||||
assert.Equal(t, float64(236.1), res.ActiveVoltageL3V)
|
||||
assert.Equal(t, float64(1.19), res.ActiveCurrentL1A)
|
||||
assert.Equal(t, float64(0.37), res.ActiveCurrentL2A)
|
||||
assert.Equal(t, float64(-0.93), res.ActiveCurrentL3A)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue