Skip to content

Commit

Permalink
Merge branch 'evcc-io:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Blowfly69 authored May 30, 2024
2 parents 862b535 + f6ba78c commit 08268a1
Show file tree
Hide file tree
Showing 288 changed files with 9,015 additions and 2,135 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ body:
label: Log details
render: text
description: >
Show evcc log output by running with <code>evcc --log debug</code>. The evcc service **MUST** be stopped before running this command.
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.
- type: dropdown
validations:
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ jobs:
- run: mkdir dist && touch dist/empty

- name: Lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v5
with:
version: latest
skip-pkg-cache: true
skip-build-cache: true
args: --out-format=colored-line-number --timeout 5m

ui:
Expand Down Expand Up @@ -179,11 +177,6 @@ jobs:
integration:
name: Integration
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2]
shardTotal: [2]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -226,7 +219,7 @@ jobs:
run: npx playwright install --with-deps chromium

- name: Run tests
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: npx playwright test

# - name: Run tests
# uses: docker://mcr.microsoft.com/playwright:v1.34.3-jammy
Expand All @@ -236,6 +229,6 @@ jobs:
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ matrix.shardIndex }}
name: playwright-report
path: playwright-report/
retention-days: 14
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: make install docs

- name: Deploy to docs repo
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./templates/docs
Expand All @@ -36,4 +36,4 @@ jobs:
destination_dir: ${{ github.event_name == 'release' && 'templates/release' || github.event_name == 'schedule' && 'templates/nightly' || 'templates/unknown_trigger' }}
allow_empty_commit: false
commit_message: ${{ github.event_name == 'release' && 'Templates update for release' || github.event_name == 'schedule' && 'Templates update for nightly' || 'Templates update unknown trigger' }}
if: ${{ success() }}
if: success()
4 changes: 2 additions & 2 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: rm templates/evcc.io/.gitignore

- name: Deploy to evcc.io repo
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./templates/evcc.io/
Expand All @@ -37,4 +37,4 @@ jobs:
destination_dir: data
allow_empty_commit: false
commit_message: Brand data update
if: ${{ success() }}
if: success()
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__debug_bin
__debug_bin*
.vscode
.cache
.DS_store
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ linters:
enable:
- dogsled
- durationcheck
- exportloopref
- gci
- gofmt
- goimports
Expand All @@ -40,6 +39,7 @@ linters:
# fixme
# - bodyclose
# - exhaustive
# - exportloopref
# - gocritic
# - godot
# - gomoddirectives
Expand Down
121 changes: 121 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
## Contributing

### Developing

#### Development environment

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.

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:

```sh
make lint
make lint-ui
```

#### Changing device templates

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.

```sh
make docs
```

If you miss one of the above steps Gitub Actions will likely trigger a **Porcelain** error.

### Building from source

Install prerequisites (once):

```sh
make install-ui
make install
```

Build and run:

```sh
make
./evcc
```

Open UI at http://127.0.0.1:7070

To run without creating the `evcc` binary use:

go run ./...

#### Cross Compiling

To compile a version for an ARM device like a Raspberry Pi set GO command variables as needed, eg:

```sh
GOOS=linux GOARCH=arm GOARM=6 make
```

#### Publishing docker images

```sh
make docker DOCKER_IMAGE=my/docker DOCKER_TAG=0815
```

### Debugging in VS Code

#### evcc Core

To debug a local evcc build in VS Code, add the following entry to your `launch.json`.
You can adjust the referred configuration as needed to e.g. use your live configuration.

```json
{
"name": "Launch evcc local build with demo config",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": ["-c", "${workspaceFolder}/cmd/demo.yaml"],
"cwd": "${workspaceFolder}",
},
```

#### UI

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).

```sh
npm install
npm run dev
```

#### Integration testing

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.

```sh
make ui build
npm run playwright
```

#### Simulating device state

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.

```
npm run simulator
```

Run an evcc instance that uses simulator data. This configuration runs with a very high refresh interval to speed up testing.

```
make ui build
./evcc --config tests/simulator.evcc.yaml
```

### Adding or modifying translations

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.

[![Languages](https://hosted.weblate.org/widgets/evcc/-/evcc/multi-auto.svg)](https://hosted.weblate.org/engage/evcc/)

[1]: https://go.dev
[2]: https://nodejs.org/
86 changes: 3 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,94 +34,17 @@ evcc is an extensible EV Charge Controller and home energy management system. Fe
- logging using [InfluxDB](https://www.influxdata.com) and [Grafana](https://grafana.com/grafana/)
- granular charge power control down to mA steps with supported chargers (labeled by e.g. smartWB as [OLC](https://board.evse-wifi.de/viewtopic.php?f=16&t=187))
- REST and MQTT [APIs](https://docs.evcc.io/docs/reference/api) for integration with home automation systems
- Add-ons for [HomeAssistant](https://github.com/evcc-io/evcc-hassio-addon) and [OpenHAB](https://www.openhab.org/addons/bindings/evcc) (not maintained by the evcc core team)
- Add-ons for [Home Assistant](https://github.com/evcc-io/evcc-hassio-addon) and [OpenHAB](https://www.openhab.org/addons/bindings/evcc) (not maintained by the evcc core team)

## Getting Started

You'll find everything you need in our [documentation](https://docs.evcc.io/).

## Contribute
## Contributing

To build evcc from source, [Go][1] 1.22 and [Node][2] 18 are required.

Build and run go backend. The UI becomes available at http://127.0.0.1:7070/

```sh
make install-ui
make ui
make install
make
./evcc
```

### Cross Compile

To compile a version for an ARM device like a Raspberry Pi set GO command variables as needed, eg:

```sh
GOOS=linux GOARCH=arm GOARM=6 make
```

### UI development

For frontend development start the Vue toolchain in dev-mode. Open http://127.0.0.1:7071/ to get to the livelreloading development server. It pulls its data from port 7070 (see above).

```sh
npm install
npm run dev
```

### Integration tests

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.

```sh
make ui build
npm run playwright
```

#### Simulating device state

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.

```
npm run simulator
```

Run an evcc instance that uses simulator data. This configuration runs with a very high refresh interval to speed up testing.

```
make ui build
./evcc --config tests/simulator.evcc.yaml
```

### Code formatting

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. For VSCode use 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) extension. You can manually reformat your code by running:

```sh
make lint
make lint-ui
```

### Changing templates

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.

```sh
make docs
```

If you miss one of the above steps Gitub Actions will likely trigger a **Porcelain** error.

### Adding or modifying translations

evcc already includes many translations for the UI. Weblate Hosted is used to maintain all languages. Feel free to add more languages or verify and edit existing translations. Weblate will automatically push all modifications on a regular base to the evcc repository.
Technical details on how to contribute, how to add translations and how to build evcc from source can be found [here](CONTRIBUTING.md).

[![Weblate Hosted](https://hosted.weblate.org/widgets/evcc/-/evcc/287x66-grey.png)](https://hosted.weblate.org/engage/evcc/)
[![Languages](https://hosted.weblate.org/widgets/evcc/-/evcc/multi-auto.svg)](https://hosted.weblate.org/engage/evcc/)

https://hosted.weblate.org/projects/evcc/evcc/

## Sponsorship

Expand All @@ -133,6 +56,3 @@ Maintaining evcc consumes time and effort. With the vast amount of different dev
While evcc is open source, we would also like to encourage vendors to provide open source hardware devices, public documentation and support open source projects like ours that provide additional value to otherwise closed hardware. Where this is not the case, evcc requires "sponsor token" to finance ongoing development and support of evcc.

The personal sponsor token requires a [Github Sponsorship](https://github.com/sponsors/evcc-io) and can be requested at [sponsor.evcc.io](https://sponsor.evcc.io/).

[1]: https://go.dev
[2]: https://nodejs.org/
31 changes: 30 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"
)

//go:generate mockgen -package api -destination mock.go github.com/evcc-io/evcc/api Charger,ChargeState,CurrentLimiter,PhaseSwitcher,Identifier,Meter,MeterEnergy,Vehicle,ChargeRater,Battery,Tariff,BatteryController
//go:generate mockgen -package api -destination mock.go github.com/evcc-io/evcc/api Charger,ChargeState,CurrentLimiter,PhaseSwitcher,Identifier,Meter,MeterEnergy,PhaseCurrents,Vehicle,ChargeRater,Battery,Tariff,BatteryController,Circuit

// Meter provides total active power in W
type Meter interface {
Expand Down Expand Up @@ -202,3 +202,32 @@ type FeatureDescriber interface {
type CsvWriter interface {
WriteCsv(context.Context, io.Writer) error
}

// CircuitMeasurements is the measurements a circuit or load must deliver
type CircuitMeasurements interface {
GetChargePower() float64
GetMaxPhaseCurrent() float64
}

// CircuitLoad represents a loadpoint attached to a circuit
type CircuitLoad interface {
CircuitMeasurements
GetCircuit() Circuit
}

// Circuit defines the load control domain
type Circuit interface {
CircuitMeasurements
GetTitle() string
SetTitle(string)
GetParent() Circuit
RegisterChild(child Circuit)
HasMeter() bool
GetMaxPower() float64
GetMaxCurrent() float64
SetMaxPower(float64)
SetMaxCurrent(float64)
Update([]CircuitLoad) error
ValidateCurrent(old, new float64) float64
ValidatePower(old, new float64) float64
}
1 change: 0 additions & 1 deletion api/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ const (
IntegratedDevice
Heating
Retryable
WelcomeCharge
)
Loading

0 comments on commit 08268a1

Please sign in to comment.