Add Innogy eBox (#2091)
This commit is contained in:
parent
c1fe5902a7
commit
bedebe2957
2 changed files with 198 additions and 1 deletions
|
|
@ -14,7 +14,7 @@ EVCC is an extensible EV Charge Controller with PV integration implemented in [G
|
|||
- simple and clean user interface
|
||||
- multiple [chargers](#charger):
|
||||
- Open source: [openWB](https://openwb.de/), [EVSEWifi](https://www.evse-wifi.de) (includes smartWB)
|
||||
- Other commercial: ABL eMH1, Alfen Eve, cFos PowerBrain, Daheimladen, go-eCharger, Heidelberg Energy Control, KEBA/BMW, NRGkick, Wallbe, Mobile Charger Connect, EEBUS (experimental)
|
||||
- Other commercial: ABL eMH1, Alfen Eve, cFos PowerBrain, Daheimladen, go-eCharger, Heidelberg Energy Control, Innogy eBox, KEBA/BMW, NRGkick, Wallbe, Mobile Charger Connect, EEBUS (experimental)
|
||||
- Build-your-own: Phoenix (includes ESL Walli), [SimpleEVSE](https://www.evse-wifi.de/produkt-schlagwort/simple-evse-wb/)
|
||||
- Smart-Home outlets: FritzDECT, Shelly, Tasmota, TP-Link
|
||||
- multiple [meters](#meter): ModBus (Eastron SDM, MPM3PM, SBC ALE3 and many more), Discovergy (using HTTP plugin), SMA Sunny Home Manager and Energy Meter, KOSTAL Smart Energy Meter (KSEM, EMxx), any Sunspec-compatible inverter or home battery devices (Fronius, SMA, SolarEdge, KOSTAL, STECA, E3DC, ...), Tesla PowerWall, LG ESS HOME
|
||||
|
|
@ -200,6 +200,7 @@ Available charger implementations are:
|
|||
- `evsewifi`: chargers with SimpleEVSE controllers using [EVSE-WiFi](https://www.evse-wifi.de/) (includes smartWB)
|
||||
- `go-e`: go-eCharger chargers (both local and cloud API are supported, at least firmware 040.0 required)
|
||||
- `heidelberg`: Heidelberg Energy Control (requires Modbus adapter; [sponsors only](#sponsorship))
|
||||
- `innogy`: Innogy eBox
|
||||
- `keba`: KEBA KeContact P20/P30 and BMW chargers (see [Preparation](#keba-preparation-))
|
||||
- `mcc`: Mobile Charger Connect devices (Audi, Bentley, Porsche)
|
||||
- `nrgkick-bluetooth`: NRGkick chargers with Bluetooth connector (Linux only, not supported on Docker)
|
||||
|
|
|
|||
196
charger/innogy.go
Normal file
196
charger/innogy.go
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
package charger
|
||||
|
||||
// LICENSE
|
||||
|
||||
// Copyright (c) 2019-2021 andig
|
||||
|
||||
// This module is NOT covered by the MIT license. All rights reserved.
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/modbus"
|
||||
"github.com/evcc-io/evcc/util/sponsor"
|
||||
)
|
||||
|
||||
const (
|
||||
igyRegID = 0 // Input
|
||||
igyRegSerial = 25 // Input
|
||||
igyRegProtocol = 50 // Input
|
||||
igyRegManufacturer = 100 // Input
|
||||
igyRegFirmware = 200 // Input
|
||||
igyRegStatus = 275 // Input
|
||||
igyRegEnable = 1028 // Holding
|
||||
)
|
||||
|
||||
var (
|
||||
igyRegMaxCurrents = []uint16{1012, 1014, 1016} // max current per phase
|
||||
igyRegCurrents = []uint16{1006, 1008, 1010} // current readings per phase
|
||||
)
|
||||
|
||||
// Innogy is an api.Charger implementation for Innogy eBox wallboxes.
|
||||
type Innogy struct {
|
||||
conn *modbus.Connection
|
||||
}
|
||||
|
||||
func init() {
|
||||
registry.Add("innogy", NewInnogyFromConfig)
|
||||
}
|
||||
|
||||
// NewInnogyFromConfig creates a Innogy charger from generic config
|
||||
func NewInnogyFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
cc := struct {
|
||||
URI string
|
||||
ID uint8
|
||||
}{
|
||||
ID: 1,
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewInnogy(cc.URI, cc.ID)
|
||||
}
|
||||
|
||||
// NewInnogy creates a Innogy charger
|
||||
func NewInnogy(uri string, id uint8) (*Innogy, error) {
|
||||
conn, err := modbus.NewConnection(uri, "", "", 0, modbus.TcpFormat, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !sponsor.IsAuthorized() {
|
||||
return nil, api.ErrSponsorRequired
|
||||
}
|
||||
|
||||
log := util.NewLogger("innogy")
|
||||
conn.Logger(log.TRACE)
|
||||
|
||||
wb := &Innogy{
|
||||
conn: conn,
|
||||
}
|
||||
|
||||
return wb, nil
|
||||
}
|
||||
|
||||
// Status implements the api.Charger interface
|
||||
func (wb *Innogy) Status() (api.ChargeStatus, error) {
|
||||
b, err := wb.conn.ReadInputRegisters(igyRegStatus, 2)
|
||||
if err != nil {
|
||||
return api.StatusNone, err
|
||||
}
|
||||
|
||||
switch r := rune(b[0]); r {
|
||||
case 'A', 'B', 'D', 'E', 'F':
|
||||
return api.ChargeStatus(r), nil
|
||||
case 'C':
|
||||
// C1 is "connected"
|
||||
if rune(b[1]) == '1' {
|
||||
return api.StatusB, nil
|
||||
}
|
||||
return api.StatusC, nil
|
||||
default:
|
||||
return api.StatusNone, fmt.Errorf("invalid status: %0x", b[:1])
|
||||
}
|
||||
}
|
||||
|
||||
// Enabled implements the api.Charger interface
|
||||
func (wb *Innogy) Enabled() (bool, error) {
|
||||
b, err := wb.conn.ReadHoldingRegisters(igyRegEnable, 1)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return binary.BigEndian.Uint16(b) > 0, nil
|
||||
}
|
||||
|
||||
// Enable implements the api.Charger interface
|
||||
func (wb *Innogy) Enable(enable bool) error {
|
||||
var u uint16
|
||||
if enable {
|
||||
u = 1
|
||||
}
|
||||
|
||||
_, err := wb.conn.WriteSingleRegister(igyRegEnable, u)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (wb *Innogy) MaxCurrent(current int64) error {
|
||||
return wb.MaxCurrentMillis(float64(current))
|
||||
}
|
||||
|
||||
var _ api.ChargerEx = (*Innogy)(nil)
|
||||
|
||||
// MaxCurrentMillis implements the api.ChargerEx interface
|
||||
func (wb *Innogy) MaxCurrentMillis(current float64) error {
|
||||
if current < 6 {
|
||||
return fmt.Errorf("invalid current %.5g", current)
|
||||
}
|
||||
|
||||
b := make([]byte, 4)
|
||||
binary.BigEndian.PutUint32(b, math.Float32bits(float32(current)))
|
||||
|
||||
for _, reg := range igyRegMaxCurrents {
|
||||
if _, err := wb.conn.WriteMultipleRegisters(reg, 2, b); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ api.MeterCurrent = (*Innogy)(nil)
|
||||
|
||||
// Currents implements the api.MeterCurrent interface
|
||||
func (wb *Innogy) Currents() (float64, float64, float64, error) {
|
||||
var currents []float64
|
||||
for _, regCurrent := range igyRegCurrents {
|
||||
b, err := wb.conn.ReadInputRegisters(regCurrent, 2)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
|
||||
currents = append(currents, float64(math.Float32frombits(binary.BigEndian.Uint32(b))))
|
||||
}
|
||||
|
||||
return currents[0], currents[1], currents[2], nil
|
||||
}
|
||||
|
||||
var _ api.Diagnosis = (*Innogy)(nil)
|
||||
|
||||
// Diagnose implements the Diagnosis interface
|
||||
func (wb *Innogy) Diagnose() {
|
||||
if b, err := wb.conn.ReadInputRegisters(igyRegManufacturer, 25); err == nil {
|
||||
fmt.Printf("Manufacturer:\t%s\n", b)
|
||||
}
|
||||
if b, err := wb.conn.ReadInputRegisters(igyRegID, 25); err == nil {
|
||||
fmt.Printf("Id:\t%s\n", b)
|
||||
}
|
||||
if b, err := wb.conn.ReadInputRegisters(igyRegSerial, 25); err == nil {
|
||||
fmt.Printf("Serial:\t%s\n", b)
|
||||
}
|
||||
if b, err := wb.conn.ReadInputRegisters(igyRegProtocol, 25); err == nil {
|
||||
fmt.Printf("Protocol:\t%s\n", b)
|
||||
}
|
||||
if b, err := wb.conn.ReadInputRegisters(igyRegFirmware, 25); err == nil {
|
||||
fmt.Printf("Firmware:\t%s\n", b)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue