From a9e63a6b8ec2ce9a8d85a796313e3d662024d924 Mon Sep 17 00:00:00 2001 From: Mungg1818 Date: Thu, 26 Sep 2024 17:36:50 +0200 Subject: [PATCH 1/6] ADD: copied smartlogger file as template --- templates/definition/meter/huawei-emma.yaml | 240 ++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 templates/definition/meter/huawei-emma.yaml diff --git a/templates/definition/meter/huawei-emma.yaml b/templates/definition/meter/huawei-emma.yaml new file mode 100644 index 0000000000..40aaab0ccb --- /dev/null +++ b/templates/definition/meter/huawei-emma.yaml @@ -0,0 +1,240 @@ +template: huawei-emma +products: + - brand: Huawei + description: + generic: EMMA +capabilities: ["battery-control"] +params: + - name: usage + choice: ["grid", "pv", "battery"] + allinone: true + - name: storageunit + type: number + default: 0 + advanced: true + - name: modbus + choice: ["tcpip"] + - name: timeout + default: 15s + - name: capacity + advanced: true +render: | + type: custom + {{- if eq .usage "grid" }} + power: + source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + connectdelay: 1s + register: + address: 32278 # Active power + type: holding + decode: int32 + scale: 1 + energy: + source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + register: + address: 32349 # Negative active electricity + type: holding + decode: int64 + scale: 0.01 + currents: + - source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + register: + address: 32272 # Huawei phase A grid current + type: holding + decode: int32 + scale: 0.1 + - source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + register: + address: 32274 # Huawei phase B grid current + type: holding + decode: int32 + scale: 0.1 + - source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + register: + address: 32276 # Huawei phase C grid current + type: holding + decode: int32 + scale: 0.1 + {{- end }} + {{- if eq .usage "pv" }} + power: + source: modbus + id: 0 + uri: {{ .host }}:{{ .port }} + register: + address: 40521 # Active power + type: holding + decode: int32 + energy: + source: modbus + id: 0 + uri: {{ .host }}:{{ .port }} + register: + address: 40560 # E-Total + type: holding + decode: uint32 + scale: 0.1 + {{- end }} + {{- if eq .usage "battery" }} + power: + source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + connectdelay: 1s + register: + {{- if eq .storageunit "1" }} + address: 37001 + {{- end }} + {{- if eq .storageunit "2" }} + address: 37743 + {{- end }} + type: holding + decode: int32nan + scale: -1 + energy: + source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + register: + {{- if eq .storageunit "1" }} + address: 37068 # [Energy storage unit 1] Total discharge + {{- end }} + {{- if eq .storageunit "2" }} + address: 37755 # [Energy storage unit 2] Total discharge + {{- end }} + type: holding + decode: uint32nan + scale: 0.01 + soc: + source: modbus + {{- include "modbus" . | indent 2 }} + timeout: {{ .timeout }} + register: + {{- if eq .storageunit "1" }} + address: 37004 + {{- end }} + {{- if eq .storageunit "2" }} + address: 37738 + {{- end }} + type: holding + decode: uint16nan + scale: 0.1 + batterymode: + source: watchdog + timeout: 30s + reset: 1 # reset watchdog on normal + set: + source: switch + switch: + - case: 1 # normal + set: + source: const + value: 0 # stop + set: + source: modbus + {{- include "modbus" . | indent 10 }} + register: + address: 47100 # Forcible charge/discharge + type: writesingle + encoding: uint16 + - case: 2 # hold + set: + source: sequence + set: + - source: const + value: 2 # discharge + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47100 # Forcible charge/discharge + type: writesingle + encoding: uint16 + - source: const + value: 0 # duration + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47246 # Forcible charge/discharge setting mode + type: writesingle + encoding: uint16 + - source: const + value: 1 # Minute + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47083 # Forced charging and discharging period + type: writesingle + encoding: uint16 + - source: const + value: 0 # W + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47249 # Forcible discharge power + type: writemultiple + encoding: uint32 + - case: 3 # charge + set: + source: sequence + set: + - source: const + value: 1 # charge + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47100 # Forcible charge/discharge + type: writesingle + encoding: uint16 + - source: const + value: 0 # duration + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47246 # Forcible charge/discharge setting mode + type: writesingle + encoding: uint16 + - source: const + value: 1 # Minute + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47083 # Forced charging and discharging period + type: writesingle + encoding: uint16 + - source: const + value: 2500 # W + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47247 # Forcible charge power + type: writemultiple + encoding: uint32 + - source: const + value: 1 # Enable + set: + source: modbus + {{- include "modbus" . | indent 12 }} + register: + address: 47087 # Charge from grid + type: writesingle + encoding: uint16 + capacity: {{ .capacity }} # kWh + {{- end }} From 50aa0a47b671ff7bf3058cf7d0cec6df4a1b41e9 Mon Sep 17 00:00:00 2001 From: Mungg1818 Date: Thu, 10 Oct 2024 16:33:44 +0200 Subject: [PATCH 2/6] MOD: Communication with EMMA working --- templates/definition/meter/huawei-emma.yaml | 178 ++++---------------- 1 file changed, 32 insertions(+), 146 deletions(-) diff --git a/templates/definition/meter/huawei-emma.yaml b/templates/definition/meter/huawei-emma.yaml index 40aaab0ccb..c902f2046b 100644 --- a/templates/definition/meter/huawei-emma.yaml +++ b/templates/definition/meter/huawei-emma.yaml @@ -3,14 +3,13 @@ products: - brand: Huawei description: generic: EMMA -capabilities: ["battery-control"] params: - name: usage choice: ["grid", "pv", "battery"] allinone: true - name: storageunit type: number - default: 0 + default: 1 advanced: true - name: modbus choice: ["tcpip"] @@ -23,45 +22,50 @@ render: | {{- if eq .usage "grid" }} power: source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} connectdelay: 1s register: - address: 32278 # Active power + address: 31657 # Active power of built-in electric energy sensor type: holding decode: int32 scale: 1 energy: source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - address: 32349 # Negative active electricity + address: 31679 # Total negative active energy of built-in electric energy sensor type: holding decode: int64 scale: 0.01 currents: - source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - address: 32272 # Huawei phase A grid current + address: 31651 # Huawei phase A grid current type: holding decode: int32 scale: 0.1 - source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - address: 32274 # Huawei phase B grid current + address: 31653 # Huawei phase B grid current type: holding decode: int32 scale: 0.1 - source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - address: 32276 # Huawei phase C grid current + address: 31655 # Huawei phase C grid current type: holding decode: int32 scale: 0.1 @@ -72,15 +76,16 @@ render: | id: 0 uri: {{ .host }}:{{ .port }} register: - address: 40521 # Active power + address: 30364 # Active power type: holding decode: int32 + scale: 1 energy: source: modbus id: 0 uri: {{ .host }}:{{ .port }} register: - address: 40560 # E-Total + address: 30344 # E-Total type: holding decode: uint32 scale: 0.1 @@ -88,153 +93,34 @@ render: | {{- if eq .usage "battery" }} power: source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} connectdelay: 1s register: - {{- if eq .storageunit "1" }} - address: 37001 - {{- end }} - {{- if eq .storageunit "2" }} - address: 37743 - {{- end }} + address: 30360 type: holding - decode: int32nan - scale: -1 + decode: int32 + scale: 1 energy: source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - {{- if eq .storageunit "1" }} - address: 37068 # [Energy storage unit 1] Total discharge - {{- end }} - {{- if eq .storageunit "2" }} - address: 37755 # [Energy storage unit 2] Total discharge - {{- end }} + address: 30314 # [Energy storage unit 1] Total discharge type: holding - decode: uint32nan + decode: uint32 scale: 0.01 soc: source: modbus - {{- include "modbus" . | indent 2 }} + id: 0 + uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - {{- if eq .storageunit "1" }} - address: 37004 - {{- end }} - {{- if eq .storageunit "2" }} - address: 37738 - {{- end }} + address: 30368 type: holding - decode: uint16nan + decode: uint16 scale: 0.1 - batterymode: - source: watchdog - timeout: 30s - reset: 1 # reset watchdog on normal - set: - source: switch - switch: - - case: 1 # normal - set: - source: const - value: 0 # stop - set: - source: modbus - {{- include "modbus" . | indent 10 }} - register: - address: 47100 # Forcible charge/discharge - type: writesingle - encoding: uint16 - - case: 2 # hold - set: - source: sequence - set: - - source: const - value: 2 # discharge - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47100 # Forcible charge/discharge - type: writesingle - encoding: uint16 - - source: const - value: 0 # duration - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47246 # Forcible charge/discharge setting mode - type: writesingle - encoding: uint16 - - source: const - value: 1 # Minute - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47083 # Forced charging and discharging period - type: writesingle - encoding: uint16 - - source: const - value: 0 # W - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47249 # Forcible discharge power - type: writemultiple - encoding: uint32 - - case: 3 # charge - set: - source: sequence - set: - - source: const - value: 1 # charge - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47100 # Forcible charge/discharge - type: writesingle - encoding: uint16 - - source: const - value: 0 # duration - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47246 # Forcible charge/discharge setting mode - type: writesingle - encoding: uint16 - - source: const - value: 1 # Minute - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47083 # Forced charging and discharging period - type: writesingle - encoding: uint16 - - source: const - value: 2500 # W - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47247 # Forcible charge power - type: writemultiple - encoding: uint32 - - source: const - value: 1 # Enable - set: - source: modbus - {{- include "modbus" . | indent 12 }} - register: - address: 47087 # Charge from grid - type: writesingle - encoding: uint16 capacity: {{ .capacity }} # kWh {{- end }} From fb6965b0861c77f563a1329cc8a42db1dc56366b Mon Sep 17 00:00:00 2001 From: Mungg1818 Date: Mon, 14 Oct 2024 20:01:02 +0200 Subject: [PATCH 3/6] MOD: adjustments after testing --- templates/definition/meter/huawei-emma.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/definition/meter/huawei-emma.yaml b/templates/definition/meter/huawei-emma.yaml index c902f2046b..3e4b890d06 100644 --- a/templates/definition/meter/huawei-emma.yaml +++ b/templates/definition/meter/huawei-emma.yaml @@ -76,7 +76,7 @@ render: | id: 0 uri: {{ .host }}:{{ .port }} register: - address: 30364 # Active power + address: 30354 # Active power type: holding decode: int32 scale: 1 @@ -101,14 +101,14 @@ render: | address: 30360 type: holding decode: int32 - scale: 1 + scale: -1 energy: source: modbus id: 0 uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - address: 30314 # [Energy storage unit 1] Total discharge + address: 30312 # [Energy storage unit 1] Total discharge type: holding decode: uint32 scale: 0.01 @@ -121,6 +121,6 @@ render: | address: 30368 type: holding decode: uint16 - scale: 0.1 + scale: .01 capacity: {{ .capacity }} # kWh {{- end }} From 5a8b00d979c008b9a5016101ed9322e513fab830 Mon Sep 17 00:00:00 2001 From: Mungg1818 Date: Mon, 18 Nov 2024 20:09:00 +0100 Subject: [PATCH 4/6] MOD: changes after review added --- templates/definition/meter/huawei-emma.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/templates/definition/meter/huawei-emma.yaml b/templates/definition/meter/huawei-emma.yaml index 3e4b890d06..09e84970fa 100644 --- a/templates/definition/meter/huawei-emma.yaml +++ b/templates/definition/meter/huawei-emma.yaml @@ -25,7 +25,6 @@ render: | id: 0 uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} - connectdelay: 1s register: address: 31657 # Active power of built-in electric energy sensor type: holding @@ -45,7 +44,6 @@ render: | - source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 31651 # Huawei phase A grid current type: holding @@ -63,7 +61,6 @@ render: | - source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 31655 # Huawei phase C grid current type: holding @@ -96,11 +93,10 @@ render: | id: 0 uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} - connectdelay: 1s register: address: 30360 type: holding - decode: int32 + decode: int32nan scale: -1 energy: source: modbus @@ -108,9 +104,9 @@ render: | uri: {{ .host }}:{{ .port }} timeout: {{ .timeout }} register: - address: 30312 # [Energy storage unit 1] Total discharge + address: 30312 # Total discharge type: holding - decode: uint32 + decode: uint32nan scale: 0.01 soc: source: modbus @@ -120,7 +116,7 @@ render: | register: address: 30368 type: holding - decode: uint16 + decode: uint16nan scale: .01 capacity: {{ .capacity }} # kWh {{- end }} From 0711e562a92343d9c34f8b7f926b32690514da3a Mon Sep 17 00:00:00 2001 From: Mungg1818 <65672049+Mungg1818@users.noreply.github.com> Date: Tue, 19 Nov 2024 20:57:03 +0100 Subject: [PATCH 5/6] MOD: huawei-emma.yaml timeouts removed battery control removed --- templates/definition/meter/huawei-emma.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/templates/definition/meter/huawei-emma.yaml b/templates/definition/meter/huawei-emma.yaml index 09e84970fa..afba8a3735 100644 --- a/templates/definition/meter/huawei-emma.yaml +++ b/templates/definition/meter/huawei-emma.yaml @@ -7,14 +7,8 @@ params: - name: usage choice: ["grid", "pv", "battery"] allinone: true - - name: storageunit - type: number - default: 1 - advanced: true - name: modbus choice: ["tcpip"] - - name: timeout - default: 15s - name: capacity advanced: true render: | @@ -24,7 +18,6 @@ render: | source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 31657 # Active power of built-in electric energy sensor type: holding @@ -34,7 +27,6 @@ render: | source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 31679 # Total negative active energy of built-in electric energy sensor type: holding @@ -52,7 +44,6 @@ render: | - source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 31653 # Huawei phase B grid current type: holding @@ -92,7 +83,6 @@ render: | source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 30360 type: holding @@ -102,7 +92,6 @@ render: | source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 30312 # Total discharge type: holding @@ -112,7 +101,6 @@ render: | source: modbus id: 0 uri: {{ .host }}:{{ .port }} - timeout: {{ .timeout }} register: address: 30368 type: holding From 56e189a12b7a076c0ec86442518fb6126c02b2ec Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 20 Nov 2024 12:30:32 +0100 Subject: [PATCH 6/6] Apply suggestions from code review --- templates/definition/meter/huawei-emma.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/definition/meter/huawei-emma.yaml b/templates/definition/meter/huawei-emma.yaml index afba8a3735..2172e4c1f7 100644 --- a/templates/definition/meter/huawei-emma.yaml +++ b/templates/definition/meter/huawei-emma.yaml @@ -22,7 +22,6 @@ render: | address: 31657 # Active power of built-in electric energy sensor type: holding decode: int32 - scale: 1 energy: source: modbus id: 0 @@ -67,7 +66,6 @@ render: | address: 30354 # Active power type: holding decode: int32 - scale: 1 energy: source: modbus id: 0 @@ -105,6 +103,6 @@ render: | address: 30368 type: holding decode: uint16nan - scale: .01 + scale: 0.01 capacity: {{ .capacity }} # kWh {{- end }}