Skip to content

Commit

Permalink
Configure: fix handling of PV systems (evcc-io#4806)
Browse files Browse the repository at this point in the history
- The configure intents to present devices that implement multiple usages in a single device or have linked templates and provide an easier step by step configuration experience e.g. by not asking for the same data for different usages over and over again
- Commit 8805575 changes this behaviour and now presents all devices that have multiple usages, e.g. meters that could be used as battery or pv meter
- This change introduces a new property `allineone` that should be used with the `usage` `param` the identify a device that implements multiple usages in the same device
- The filter to present these devices is extended by checking for this property
  • Loading branch information
DerAndereAndi authored Oct 13, 2022
1 parent ebf53d1 commit d408767
Show file tree
Hide file tree
Showing 34 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ Example Use Case: With SMA Home Manager, there can be a SMA Energy Meter used fo
- `usage`: specifies a list of meter classes, the device can be used for. Possible values are `grid`, `pv`, `battery`, and `charger`
- `modbus`: specifies that this device is accessed via modbus. It requires the `choice` property to have a list of possible interface values the device provides. These values can be `rs485` and `tcpip`. The command will use either to ask the appropriate questions and settings. The `render` section needs to include the string `{{include "modbus" .}}` in all places where the configuration needs modbus settings.

#### Usage Options

- `allineone`: Defines if the different usages are all available in a single device. Enables `guidedsetup` mode.

#### Modbus Options

- `id`: Device specific default for modbus ID
Expand Down
3 changes: 3 additions & 0 deletions templates/definition/common-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
"type": "string",
"enum": ["charge", "grid", "pv", "battery"]
}
},
"allinone": {
"type": "boolean"
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/e3dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/fronius-gen24.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/fronius-solarapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
render: |
type: custom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: modbus
choice: ["tcpip"]
render: |
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/kostal-piko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
render: |
type: custom
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/kostal-plenticore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ linked:
params:
- name: usage
choice: ["pv", "battery"]
allinone: true
- name: modbus
choice: ["tcpip"]
id: 71
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/lg-ess-home-8-10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: registration
required: true
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/openems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: password
mask: true
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/powerdog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ products:
params:
- name: usage
choice: ["grid", "pv"]
allinone: true
- name: modbus
choice: ["tcpip"]
render: |
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/rct-power.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
render: |
type: rct
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/senec-home.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
render: |
type: custom
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/sma-datamanager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ requirements:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/sma-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ products:
params:
- name: usage
choice: ["pv", "battery"]
allinone: true
- name: modbus
choice: ["tcpip"]
port: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solaredge-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ requirements:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solaredge-inverter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ products:
params:
- name: usage
choice: ["grid", "pv"]
allinone: true
- name: modbus
choice: ["tcpip"]
id: 1
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solarlog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ requirements:
params:
- name: usage
choice: ["grid", "pv"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solarmax-maxstorage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: modbus
choice: ["tcpip"]
id: 1
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solarwatt-myreserve-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 8080
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solarwatt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
render: |
type: custom
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solax-hybrid-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ requirements:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: tokenid
required: true
description:
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/solax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: modbus
choice: ["rs485", "tcpip"]
baudrate: 19200
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/sonnenbatterie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 8080
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/sungrow-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ requirements:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: modbus
choice: ["rs485", "tcpip"]
baudrate: 9600
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/sungrow-inverter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ requirements:
params:
- name: usage
choice: ["grid", "pv"]
allinone: true
- name: modbus
choice: ["rs485", "tcpip"]
baudrate: 9600
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/sunspec-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ group: generic
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: modbus
choice: ["tcpip"]
- name: integer
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/sunspec-inverter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ group: generic
params:
- name: usage
choice: ["grid", "pv"]
allinone: true
- name: modbus
choice: ["tcpip"]
- name: integer
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/tesla-powerwall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: password
required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ products:
params:
- name: usage
choice: ["grid", "battery"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/varta-energiespeicher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
1 change: 1 addition & 0 deletions templates/definition/meter/victron-energy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ products:
params:
- name: usage
choice: ["grid", "pv", "battery"]
allinone: true
- name: host
- name: port
default: 502
Expand Down
2 changes: 1 addition & 1 deletion util/templates/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Template struct {
// GuidedSetupEnabled returns true if there are linked templates or >1 usage
func (t *Template) GuidedSetupEnabled() bool {
_, p := t.ParamByName(ParamUsage)
return len(t.Linked) > 0 || len(p.Choice) > 1
return len(t.Linked) > 0 || (len(p.Choice) > 1 && p.AllInOne)
}

// UpdateParamWithDefaults adds default values to specific param name entries
Expand Down
1 change: 1 addition & 0 deletions util/templates/template_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ type Param struct {
ValueType string // string representation of the value type, "string" is default
ValidValues []string // list of valid values the user can provide
Choice []string // defines a set of choices, e.g. "grid", "pv", "battery", "charge" for "usage"
AllInOne bool // defines if the defined usages can all be present in a single device
Requirements Requirements // requirements for this param to be usable, only supported via ValueType "bool"

Baudrate int // device specific default for modbus RS485 baudrate
Expand Down

0 comments on commit d408767

Please sign in to comment.