diff --git a/templates/definition/meter/pstryk.yaml b/templates/definition/meter/pstryk.yaml new file mode 100644 index 000000000..0b460bf9f --- /dev/null +++ b/templates/definition/meter/pstryk.yaml @@ -0,0 +1,68 @@ +template: pstryk +products: + - brand: Pstryk.pl + description: + generic: 3-phase meter via local HTTP + +params: + - name: usage + choice: ["grid"] + - name: host + - name: cache + advanced: true + default: 1s + +render: | + {{- define "uri" -}} + http://{{ .host }}/state + {{- end }} + type: custom + power: + source: http + uri: {{ include "uri" . }} + jq: .multiSensor.sensors[] | select(.id==0 and .type=="activePower") | .value // 0 + cache: {{ .cache }} + energy: + source: http + uri: {{ include "uri" . }} + jq: ((.multiSensor.sensors[] | select(.id==0 and .type=="forwardActiveEnergy") | .value // 0) / 1000) + cache: {{ .cache }} + currents: + - source: http + uri: {{ include "uri" . }} + jq: ((.multiSensor.sensors[] | select(.id==1 and .type=="current") | .value // 0) / 1000) + cache: {{ .cache }} + - source: http + uri: {{ include "uri" . }} + jq: ((.multiSensor.sensors[] | select(.id==2 and .type=="current") | .value // 0) / 1000) + cache: {{ .cache }} + - source: http + uri: {{ include "uri" . }} + jq: ((.multiSensor.sensors[] | select(.id==3 and .type=="current") | .value // 0) / 1000) + cache: {{ .cache }} + voltages: + - source: http + uri: {{ include "uri" . }} + jq: ((.multiSensor.sensors[] | select(.id==1 and .type=="voltage") | .value // 0) / 10) + cache: {{ .cache }} + - source: http + uri: {{ include "uri" . }} + jq: ((.multiSensor.sensors[] | select(.id==2 and .type=="voltage") | .value // 0) / 10) + cache: {{ .cache }} + - source: http + uri: {{ include "uri" . }} + jq: ((.multiSensor.sensors[] | select(.id==3 and .type=="voltage") | .value // 0) / 10) + cache: {{ .cache }} + powers: + - source: http + uri: {{ include "uri" . }} + jq: (.multiSensor.sensors[] | select(.id==1 and .type=="activePower") | .value // 0) + cache: {{ .cache }} + - source: http + uri: {{ include "uri" . }} + jq: (.multiSensor.sensors[] | select(.id==2 and .type=="activePower") | .value // 0) + cache: {{ .cache }} + - source: http + uri: {{ include "uri" . }} + jq: (.multiSensor.sensors[] | select(.id==3 and .type=="activePower") | .value // 0) + cache: {{ .cache }} diff --git a/templates/definition/tariff/pstryk.yaml b/templates/definition/tariff/pstryk.yaml new file mode 100644 index 000000000..d00583967 --- /dev/null +++ b/templates/definition/tariff/pstryk.yaml @@ -0,0 +1,53 @@ +template: pstryk +products: + - brand: Pstryk.pl +requirements: + description: + en: "Get your API token from the Pstryk App." + de: "Hol dir deinen API-Token aus der Pstryk App." + evcc: ["skiptest"] +group: price +countries: ["PL"] + +params: + - name: token + type: string + required: true + description: + en: "API token (e.g. sk-...)." + de: "API-Token (z.B. sk-...)." + + - name: plan + type: choice + default: pricing + choice: ["pricing", "prosumer-pricing"] + required: true + description: + en: "Tariff source" + de: "Tarifquelle" + + - preset: tariff-base + + - name: interval + default: 1h + advanced: true + +render: | + type: custom + {{ include "tariff-base" . }} + forecast: + source: http + uri: https://api.pstryk.pl/integrations/{{ .plan }}/?resolution=hour&window_start={{ `{{ now | mustDateModify "-24h" | date "2006-01-02" }}` }}&window_end={{ `{{ now | mustDateModify "+72h" | date "2006-01-02" }}` }} + headers: + Authorization: {{ .token }} + Accept: application/json + jq: | + [(.frames // [])[] + | select(.is_cheap != null or .is_expensive != null) + | { + start: (.start | sub("\\+00:00$"; "Z")), + end: (.end | sub("\\+00:00$"; "Z")), + value: .price_gross + } + ] | tostring + interval: {{ .interval }}