From a9e63a6b8ec2ce9a8d85a796313e3d662024d924 Mon Sep 17 00:00:00 2001 From: Mungg1818 Date: Thu, 26 Sep 2024 17:36:50 +0200 Subject: [PATCH 1/3] 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/3] 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/3] 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 }}