Skip to content

Commit

Permalink
Merge branch 'master' into fix-12640
Browse files Browse the repository at this point in the history
* master: (43 commits)
  Translations update from Hosted Weblate (evcc-io#13257)
  sungrow charger: fix product name
  sungrow charger: fix default id
  InfluxDB: fix vehicle limit soc data type
  chore: speed-up post lint (evcc-io#13340)
  Custom vehicle: add FinishTimer (evcc-io#13338)
  chore: make generate organize imports (evcc-io#13337)
  Easee: change default timeout to 20s (evcc-io#13321)
  Chore: playwright sharding (evcc-io#13318)
  SmartCostLimit: allow negative limits (evcc-io#13317)
  Kia: fix status
  Easee: validate charger phases (evcc-io#13238)
  chore: switch to actions/cache (evcc-io#13308)
  Chore: docs test pr (evcc-io#13309)
  chore: create doc issue on pr merge
  Add Sungrow AC011E-01 charger (evcc-io#13247)
  Volkszaehler: fix uuids starting with 0
  Fix limiting PV current when scaling phases up (evcc-io#13295)
  chore: avoid warning (evcc-io#13253)
  solax charger: fix enable/enabled
  ...
  • Loading branch information
mabunixda committed Apr 10, 2024
2 parents b10969c + a3b0d7c commit 8c02225
Show file tree
Hide file tree
Showing 102 changed files with 20,487 additions and 1,615 deletions.
93 changes: 80 additions & 13 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ jobs:
steps:
- uses: actions/checkout@v4

# - uses: actions/setup-go@v5
- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: clean-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-clean-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-clean-
${{ runner.os }}-go-
- name: Install tools
run: make install

Expand All @@ -47,12 +56,22 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: build-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
${{ runner.os }}-go-
- uses: actions/setup-node@v4
with:
node-version: "18"
Expand All @@ -70,13 +89,22 @@ jobs:
steps:
- uses: actions/checkout@v4

# - uses: actions/setup-go@v5
- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: test-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-test-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-test-
${{ runner.os }}-go-
- name: Test
run: mkdir dist && touch dist/empty && make test

Expand All @@ -93,12 +121,24 @@ jobs:
cache: false # avoid cache thrashing
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-lint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-lint-
${{ runner.os }}-go-
- run: mkdir dist && touch dist/empty

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

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

steps:
- uses: actions/checkout@v4

- uses: erezrokah/setup-go@feat/add_cache_prefix
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-key-prefix: integration-cache-
cache: false
id: go

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-integration-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-integration-
${{ runner.os }}-go-
- uses: actions/setup-node@v4
with:
node-version: "18"
Expand All @@ -160,15 +215,27 @@ jobs:
- name: Build Go
run: make build

- uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}

- name: Install playwright
run: npx playwright install --with-deps chromium

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

# - name: Run tests
# uses: docker://mcr.microsoft.com/playwright:v1.34.3-jammy
# with:
# args: npx playwright test

- uses: actions/upload-artifact@v4
if: always()
if: ${{ !cancelled() }}
with:
name: playwright-report
name: playwright-report-${{ matrix.shardIndex }}
path: playwright-report/
retention-days: 14
42 changes: 42 additions & 0 deletions .github/workflows/docs-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Create Documentation Issue

on:
pull_request_target:
types: [closed]
branches: [master]

jobs:
check-label-and-create-issue:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Check for 'needs documentation' label
id: check-label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const hasLabel = labels.some(label => label.name === 'needs documentation');
return hasLabel;
result-encoding: string

- name: Create Docs Issue
if: steps.check-label.outputs.result == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const title = `Document: ${context.payload.pull_request.title}`;
const body = `We need to document the new feature introduced in this PR: ${context.payload.pull_request.html_url}`;
await github.rest.issues.create({
owner: 'evcc-io',
repo: 'docs',
title: title,
body: body
});
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ npm run playwright

#### Simulating device state

Since we dont want to run tests agains 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.
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
Expand Down
4 changes: 4 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ type PhaseSwitcher interface {
Phases1p3p(phases int) error
}

type PhaseGetter interface {
GetPhases() (int, error)
}

// Diagnosis is a helper interface that allows to dump diagnostic data to console
type Diagnosis interface {
Diagnose()
Expand Down
11 changes: 3 additions & 8 deletions api/chargemode.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ func ChargeModeString(mode string) (ChargeMode, error) {
var _ encoding.TextUnmarshaler = (*ChargeMode)(nil)

func (c *ChargeMode) UnmarshalText(text []byte) error {
casted, err := ChargeModeString(string(text))
if err != nil {
return err
}

*c = casted

return nil
var err error
*c, err = ChargeModeString(string(text))
return err
}
10 changes: 1 addition & 9 deletions api/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ package api

type Feature int

func (f *Feature) UnmarshalText(text []byte) error {
feat, err := FeatureString(string(text))
if err == nil {
*f = feat
}
return err
}

//go:generate enumer -type Feature
//go:generate enumer -type Feature -text
const (
_ Feature = iota
Offline
Expand Down
14 changes: 13 additions & 1 deletion api/feature_enumer.go

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

9 changes: 8 additions & 1 deletion assets/js/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from "axios";
import { openLoginModal } from "./auth";

const { protocol, hostname, port, pathname } = window.location;

Expand All @@ -15,13 +16,19 @@ const api = axios.create({
api.interceptors.response.use(
(response) => response,
(error) => {
// handle unauthorized errors
if (error.response?.status === 401) {
openLoginModal();
return Promise.reject(error);
}

const message = [`${error.message}.`];
if (error.response?.data?.error) {
message.push(`${error.response.data.error}.`);
}
if (error.config) {
const method = error.config.method.toUpperCase();
const url = error.config.baseURL + error.config.url;
const url = error.request.responseURL;
message.push(`${method} ${url}`);
}
window.app.raise({ message });
Expand Down
58 changes: 58 additions & 0 deletions assets/js/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { reactive, watch } from "vue";
import api from "./api";
import Modal from "bootstrap/js/dist/modal";

const auth = reactive({
configured: true,
loggedIn: false,
});

export async function updateAuthStatus() {
try {
const res = await api.get("/auth/status", {
validateStatus: (code) => [200, 501].includes(code),
});
if (res.status === 501) {
auth.configured = false;
}
if (res.status === 200) {
auth.configured = true;
auth.loggedIn = res.data === true;
}
} catch (e) {
console.log("unable to fetch auth status", e);
}
}

export async function logout() {
try {
await api.post("/auth/logout");
await updateAuthStatus();
} catch (e) {
console.log("unable to logout", e);
}
}

export function isLoggedIn() {
return auth.loggedIn;
}

export function isConfigured() {
return auth.configured;
}

export function openLoginModal() {
const modal = Modal.getOrCreateInstance(document.getElementById("loginModal"));
modal.show();
}

// show/hide password modal based on auth status
watch(
() => auth.configured,
(configured) => {
const modal = Modal.getOrCreateInstance(document.getElementById("passwordModal"));
configured ? modal.hide() : modal.show();
}
);

export default auth;
6 changes: 3 additions & 3 deletions assets/js/components/ChargingPlan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<span class="targetTimeLabel"> {{ targetTimeLabel() }}</span>
<div
class="extraValue text-nowrap"
:class="{ 'text-warning': planOverrun }"
:class="{ 'text-warning': planTimeUnreachable }"
>
{{ targetSocLabel }}
</div>
Expand Down Expand Up @@ -125,7 +125,7 @@ export default {
planActive: Boolean,
planEnergy: Number,
planTime: String,
planOverrun: Boolean,
planTimeUnreachable: Boolean,
rangePerSoc: Number,
smartCostLimit: Number,
smartCostType: String,
Expand All @@ -146,7 +146,7 @@ export default {
},
computed: {
buttonColor: function () {
if (this.planOverrun) {
if (this.planTimeUnreachable) {
return "text-warning";
}
if (!this.enabled) {
Expand Down

0 comments on commit 8c02225

Please sign in to comment.