Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename modbus meter to mbmd #11665

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: rename modbus meter to mbmd
  • Loading branch information
andig committed Jan 13, 2024
commit a88c95dce8c47c3bb63d91bd6cf35d45addbb215
2 changes: 1 addition & 1 deletion evcc.dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ modbusproxy:
# for documentation see https://docs.evcc.io/docs/devices/meters
meters:
- name: grid
type: modbus
type: mbmd
model: sdm # SDM630
uri: rs485.fritz.box:23
rtu: true # rs485 device connected using ethernet adapter
Expand Down
24 changes: 12 additions & 12 deletions meter/modbus.go → meter/mbmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/volkszaehler/mbmd/meters/sunspec"
)

// Modbus is an api.Meter implementation with configurable getters and setters.
type Modbus struct {
// ModbusMbmd is an api.Meter implementation with configurable getters and setters.
type ModbusMbmd struct {
conn *modbus.Connection
device meters.Device
opPower modbus.Operation
Expand All @@ -23,13 +23,13 @@ type Modbus struct {
}

func init() {
registry.Add("modbus", NewModbusFromConfig)
registry.Add("mbmd", NewModbusMbmdFromConfig)
}

//go:generate go run ../cmd/tools/decorate.go -f decorateModbus -b api.Meter -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.PhasePowers,Powers,func() (float64, float64, float64, error)" -t "api.Battery,Soc,func() (float64, error)" -t "api.BatteryCapacity,Capacity,func() float64"

// NewModbusFromConfig creates api.Meter from config
func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
// NewModbusMbmdFromConfig creates api.Meter from config
func NewModbusMbmdFromConfig(other map[string]interface{}) (api.Meter, error) {
cc := struct {
Model string
capacity `mapstructure:",squash"`
Expand Down Expand Up @@ -91,7 +91,7 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
return nil, err
}

m := &Modbus{
m := &ModbusMbmd{
conn: conn,
device: device,
}
Expand Down Expand Up @@ -138,10 +138,10 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
soc = m.soc
}

return decorateModbus(m, totalEnergy, currentsG, voltagesG, powersG, soc, cc.capacity.Decorator()), nil
return decorateModbusMbmd(m, totalEnergy, currentsG, voltagesG, powersG, soc, cc.capacity.Decorator()), nil
}

func (m *Modbus) buildPhaseProviders(readings []string) (func() (float64, float64, float64, error), error) {
func (m *ModbusMbmd) buildPhaseProviders(readings []string) (func() (float64, float64, float64, error), error) {
var res func() (float64, float64, float64, error)
if len(readings) > 0 {
if len(readings) != 3 {
Expand Down Expand Up @@ -170,7 +170,7 @@ func (m *Modbus) buildPhaseProviders(readings []string) (func() (float64, float6
}

// floatGetter executes configured modbus read operation and implements func() (float64, error)
func (m *Modbus) floatGetter(op modbus.Operation) (float64, error) {
func (m *ModbusMbmd) floatGetter(op modbus.Operation) (float64, error) {
var res meters.MeasurementResult
var err error

Expand Down Expand Up @@ -201,16 +201,16 @@ func (m *Modbus) floatGetter(op modbus.Operation) (float64, error) {
}

// CurrentPower implements the api.Meter interface
func (m *Modbus) CurrentPower() (float64, error) {
func (m *ModbusMbmd) CurrentPower() (float64, error) {
return m.floatGetter(m.opPower)
}

// totalEnergy implements the api.MeterEnergy interface
func (m *Modbus) totalEnergy() (float64, error) {
func (m *ModbusMbmd) totalEnergy() (float64, error) {
return m.floatGetter(m.opEnergy)
}

// soc implements the api.Battery interface
func (m *Modbus) soc() (float64, error) {
func (m *ModbusMbmd) soc() (float64, error) {
return m.floatGetter(m.opSoc)
}
2 changes: 1 addition & 1 deletion meter/modbus_decorators.go → meter/mbmd_decorators.go

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

2 changes: 1 addition & 1 deletion templates/definition/meter/abb-ab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: abb
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/be-mpm3pm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: MPM
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/cg-em24.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485", "tcpip"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: cgem24
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/cg-emt3xx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485", "tcpip"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: cgex3x0
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/dzg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: dzg
power: ImportPower
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/eastron-sdm120.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: sdm
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/eastron-sdm220_230.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: sdm220
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/eastron-sdm72.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: sdm72
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/eastron-sdm72v2_630.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: sdm
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/fronius-gen24.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ params:
render: |
# reference: https://github.com/volkszaehler/mbmd/blob/master/meters/sunspec/models.go
{{- if eq .usage "grid" }}
type: modbus
type: mbmd
uri: {{ .host }}:{{ .port }}
id: 200
model: sunspec
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/inepro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: inepro
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/janitza.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485", "tcpip"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: janitza
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/keba-kecontact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ params:
choice: ["tcpip"]
id: 1
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: sunspec
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/kostal-ksem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ params:
choice: ["tcpip"]
id: 71
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: sunspec
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/orno.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: orno3p
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/sbc-axx3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: sbc
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/schneider-iem3000.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: iem3000
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/siemens-pac2200.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ params:
- name: modbus
choice: ["rs485", "tcpip"]
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
model: pac2200
power: Power
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/sunspec-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ params:
advanced: true
render: |
{{- if eq .usage "grid" }}
type: modbus
type: mbmd
{{- include "modbus" . }}
{{- if eq .integer "true" }}
# sunspec model 203 (int+sf) meter
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/meter/sunspec-inverter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ params:
- name: capacity
advanced: true
render: |
type: modbus
type: mbmd
{{- include "modbus" . }}
{{- if eq .usage "grid" }}
model: sunspec
Expand Down
Loading