From f0298922036edcc871ff4882af54b70e9f445606 Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Fri, 23 Jun 2023 12:13:14 +0200 Subject: [PATCH 1/9] adjust GHA config to my local repo --- .github/workflows/nightly.yml | 45 ++--------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2c2b6458da..9121350df2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -32,7 +32,7 @@ jobs: ${{ needs.check_date.outputs.should_run != 'false' }} && startsWith(github.ref, 'refs/heads/master') && ! contains(github.head_ref, 'refs/heads/chore/') - uses: evcc-io/evcc/.github/workflows/default.yml@master + uses: grimmimeloni/evcc/.github/workflows/default.yml@master docker: name: Publish Docker :nightly @@ -69,46 +69,5 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v6 push: true tags: | - evcc/evcc:nightly + grimmimeloni/evcc:nightly - apt: - name: Publish APT nightly - needs: - - call-build-workflow - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - id: go - - - name: Install Cloudsmith CLI - run: pip install --upgrade cloudsmith-cli - - - name: Patch ASN1 - run: make patch-asn1-sudo - - - name: Get dist from cache - uses: actions/cache/restore@v3 - id: cache-dist - with: - path: dist - key: ${{ runner.os }}-${{ github.sha }}-dist - - - name: Create nightly build - uses: goreleaser/goreleaser-action@v4 - with: - version: latest - args: --snapshot -f .goreleaser-nightly.yml --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish .deb to Cloudsmith - env: - CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} - run: make apt-nightly From f6df98245db53a8bac3e43f41e1a874559a234d9 Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Fri, 23 Jun 2023 13:22:32 +0200 Subject: [PATCH 2/9] make linter happy --- .github/workflows/nightly.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9121350df2..6d12af1ef4 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -70,4 +70,3 @@ jobs: push: true tags: | grimmimeloni/evcc:nightly - From e5acc87d011bfd09da9b541ded432d505b1dde2b Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Sun, 25 Jun 2023 22:53:36 +0200 Subject: [PATCH 3/9] do not force master branch --- .github/workflows/nightly.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6d12af1ef4..2ecf94d82b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -43,7 +43,6 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: refs/heads/master # force master fetch-depth: 0 - name: Get dist from cache From dceea06a36f8812b9e3c38c7ec5bc0f8a897a0a0 Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Tue, 25 Jul 2023 13:09:43 +0200 Subject: [PATCH 4/9] make docker image tag match branch --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2ecf94d82b..c90c8af57c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -68,4 +68,4 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v6 push: true tags: | - grimmimeloni/evcc:nightly + grimmimeloni/evcc:${{ github.ref_name }} From c1922e5b26bfa44e8c79d00789a6f41e8d8620ed Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Wed, 15 Nov 2023 21:06:25 +0100 Subject: [PATCH 5/9] add apt build and cloudsmith distro back in --- .github/workflows/nightly.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c90c8af57c..334118a436 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -69,3 +69,45 @@ jobs: push: true tags: | grimmimeloni/evcc:${{ github.ref_name }} + + apt: + name: Publish APT nightly + needs: + - call-build-workflow + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + id: go + + - name: Install Cloudsmith CLI + run: pip install --upgrade cloudsmith-cli + + - name: Patch ASN1 + run: make patch-asn1-sudo + + - name: Get dist from cache + uses: actions/cache/restore@v3 + id: cache-dist + with: + path: dist + key: ${{ runner.os }}-${{ github.sha }}-dist + + - name: Create nightly build + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: --snapshot -f .goreleaser-nightly.yml --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish .deb to Cloudsmith + env: + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} + run: make apt-nightly \ No newline at end of file From cb61ff85e9006ec54618bb2415a95b1d4e1b0365 Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Thu, 16 Nov 2023 08:09:45 +0100 Subject: [PATCH 6/9] fix glasware --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 334118a436..7782dc5cd2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -110,4 +110,4 @@ jobs: - name: Publish .deb to Cloudsmith env: CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} - run: make apt-nightly \ No newline at end of file + run: make apt-nightly From 266af66fecb3e214ce931ec8a3f7210f246132ea Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Thu, 16 Nov 2023 20:47:04 +0100 Subject: [PATCH 7/9] adjust makefile to push in forked deb repo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c8a26dcf2e..a9395e2c26 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ publish-release:: apt-nightly:: $(foreach file, $(wildcard $(PACKAGES)/*.deb), \ - cloudsmith push deb evcc/unstable/any-distro/any-version $(file); \ + cloudsmith push deb grimmimeloni/evcc/any-distro/any-version $(file); \ ) apt-release:: From 9be171a29a405d1ef2147eaa520a3484a9ea9cc1 Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Sat, 16 Dec 2023 10:21:34 +0100 Subject: [PATCH 8/9] poll chargerOpMode on demand --- charger/easee.go | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/charger/easee.go b/charger/easee.go index a3d0e03784..6c2984934f 100644 --- a/charger/easee.go +++ b/charger/easee.go @@ -47,6 +47,7 @@ type Easee struct { site, circuit int updated time.Time lastEnergyPollTriggered time.Time + lastOpModePollTriggered time.Time log *util.Logger mux sync.Mutex lastEnergyPollMux sync.Mutex @@ -58,6 +59,7 @@ type Easee struct { authorize bool enabled bool opMode int + pilotMode string reasonForNoCurrent int phaseMode int sessionStartEnergy *float64 @@ -243,11 +245,6 @@ func (c *Easee) subscribe(client signalr.Client) { if err := <-client.Send("SubscribeWithCurrentState", c.charger, true); err != nil { c.log.ERROR.Printf("SubscribeWithCurrentState: %v", err) } - // poll opMode from charger as API can give outdated initial data after (re)connect - uri := fmt.Sprintf("%s/chargers/%s/commands/poll_chargeropmode", easee.API, c.charger) - if _, err := c.Post(uri, request.JSONContent, nil); err != nil { - c.log.WARN.Printf("failed to poll CHARGER_OP_MODE, results may vary: %v", err) - } } } }() @@ -375,6 +372,8 @@ func (c *Easee) ProductUpdate(i json.RawMessage) { case easee.REASON_FOR_NO_CURRENT: c.reasonForNoCurrent = value.(int) + case easee.PILOT_MODE: + c.pilotMode = value.(string) } select { @@ -414,6 +413,7 @@ func (c *Easee) chargers() ([]easee.Charger, error) { // Status implements the api.Charger interface func (c *Easee) Status() (api.ChargeStatus, error) { c.updateSmartCharging() + c.confirmStatusConsistency() c.mux.Lock() defer c.mux.Unlock() @@ -844,3 +844,23 @@ func (c *Easee) updateSmartCharging() { func (c *Easee) LoadpointControl(lp loadpoint.API) { c.lp = lp } + +// checks that opMode matches powerflow and polls if inconsistent +func (c *Easee) confirmStatusConsistency() { + c.mux.Lock() + opCharging := c.opMode == easee.ModeCharging + pilotCharging := c.pilotMode == "C" + powerFlowing := c.currentPower > 0 + c.mux.Unlock() + + if opCharging != powerFlowing || opCharging != pilotCharging { + // poll opMode from charger as API can give outdated data after SignalR (re)connect + if time.Since(c.lastOpModePollTriggered) > time.Minute*3 { // api rate limit, max once in 3 minutes + uri := fmt.Sprintf("%s/chargers/%s/commands/poll_chargeropmode", easee.API, c.charger) + if _, err := c.Post(uri, request.JSONContent, nil); err != nil { + c.log.WARN.Printf("failed to poll CHARGER_OP_MODE, results may vary: %v", err) + } + c.lastOpModePollTriggered = time.Now() + } + } +} From 4d4c82ca7f892178a0611196d6f1db07a30553e0 Mon Sep 17 00:00:00 2001 From: Michael Hess Date: Tue, 2 Jan 2024 20:36:23 +0100 Subject: [PATCH 9/9] Fix panic due to multiple channel closes --- charger/easee.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/charger/easee.go b/charger/easee.go index a0cbacbb8f..0c3f807b15 100644 --- a/charger/easee.go +++ b/charger/easee.go @@ -70,6 +70,7 @@ type Easee struct { obsC chan easee.Observation obsTime map[easee.ObservationID]time.Time stopTicker chan struct{} + once sync.Once } func init() { @@ -251,10 +252,7 @@ func (c *Easee) subscribe(client signalr.Client) { // ProductUpdate implements the signalr receiver func (c *Easee) ProductUpdate(i json.RawMessage) { - var ( - once sync.Once - res easee.Observation - ) + var res easee.Observation if err := json.Unmarshal(i, &res); err != nil { c.log.ERROR.Printf("invalid message: %s %v", i, err) @@ -362,7 +360,7 @@ func (c *Easee) ProductUpdate(i json.RawMessage) { // startup completed if c.opMode != 0 { - once.Do(func() { close(c.done) }) + c.once.Do(func() { close(c.done) }) } c.opMode = opMode