Skip to content

Commit 1c62eec

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents be9ed72 + d8875bf commit 1c62eec

355 files changed

Lines changed: 10932 additions & 4182 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ body:
4747
label: Log details
4848
render: text
4949
description: >
50-
Show evcc log output by running with <code>evcc --log debug</code>. The evcc service **MUST** be stopped before running this command.
50+
Show evcc log output of the issue, see https://docs.evcc.io/en/docs/faq#how-do-i-create-a-log-file-for-error-analysis for instructions.
5151
5252
- type: dropdown
5353
validations:

.github/workflows/default.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
- run: mkdir dist && touch dist/empty
135135

136136
- name: Lint
137-
uses: golangci/golangci-lint-action@v5
137+
uses: golangci/golangci-lint-action@v6
138138
with:
139139
version: latest
140140
args: --out-format=colored-line-number --timeout 5m
@@ -177,11 +177,6 @@ jobs:
177177
integration:
178178
name: Integration
179179
runs-on: ubuntu-latest
180-
strategy:
181-
fail-fast: false
182-
matrix:
183-
shardIndex: [1, 2]
184-
shardTotal: [2]
185180

186181
steps:
187182
- uses: actions/checkout@v4
@@ -224,7 +219,7 @@ jobs:
224219
run: npx playwright install --with-deps chromium
225220

226221
- name: Run tests
227-
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
222+
run: npx playwright test
228223

229224
# - name: Run tests
230225
# uses: docker://mcr.microsoft.com/playwright:v1.34.3-jammy
@@ -234,6 +229,6 @@ jobs:
234229
- uses: actions/upload-artifact@v4
235230
if: ${{ !cancelled() }}
236231
with:
237-
name: playwright-report-${{ matrix.shardIndex }}
232+
name: playwright-report
238233
path: playwright-report/
239234
retention-days: 14

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ __debug_bin*
1010
!templates/**/*.yaml
1111
!templates/**/*-schema.json
1212
!util/templates/**/*.yaml
13+
!assets/js/**/*.yaml
1314
!package*.json
1415
!evcc.dist.yaml
1516
!tests/**/*.evcc.yaml

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ linters:
1616
enable:
1717
- dogsled
1818
- durationcheck
19-
- exportloopref
2019
- gci
2120
- gofmt
2221
- goimports
@@ -40,6 +39,7 @@ linters:
4039
# fixme
4140
# - bodyclose
4241
# - exhaustive
42+
# - exportloopref
4343
# - gocritic
4444
# - godot
4545
# - gomoddirectives

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ brews:
9696
commit_author:
9797
name: andig
9898
email: cpuidle@gmx.de
99-
folder: Formula
99+
directory: Formula
100100
homepage: "https://evcc.io"
101101
description: "Sonne tanken ☀️🚘"
102102
license: "MIT"

CONTRIBUTING.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
## Contributing
2+
3+
### Developing
4+
5+
#### Development environment
6+
7+
Developing evcc requires [Go][1] 1.22 and [Node][2] 18. We recommend VSCode with the [Go](https://marketplace.visualstudio.com/items?itemName=golang.Go), [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) and [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur) extensions.
8+
9+
We use linters (golangci-lint, Prettier) to keep a coherent source code formatting. It's recommended to use the format-on-save feature of your editor. You can manually reformat your code by running:
10+
11+
```sh
12+
make lint
13+
make lint-ui
14+
```
15+
16+
#### Changing device templates
17+
18+
evcc supports a massive amount of different devices. To keep our documentation and website in sync with the latest software the core project (this repo) generates meta-data that's pushed to the `docs` and `evcc.io` repository. Make sure to update this meta-data every time you make changes to a templates.
19+
20+
```sh
21+
make docs
22+
```
23+
24+
If you miss one of the above steps Gitub Actions will likely trigger a **Porcelain** error.
25+
26+
### Building from source
27+
28+
Install prerequisites (once):
29+
30+
```sh
31+
make install-ui
32+
make install
33+
```
34+
35+
Build and run:
36+
37+
```sh
38+
make
39+
./evcc
40+
```
41+
42+
Open UI at http://127.0.0.1:7070
43+
44+
To run without creating the `evcc` binary use:
45+
46+
go run ./...
47+
48+
#### Cross Compiling
49+
50+
To compile a version for an ARM device like a Raspberry Pi set GO command variables as needed, eg:
51+
52+
```sh
53+
GOOS=linux GOARCH=arm GOARM=6 make
54+
```
55+
56+
#### Publishing docker images
57+
58+
```sh
59+
make docker DOCKER_IMAGE=my/docker DOCKER_TAG=0815
60+
```
61+
62+
### Debugging in VS Code
63+
64+
#### evcc Core
65+
66+
To debug a local evcc build in VS Code, add the following entry to your `launch.json`.
67+
You can adjust the referred configuration as needed to e.g. use your live configuration.
68+
69+
```json
70+
{
71+
"name": "Launch evcc local build with demo config",
72+
"type": "go",
73+
"request": "launch",
74+
"mode": "auto",
75+
"program": "${workspaceFolder}",
76+
"args": ["-c", "${workspaceFolder}/cmd/demo.yaml"],
77+
"cwd": "${workspaceFolder}",
78+
},
79+
```
80+
81+
#### UI
82+
83+
For frontend development start the Vue toolchain in dev-mode. Open http://127.0.0.1:7071/ to get to the live reloading development server. It pulls its data from port 7070 (see above).
84+
85+
```sh
86+
npm install
87+
npm run dev
88+
```
89+
90+
#### Integration testing
91+
92+
We use Playwright for end-to-end integration tests. They start a local evcc instance with different configuration yamls and prefilled databases. To run them, you have to do a local build first.
93+
94+
```sh
95+
make ui build
96+
npm run playwright
97+
```
98+
99+
#### Simulating device state
100+
101+
Since we don't want to run tests against real devices or cloud services, we've build a simple simulator that lets you emulated meters, vehicles and loadpoints. The simulators web interface runs on http://localhost:7072.
102+
103+
```
104+
npm run simulator
105+
```
106+
107+
Run an evcc instance that uses simulator data. This configuration runs with a very high refresh interval to speed up testing.
108+
109+
```
110+
make ui build
111+
./evcc --config tests/simulator.evcc.yaml
112+
```
113+
114+
### Adding or modifying translations
115+
116+
evcc already includes many translations for the UI. We're using [Weblate](https://hosted.weblate.org/projects/evcc/evcc/) to maintain translations. Feel free to add more languages or verify and edit existing translations. Weblate will automatically push all modifications to the evcc repository where they get reviewed and merged.
117+
118+
[![Languages](https://hosted.weblate.org/widgets/evcc/-/evcc/multi-auto.svg)](https://hosted.weblate.org/engage/evcc/)
119+
120+
[1]: https://go.dev
121+
[2]: https://nodejs.org/

api/globalconfig/types.go

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
package globalconfig
2+
3+
import (
4+
"fmt"
5+
"net"
6+
"strconv"
7+
"time"
8+
9+
"github.com/evcc-io/evcc/charger/eebus"
10+
"github.com/evcc-io/evcc/provider/mqtt"
11+
"github.com/evcc-io/evcc/push"
12+
"github.com/evcc-io/evcc/util/config"
13+
"github.com/evcc-io/evcc/util/modbus"
14+
)
15+
16+
type All struct {
17+
Network Network
18+
Log string
19+
SponsorToken string
20+
Plant string // telemetry plant id
21+
Telemetry bool
22+
Metrics bool
23+
Profile bool
24+
Levels map[string]string
25+
Interval time.Duration
26+
Database DB
27+
Mqtt Mqtt
28+
ModbusProxy []ModbusProxy
29+
Javascript []Javascript
30+
Go []Go
31+
Influx Influx
32+
EEBus eebus.Config
33+
HEMS config.Typed
34+
Messaging Messaging
35+
Meters []config.Named
36+
Chargers []config.Named
37+
Vehicles []config.Named
38+
Tariffs Tariffs
39+
Site map[string]interface{}
40+
Loadpoints []map[string]interface{}
41+
Circuits []config.Named
42+
}
43+
44+
type Javascript struct {
45+
VM string
46+
Script string
47+
}
48+
49+
type Go struct {
50+
VM string
51+
Script string
52+
}
53+
54+
type ModbusProxy struct {
55+
Port int
56+
ReadOnly string
57+
modbus.Settings `mapstructure:",squash"`
58+
}
59+
60+
type Mqtt struct {
61+
mqtt.Config `mapstructure:",squash"`
62+
Topic string `json:"topic"`
63+
}
64+
65+
// Redacted implements the redactor interface used by the tee publisher
66+
func (m Mqtt) Redacted() any {
67+
// TODO add masked password
68+
return struct {
69+
Broker string `json:"broker"`
70+
Topic string `json:"topic"`
71+
User string `json:"user"`
72+
ClientID string `json:"clientID"`
73+
Insecure bool `json:"insecure"`
74+
}{
75+
Broker: m.Broker,
76+
Topic: m.Topic,
77+
User: m.User,
78+
ClientID: m.ClientID,
79+
Insecure: m.Insecure,
80+
}
81+
}
82+
83+
// Influx is the influx db configuration
84+
type Influx struct {
85+
URL string `json:"url"`
86+
Database string `json:"database"`
87+
Token string `json:"token"`
88+
Org string `json:"org"`
89+
User string `json:"user"`
90+
Password string `json:"password"`
91+
}
92+
93+
// Redacted implements the redactor interface used by the tee publisher
94+
func (c Influx) Redacted() any {
95+
// TODO add masked password
96+
return struct {
97+
URL string `json:"url"`
98+
Database string `json:"database"`
99+
Org string `json:"org"`
100+
User string `json:"user"`
101+
}{
102+
URL: c.URL,
103+
Database: c.Database,
104+
Org: c.Org,
105+
User: c.User,
106+
}
107+
}
108+
109+
type DB struct {
110+
Type string
111+
Dsn string
112+
}
113+
114+
type Messaging struct {
115+
Events map[string]push.EventTemplateConfig
116+
Services []config.Typed
117+
}
118+
119+
type Tariffs struct {
120+
Currency string
121+
Grid config.Typed
122+
FeedIn config.Typed
123+
Co2 config.Typed
124+
Planner config.Typed
125+
}
126+
127+
type Network struct {
128+
Schema string `json:"schema"`
129+
Host string `json:"host"`
130+
Port int `json:"port"`
131+
}
132+
133+
func (c Network) HostPort() string {
134+
if c.Schema == "http" && c.Port == 80 || c.Schema == "https" && c.Port == 443 {
135+
return c.Host
136+
}
137+
return net.JoinHostPort(c.Host, strconv.Itoa(c.Port))
138+
}
139+
140+
func (c Network) URI() string {
141+
return fmt.Sprintf("%s://%s", c.Schema, c.HostPort())
142+
}

0 commit comments

Comments
 (0)