-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Tinkerforge WARP WebSocket API (BC) #26970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
marcelGoerentz
wants to merge
30
commits into
evcc-io:master
Choose a base branch
from
marcelGoerentz:feature/add_warp_ws
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,949
−38
Draft
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
c59e6da
feat: tinkerforge warp http api
lehmanju d4b4eb8
Apply suggestion from @Copilot
andig ae1a608
Apply suggestion from @Copilot
andig 64e1369
fix: apply review suggestions
lehmanju 6659652
fix: apply review 2
lehmanju 71ec6c7
use struct instead of map for metersValues indices
lehmanju 6a8c964
change meter variables and methods to legacy
lehmanju 3729ddb
Initial commit
marcelGoerentz f0ddada
Add missing ws files
marcelGoerentz f163001
Implement suggestions
marcelGoerentz 77969ac
Fix formating issues
marcelGoerentz e6a7579
Fix Enabled using wrong status
marcelGoerentz 135b029
Add meter index from config when creating the struct
marcelGoerentz 3770a25
Fix code formatting
marcelGoerentz 7ada1fd
Add trace and debug messages, fix formatting
marcelGoerentz 94425ed
Improve the switch clause
marcelGoerentz aa035a6
Remove uneccessary method
marcelGoerentz e8a1727
Fix interface assertion, clean up, fix findings
marcelGoerentz 2c363fd
Improve the maintainability and readability of the code
marcelGoerentz c3db85a
Fix format
marcelGoerentz c90785e
Implement suggestions
marcelGoerentz 0e7aadd
Refactored to get rid of boilerplate code
marcelGoerentz 29ff7d1
Small improvements
marcelGoerentz 710a0e5
More small improvements
marcelGoerentz 760ee02
Fix formatting
marcelGoerentz 877e720
Use Energy Manager where necessary, delete uneccessary methods and fi…
marcelGoerentz f3c6280
Abstract handler, abstract POST, abstract ensure method, add status m…
marcelGoerentz 1b092e8
Fix possible deadlock
marcelGoerentz 0a32a63
Merge branch 'master' into feature/add_warp_ws
andig 8a572fc
Simplify
andig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package warp | ||
|
|
||
| import "github.com/evcc-io/evcc/util" | ||
|
|
||
| type MeterMapper struct { | ||
| indices MeterValuesIndices | ||
| Log *util.Logger | ||
| } | ||
|
|
||
| func (m *MeterMapper) UpdateValueIDs(ids []int) { | ||
| required := []int{ | ||
| ValueIDVoltageL1N, | ||
| ValueIDVoltageL2N, | ||
| ValueIDVoltageL3N, | ||
| ValueIDCurrentImExSumL1, | ||
| ValueIDCurrentImExSumL2, | ||
| ValueIDCurrentImExSumL3, | ||
| ValueIDPowerImExSum, | ||
| ValueIDEnergyAbsImSum, | ||
| } | ||
|
|
||
| // check that all IDs are present | ||
| missing := []int{} | ||
| for _, req := range required { | ||
| found := false | ||
| for _, id := range ids { | ||
| if id == req { | ||
| found = true | ||
| break | ||
| } | ||
| } | ||
| if !found { | ||
| missing = append(missing, req) | ||
| } | ||
| } | ||
|
|
||
| if len(missing) > 0 { | ||
marcelGoerentz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| m.Log.ERROR.Printf("missing required meter value IDs: %v", missing) | ||
| return | ||
| } | ||
|
|
||
| // Create mapping | ||
| var idx MeterValuesIndices | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why aren't the indexes simply a then for i, valueID := range ids {
indexes[valueID] = i
}and the entire mapper goes away. |
||
| for i, valueID := range ids { | ||
| switch valueID { | ||
| case ValueIDVoltageL1N: | ||
| idx.VoltageL1NIndex = i | ||
| case ValueIDVoltageL2N: | ||
| idx.VoltageL2NIndex = i | ||
| case ValueIDVoltageL3N: | ||
| idx.VoltageL3NIndex = i | ||
| case ValueIDCurrentImExSumL1: | ||
| idx.CurrentImExSumL1Index = i | ||
| case ValueIDCurrentImExSumL2: | ||
| idx.CurrentImExSumL2Index = i | ||
| case ValueIDCurrentImExSumL3: | ||
| idx.CurrentImExSumL3Index = i | ||
| case ValueIDPowerImExSum: | ||
| idx.PowerImExSumIndex = i | ||
| case ValueIDEnergyAbsImSum: | ||
| idx.EnergyAbsImSumIndex = i | ||
| } | ||
| } | ||
|
|
||
| m.indices = idx | ||
| } | ||
|
|
||
| func (m *MeterMapper) UpdateValues(vals []float64, power *float64, energy *float64, voltL, currL *[3]float64) { | ||
| // get the highest possible index | ||
| highestIndex := max(m.indices.VoltageL1NIndex, m.indices.VoltageL2NIndex, m.indices.VoltageL3NIndex, | ||
| m.indices.CurrentImExSumL1Index, m.indices.CurrentImExSumL2Index, m.indices.CurrentImExSumL3Index, | ||
| m.indices.PowerImExSumIndex, m.indices.EnergyAbsImSumIndex) | ||
|
|
||
| // check boundaries | ||
| if len(vals) < highestIndex+1 { | ||
| return | ||
| } | ||
|
|
||
| *voltL = [3]float64{vals[m.indices.VoltageL1NIndex], vals[m.indices.VoltageL2NIndex], vals[m.indices.VoltageL3NIndex]} | ||
| *currL = [3]float64{vals[m.indices.CurrentImExSumL1Index], vals[m.indices.CurrentImExSumL2Index], vals[m.indices.CurrentImExSumL3Index]} | ||
| *power = vals[m.indices.PowerImExSumIndex] | ||
| *energy = vals[m.indices.EnergyAbsImSumIndex] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| template: tinkerforge-warp-ws | ||
| products: | ||
| - brand: TinkerForge | ||
| description: | ||
| generic: WARP Charger Smart (WebSocket) | ||
| - brand: TinkerForge | ||
| description: | ||
| generic: WARP Charger Pro (WebSocket) | ||
| capabilities: ["mA", "1p3p", "rfid"] | ||
| requirements: | ||
| description: | ||
| en: Firmware v2 required. Automatic phase switching requires the additional WARP Energy Manager. | ||
| de: Firmware v2 erforderlich. Für automatische Phasenumschaltung wird zusätzlich der WARP Energy Manager benötigt. | ||
| evcc: ["skiptest"] | ||
| params: | ||
| - name: uri | ||
| required: true | ||
| - name: user | ||
| - name: password | ||
| - name: energyManagerUri | ||
| description: | ||
| generic: Energy Manager URI | ||
| help: | ||
| de: HTTP(S) Adresse des WARP Energy Manager | ||
| en: HTTP(S) address of the WARP Energy Manager | ||
| - name: energyManagerUser | ||
| description: | ||
| de: Energy Manager Benutzerkonto | ||
| en: Energy Manager Username | ||
| help: | ||
| de: bspw. E-Mail Adresse, User Id, etc. | ||
| en: e.g. email address, user id, etc. | ||
| - name: energyManagerPassword | ||
| description: | ||
| de: Energy Manager Passwort | ||
| en: Energy Manager Password | ||
| help: | ||
| de: Bei führenden Nullen bitte in einfache Hochkommata setzen | ||
| en: Use single quotes in case of leading zeros | ||
| render: | | ||
| type: warp-ws | ||
| uri: {{ .uri }} | ||
| user: {{ .user }} | ||
| password: {{ .password }} | ||
| energyManagerUri: {{ .energyManagerUri }} | ||
| energyManagerUser: {{ .energyManagerUser }} | ||
| energyManagerPassword: {{ .energyManagerPassword }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| template: tinkerforge-warp | ||
| deprecated: true | ||
| covers: | ||
| - tinkerforge-warp-pro | ||
| products: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| template: tinkerforge-warp3-smart | ||
| deprecated: true | ||
| products: | ||
| - brand: TinkerForge | ||
| description: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| template: tinkerforge-warp3-ws | ||
| products: | ||
| - brand: TinkerForge | ||
| description: | ||
| generic: WARP3 Charger Smart (WebSocket) | ||
| - brand: TinkerForge | ||
| description: | ||
| generic: WARP3 Charger Pro (WebSocket) | ||
| capabilities: ["mA", "1p3p", "rfid"] | ||
| requirements: | ||
| description: | ||
| de: Die automatische Phasenumschaltung bei 1p Fahrzeugen muss deaktiviert sein. Siehe [docs.warp-charger.com](https://docs.warp-charger.com/docs/mqtt_http/api_reference/evse#evse_phase_auto_switch_warp3). | ||
| en: The automatic phase switching for 1p vehicles must be deactivated. See [docs.warp-charger.com](https://docs.warp-charger.com/docs/mqtt_http/api_reference/evse#evse_phase_auto_switch_warp3). | ||
| evcc: ["skiptest"] | ||
| params: | ||
| - name: uri | ||
| required: true | ||
| - name: user | ||
| - name: password | ||
| render: | | ||
| type: warp-ws | ||
| uri: {{ .uri }} | ||
| user: {{ .user }} | ||
| password: {{ .password }} | ||
| disablePhaseAutoSwitch: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| template: tinkerforge-warp3 | ||
| deprecated: true | ||
| products: | ||
| - brand: TinkerForge | ||
| description: | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.