tg44 / mqtt-transformer

A simple service which consumes, transforms and periodically republish json messages on mqtt.
MIT License
14 stars 5 forks source link

calculated signals #15

Closed SMCinc closed 1 year ago

SMCinc commented 1 year ago

Hi, I have on a Pi 3b with Debian openWB (with mosquitto), evcc (for charging), solarview running. the following hardware is connected : Shelly 3em as energy meter for grid energy incoming; SMA inverters . I have two analogue Ferraris energy meters : one for grid energy in , one for solar energy out unfutunately iI cactch an errormessage when I try to start mqtt-transformer as docker-compose:

sudo docker-compose up
Recreating mqtt-transformer_mqtt-transformer_1 ... done
Attaching to mqtt-transformer_mqtt-transformer_1
mqtt-transformer_1 | exec /usr/local/bin/docker-entrypoint.sh: exec format error

python3.7 / docker are on the latest update. docker-compose.yaml is

version:  '3.3'
services:
  mqtt-transformer:
    image: ghcr.io/tg44/mqtt-transformer:latest
    restart: unless-stopped
    volumes:
      - /otp/mqtt-transformer/:/home/node/app/conf
    environment:
      - MQTT_URL=mqtt://192.168.123.123:1883

Here I need some help, please. - do I have to create an entrypoint file? If yes, what content is needed?

When mqtt-transformer runs, I want to create two calculated signals:#

  1. energy sum: [shellies/shellyem3/emeter/0/total + shellies/shellyem3/emeter/1/total + shellies/shellyem3/emeter/2/total] *<correction factor>+ <[analogue Ferraris energy meter start value]> Gain here is to have the signal containig identical value like on the analogue emeter

  2. Power sum: shellies/shellyem3/emeter/0/power+shellies/shellyem3/emeter/1/power+shellies/shellyem3/emeter/2/power - solarview/WR0/PAC here I want to have a signal that gives the effective power the hous produces (grid - solar)

Are those signals possible to create? Thanks a lot and bye Christian

tg44 commented 1 year ago

I think you need a config file at least (I don't know if you have one or not, but I think this is the main problem).

This app is really versatile, but you will probably need a bit thinkering...

I think you either need zipLast or combineLatest, something like this;

{
    "fromTopics": ["shellies/shellyem3/emeter/0/total", "shellies/shellyem3/emeter/1/total", "shellies/shellyem3/emeter/2/total", "correction/factor", "energy/ferraris/start"],
    "toTopic": "calc/out/energy/sum",
    "emitType": "zipLast",
    "template": {
        "$eval": "(messages[0]+messages[1]+messages[2])*messages[3]+messages[4]"
    }
}

And;

{
    "fromTopics": ["shellies/shellyem3/emeter/0/total", "shellies/shellyem3/emeter/1/total", "shellies/shellyem3/emeter/2/total", "solarview/WR0/PAC"],
    "toTopic": "calc/out/power/sum",
    "emitType": "zipLast",
    "template": {
        "$eval": "messages[0]+messages[1]+messages[2]-messages[3]"
    }
}
SMCinc commented 1 year ago

The config.json I have is in subfolder /conf is the following

{
  "transforms": [
 {
      "fromTopic": "solarview/WR0/PAC",
      "toTopic":   "openWB/set/pv/1/W",
      "emitType":  "map",
      "wrapper":   "pv_power",
      "template":  {"$eval": "pv_power"}
    },
    {
      "fromTopic": "solarview/WR0/KT0",
      "toTopic":   "openWB/set/pv/1/WhCounter",
      "emitType":  "map",
      "wrapper":   "pv_energy",
      "template":  {"$eval": "pv_energy*1000"}
    },
  ]
}

and I still get: grafik

doesn't run also with updated config

tg44 commented 1 year ago

That file is not a valid json. This is really annoying I know... After the last element in the transforms array there should be no colons.

SMCinc commented 1 year ago

Seems to be a platform problem: when I try docker... grafik

for compose now I have tried:

version:  '3.1'
services:
  mqtt-transformer:
    image: ghcr.io/tg44/mqtt-transformer:latest
    restart: unless-stopped
    volumes:
      - /otp/mqtt-transformer/:/home/node/app/conf
    environment:
      - MQTT_URL=mqtt://localhost:1883
      - IS_VERBOSE=true

config.json is now:

{
  "transforms":[

{ "fromTopics": ["shellies/shellyem3/emeter/0/total", "shellies/shellyem3/emeter/1/total", "shellies/shellyem3/emeter/2/total", "solarview/WR0/PAC"],
 "toTopic": "calc/out/power/sum",
 "emitType": "zipLast",
 "template": {
        "$eval": "messages[0]+messages[1]+messages[2]-messages[3]"
    },
{ "fromTopics": ["shellies/shellyem3/emeter/0/total", "shellies/shellyem3/emeter/1/total", "shellies/shellyem3/emeter/2/total"],
 "toTopic": "calc/out/energy/sum",
 "emitType": "zipLast",
 "template": {
        "$eval": "(messages[0]+messages[1]+messages[2])*1.099+96266650"
    }
 ]
}

with the result: grafik I also tried just to remove the obsolete comma in the former .json with the same result.

git-developer commented 1 year ago

Looks like the image ghcr.io/tg44/mqtt-transformer is built for platform amd64 and you're running on platform armhf which is incompatible.

Maybe tg44 can provide an image for armhf platform (multiarch).

Alternatively you could try to use qemu to emulate the amd64 platform on your pi. If I remember correctly, qemu can be installed and enabled by running:

sudo apt-get install qemu-user-static
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

After that, you should be able to run amd64 images on your pi. I'm not really sure though because it's been a long time since I configured a pi that way.

tg44 commented 1 year ago

Thats a nice catch, I will try to do multiarch builds tomorrow for the project.

tg44 commented 1 year ago

@SMCinc Can you try to run docker pull ghcr.io/tg44/mqtt-transformer and get up your container with docker-compose up again? I added ARMv7 and ARMv8, I think this should be ok for rpis but if not I will try and add more platforms :D

SMCinc commented 1 year ago

To both of you: thanks a lot for very fast response.

@git-developer unfortunately qemu returns also amd64 is needed.

pi@raspberrypi:/otp/mqtt-transformer $ sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
exec /register: exec format error

@tg44 unfortunately the update did not work. - this is the response:

hcr.io/tg44/mqtt-transformer

#
# Fatal error in , line 0
# unreachable code
#
#
#
#FailureMessage Object: 0x7ed87684
git-developer commented 1 year ago

I can confirm that the arm/v7 image works on a Raspberry Pi 3+ without qemu:

$ docker pull ghcr.io/tg44/mqtt-transformer
Using default tag: latest
latest: Pulling from tg44/mqtt-transformer
c6556b3b6858: Already exists
e399ca187b89: Pull complete
26c4c24c6f36: Pull complete
330de45e45aa: Pull complete
f89d11729e77: Pull complete
4f4fb700ef54: Pull complete
1c4bd91f43e5: Pull complete
0697a8dd7da2: Pull complete
9c7cdece78f1: Pull complete
Digest: sha256:e963f6d0230c8e9d2d81c37610bb8c2988b3c72b077ae3bbaaf8dcdbb7070816
Status: Downloaded newer image for ghcr.io/tg44/mqtt-transformer:latest
ghcr.io/tg44/mqtt-transformer:latest
$ docker run --rm -ti ghcr.io/tg44/mqtt-transformer:latest uname -a
Linux 2376c8fa13a7 5.10.78-7-osmc #1 SMP PREEMPT Fri Sep 2 02:43:52 UTC 2022 armv7l Linux

This is better than the qemu approach, so we should focus on that.

The image works with the following configuration.

docker-compose.yml

---
services:
  mqtt-transformer:
    image: tg44/mqtt-transformer
    init: true
    restart: unless-stopped
    volumes:
      - ./data:/home/node/app/conf
    environment:
      - "MQTT_URL=mqtt://broker:1883"

data/conf.json

{
  "transforms": [
    {
      "fromTopic": "services/solarview/D0/DPAC",
      "toTopic":   "openWB/set/evu/W",
      "emitType":  "map",
      "wrapper":   "power",
      "template":  {"$eval": "-power"}
    }
  ]
}

Service

$ docker-compose up
[+] Running 1/1
 ⠿ mqtt-transformer Pulled                                                                                                                            1.7s
[+] Running 2/2
 ⠿ Network mqtt-transformer_default                    Created                                                                                             0.7s
 ⠿ Container mqtt-transformer-mqtt-transformer-1  Created                                                                                             0.6s
Attaching to mqtt-transformer-mqtt-transformer-1
mqtt-transformer-mqtt-transformer-1  | App started
mqtt-transformer-mqtt-transformer-1  | MQTT connected to mqtt://broker:1883
mqtt-transformer-mqtt-transformer-1  | Subscribed to services/solarview/D0/DPAC

Result

$ mosquitto_sub -v -h broker -t openWB/#
openWB/set/evu/W 173
openWB/set/evu/W 170

@SMCinc please compare this configuration with your environment.

SMCinc commented 1 year ago

@git-developer I did

 $ sudo docker pull ghcr.io/tg44/mqtt-transformer
Using default tag: latest
latest: Pulling from tg44/mqtt-transformer
Digest: sha256:e963f6d0230c8e9d2d81c37610bb8c2988b3c72b077ae3bbaaf8dcdbb7070816
Status: Image is up to date for ghcr.io/tg44/mqtt-transformer:latest
ghcr.io/tg44/mqtt-transformer:latest

with your configuration 'version' was missing ; I used '3.3' then 'init' is not supported and '---' had to be removed

ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.mqtt-transformer: 'init'

with version '2.2' init: true leads not to an error

Mosquitto is running at localhost on my Pi 3B+:

 $ mosquitto_sub -v -h localhost -t solarview/WR0/PAC
solarview/WR0/PAC 1682
solarview/WR0/PAC 1682

so I came to docker-compose.yml

version:  '2.2'
services:
  mqtt-transformer:
    image: tg44/mqtt-transformer
    init: true
    restart: unless-stopped
    volumes:
      - ./data:/home/node/app/conf
    environment:
      - "MQTT_URL=mqtt://localhost:1883"

Your config adatped to my environment in ./data/config.json is

{
  "transforms": [
   {
     "fromTopic": "solarview/WR0/PAC",
      "toTopic": "openWB/set/evu/W",
      "emitType": "map", "wrapper":
      "power", "template": {"$eval": "-power"}
    }
  ]
}

The result is:

 $ docker-compose up                                                                          mqtt-transformer_mqtt-transformer_1 is up-to-date
Attaching to mqtt-transformer_mqtt-transformer_1
mqtt-transformer_1  |
mqtt-transformer_1  |
mqtt-transformer_1  | #
mqtt-transformer_1  | # Fatal error in , line 0
mqtt-transformer_1  | # unreachable code
mqtt-transformer_1  | #
mqtt-transformer_1  | #
mqtt-transformer_1  | #
mqtt-transformer_1  | #FailureMessage Object: 0x7ef6e684
mqtt-transformer_mqtt-transformer_1 exited with code 0
mqtt-transformer_1  |
mqtt-transformer_1  |
mqtt-transformer_1  | #
mqtt-transformer_1  | # Fatal error in , line 0
mqtt-transformer_1  | # unreachable code
mqtt-transformer_1  | #
mqtt-transformer_1  | #
mqtt-transformer_1  | #
mqtt-transformer_1  | #FailureMessage Object: 0x7e9cd684
mqtt-transformer_mqtt-transformer_1 exited with code 133

by the way: /home/nodedirectory does still not exist.

git-developer commented 1 year ago

A web search for the terms Fatal error and unreachable code leads to sonos2mqtt #152 and zigbee2mqtt #7662.

When your pi OS based on Buster (Debian 10), the Alpine base image version must not exceed 3.12. My OS is based on Bullseye (Debian 11):

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
...

Please check if you're running Buster. If so, I see 3 options: 1.) Upgrade to Bullseye 2.) tg44 changes the base image to Alpine 3.12 3.) We have to find some other workaround

SMCinc commented 1 year ago

Yes, my OS is Debian 10:

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
tg44 commented 1 year ago

@git-developer thx for the support!

About the 2nd point; we can use this alpine3.12 base image, if you think this will work.

git-developer commented 1 year ago

I think this should help.

git-developer commented 1 year ago

@SMCinc

with your configuration 'version' was missing

This was done intentionally. Beginning with Compose 1.27.0+, the version element is deprecated.

Unsupported config option for services.mqtt-transformer: 'init'

init is not supported on Compose 3.x, so your change to 2.x is correct. You may either use the latest 2.x (which should currently be 2.4) or remove the version tag and update your docker-compose to a recent version.

tg44 commented 1 year ago

I think this should help.

Im not near my computer today, but if you create a pr I let it through.

git-developer commented 1 year ago

@SMCinc The image has been updated, I keep my fingers crossed for your next try!

SMCinc commented 1 year ago
 $ docker compose version
Docker Compose version v2.12.2

$ docker pull ghcr.io/tg44/mqtt-transformer
Using default tag: latest
latest: Pulling from tg44/mqtt-transformer
Digest: sha256:c327339274c43608be0ae0f6f475ff2c57c6a1bec62fe0fe086b683bd0c0d191
Status: Image is up to date for ghcr.io/tg44/mqtt-transformer:latest
ghcr.io/tg44/mqtt-transformer:latest

$ /otp/mqtt-transformer $ docker-compose up                        Creating network "mqtt-transformer_default" with the default driver
Creating mqtt-transformer_mqtt-transformer_1 ... done
Attaching to mqtt-transformer_mqtt-transformer_1
mqtt-transformer_1  |
mqtt-transformer_1  |
mqtt-transformer_1  | #
mqtt-transformer_1  | # Fatal error in , line 0
mqtt-transformer_1  | # unreachable code
mqtt-transformer_1  | #
mqtt-transformer_1  | #
mqtt-transformer_1  | #
mqtt-transformer_1  | #FailureMessage Object: 0x7ed68684
mqtt-transformer_mqtt-transformer_1 exited with code 133

unfortunatly it does not work

also with docker:

 $ docker run -e MQTT_URL="mqtt://localhost:1883" -v ${PWD}/conf:/home/node/app/conf ghcr.io/tg44/mqtt-transformer
App started

looks different but does not work. neither userr 'node' nor dir 'home/node' where created

git-developer commented 1 year ago

zigbee2mqtt #12459 contains some discussions that may help.

git-developer commented 1 year ago

Please verify that the image used in your docker-compose configuration (and docker command line run) file is ghcr.io/tg44/mqtt-transformer and not tg44/mqtt-transformer.

SMCinc commented 1 year ago

some progress ...

 $ docker-compose up
Creating network "mqtt-transformer_default" with the default driver
Creating mqtt-transformer_mqtt-transformer_1 ... done
Attaching to mqtt-transformer_mqtt-transformer_1
mqtt-transformer_1  | App started

but something seems to be mising: I have corrected the path in docker-composer.yml


version: '2.4'
services:
  mqtt-transformer:
    image: ghcr.io/tg44/mqtt-transformer
    init: true
    restart: unless-stopped
    volumes:
      - ./data:/home/node/app/conf
    environment:
      - "MQTT_URL=mqtt://localhost:1883"

and I have added deb http://deb.debian.org/debian bullseye-backports main to raspi.list and did get-apt update

||/ Name              Version      Architektur  Beschreibung
+++-=================-============-============-============================================
ii  libseccomp2:armhf 2.3.3-4      armhf        high level interface to Linux seccomp filter
git-developer commented 1 year ago

Is here anything else to do?

If the error message ("unreachable code") is gone after switching to ghcr.io/tg44/mqtt-transformer, you don't need to update libseccomp2. Otherwise:

  1. raspi.list should contain buster-backports, not bullseye-backports:
    deb http://ftp.debian.org/debian buster-backports main
  2. Update libseccomp2 to 2.5.1 by running
    apt-get update && apt-get install --only-upgrade libseccomp2

Please keep us updated about success or further errors.

SMCinc commented 1 year ago

The error message unreachable code has disappeared with image: ghcr.io/tg44/mqtt-transformer. libseccomp2:armhf 2.3.3-4 seems to be the latest version I can get

I have added deb http://ftp.debian.org/debian buster-backports main to raspi.list When doing apt-get update an error message occurs:

W: GPG-Fehler: http://ftp.debian.org/debian buster-backports InRelease: Die folgenden Signaturen konnten nicht überprüft werden, weil ihr öffentlicher Schlüssel nicht verfügbar ist: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
E: Das Depot »http://ftp.debian.org/debian buster-backports InRelease« ist nicht signiert.
N: Eine Aktualisierung von solch einem Depot kann nicht auf eine sichere Art durchgeführt werden, daher ist es standardmäßig deaktiviert.

public key is missing - update is deactivated

git-developer commented 1 year ago

OK. Since the error message is gone, you don't need the backports repo. If you're nevertheless interested in adding it: you have to trust the keys, e.g. by running

$ sudo apt-key adv --recv-keys 04EE7237B7D453EC 648ACFD622F3D138

But let's focus on your initial problem. Is everything OK now? Is mqtt-transformer working (verify with e.g. mosquitto_sub -v -h localhost -t openWB/#)?

When the broker is running in a different container on the same machine as mqtt-transformer, you cannot use localhost as hostname because localhost means inside the mqtt-transformer container. Use an extra_hosts entry with host-gateway in that case, e.g.

version: '2.4'
services:
  mqtt-transformer:
    image: ghcr.io/tg44/mqtt-transformer
    container_name: mqtt-transformer
    init: true
    restart: unless-stopped
    volumes:
      - ./data:/home/node/app/conf
    environment:
      - "MQTT_URL=mqtt://broker:1883"
    extra_hosts:
      - "broker:host-gateway"
SMCinc commented 1 year ago

OK - updated to libseccomp2:armhf 2.5.1-1~bpo10+1 ,but was not necessary. With ibseccomp2:armhf 2.3.3-4 it is fine also

IT WORKS - thanks a lot ! with your .yml content :

:/otp/mqtt-transformer $ docker-compose up
Recreating mqtt-transformer_mqtt-transformer_1 ... done
Attaching to mqtt-transformer_mqtt-transformer_1
mqtt-transformer_1  | App started
mqtt-transformer_1  | MQTT connected to mqtt://broker:1883
mqtt-transformer_1  | Subscribed to solarview/WR0/PAC
^CGracefully stopping... (press Ctrl+C again to force)
Stopping mqtt-transformer_mqtt-transformer_1   ... done
pi@raspberrypi:/otp/mqtt-transformer $ docker-compose up -d
Starting mqtt-transformer_mqtt-transformer_1 ...
Starting mqtt-transformer_mqtt-transformer_1 ... done
 $ mosquitto_sub -v -h localhost -t openWB/set/evu/W
openWB/set/evu/W -4509
openWB/set/evu/W (null)
openWB/set/evu/W -4516
openWB/set/evu/W (null)

Now I can do some reseach to my initial initial problem: calculated signals I guess I will have additional questions and will report my results For now thanks a lot for the great support.

SMCinc commented 1 year ago

Great, the calculation works fine. sorry for bothering again: How can the result forced to integer / rounded

/set/evu/W -2900.3747792754766

/set/evu/W -2900.3747792754766 -> -2900 as it is expected from openWB in my case

At the moment I have:

   {
 "fromTopics": ["shellies/shellyem3/emeter/0/power","shellies/shellyem3/emeter/1/power","shellies/shellyem3/emeter/2/power","solarview/WR0/PAC"],
 "toTopic": "openWB/set/evu/W",
 "emitType": "zipLast",
 "template": {"$eval": "(messages[0]+messages[1]+messages[2])*1.02103678113188-messages[3]*0.98995174"}
   },
   {

Solved: round is not available; I found in json-e manual only ceilor floor

e.g.

 "template": {"$eval": "ceil(-power)"}

Now I have a Shelly EM3 and Solarview connected to openWB and EVCC with the great mqtt-transformer. How shall we procced? - I would create a summary and my config files.

In sum my Pi 3B+ with Debian 10 'buster' runs with the latest version of mqtt-transformer (sha-13279a5 ff) for ARMv7 with [alpine 3.12] An update to libseccomp2 to 2.5.1 was not necessary, nor the usage of buster-backports.

in my case as docker-compose in dir /otp/mqtt-trqnsformer with docker-compose.yaml

version: '2.4'
services:
  mqtt-transformer:
    image: ghcr.io/tg44/mqtt-transformer
    container_name: mqtt-transformer
    init: true
    restart: unless-stopped
    volumes:
      - ./data:/home/node/app/conf
    environment:
      - "MQTT_URL=mqtt://broker:1883"
    extra_hosts:
      - "broker:host-gateway" 

in subfolder /otp/mqtt-trqnsformer/data conf.json here with correction factor 1,021 for Shelly/official electricity meter + additve offset e.g. 967611 kWh at hte time shelly was installed and 0.98 SMA SunnyBoys / official electricity meter (must be calculate individually)

{
  "transforms":[
   {
 "fromTopics": ["shellies/shellyem3/emeter/0/power","shellies/shellyem3/emeter/1/power","shellies/shellyem3/emeter/2/power","solarview/WR0/PAC"]
 "toTopic": "calc/out/power/sum",
 "emitType": "zipLast",
 "template": {"$eval": "(messages[0]+messages[1]+messages[2])*1.021+967611-messages[3]*0.98"}
   },
   {
     "fromTopic": "calc/out/power/sum",
      "toTopic": "openWB/set/evu/W",
      "emitType": "map",
      "wrapper":"power_sum",
       "template": {"$eval": "ceil(power_sum)"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/0/current",
      "toTopic": "openWB/set/evu/APhase1",
      "emitType": "map",
      "wrapper":"current",
       "template": {"$eval": "current*1.021+967611"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/1/current",
      "toTopic": "openWB/set/evu/APhase2",
      "emitType": "map",
      "wrapper":"current",
       "template": {"$eval": "current*1.021+967611"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/2/current",
      "toTopic": "openWB/set/evu/APhase3",
      "emitType": "map",
      "wrapper":"current",
       "template": {"$eval": "current*1.021+967611"}
    },
    {
    "fromTopic": "solarview/WR0/KT0",
      "toTopic": "openWB/set/evu/WhExported",
      "emitType": "map",
      "wrapper":"energy_pv_sum",
       "template": {"$eval": "floor(energy_pv_sum*0.98)*1000"}
    },
    {
    "fromTopic": "solarview/WR1/KT0",
      "toTopic": "openWB/set/pv/1/WhCounter",
      "emitType": "map",
      "wrapper":"energy_pv_1",
       "template": {"$eval": "floor(energy_pv_1*0.98)*1000"}
    },
    {
    "fromTopic": "solarview/WR2/KT0",
      "toTopic": "openWB/set/pv/2/WhCounter",
      "emitType": "map",
      "wrapper":"energy_pv_2",
       "template": {"$eval": "floor(energy_pv_2*0.98)*1000"}
    },
    {
    "fromTopic": "solarview/WR1/PAC",
      "toTopic": "openWB/set/pv/1/W",
      "emitType": "map",
      "wrapper":"power_pv_1",
       "template": {"$eval": "ceil(power_pv_1*0.98)"}
    },
   {
    "fromTopic": "solarview/WR2/PAC",
      "toTopic": "openWB/set/pv/2/W",
      "emitType": "map",
      "wrapper":"power_pv_2",
       "template": {"$eval": "ceil(power_pv_2*0.98)"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/0/voltage",
      "toTopic": "openWB/set/evu/VPhase1",
      "emitType": "map",
      "wrapper":"voltage",
       "template": {"$eval": "voltage"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/1/voltage",
      "toTopic": "openWB/set/evu/VPhase2",
      "emitType": "map",
      "wrapper":"voltage",
       "template": {"$eval": "voltage"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/2/voltage",
      "toTopic": "openWB/set/evu/VPhase3",
      "emitType": "map",
      "wrapper":"voltage",
       "template": {"$eval": "voltage"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/0/pf",
      "toTopic": "openWB/set/evu/PfPhase1",
      "emitType": "map",
      "wrapper":"power_factor",
       "template": {"$eval": "power_factor"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/1/pf",
      "toTopic": "openWB/set/evu/PfPhase2",
      "emitType": "map",
      "wrapper":"power_factor",
       "template": {"$eval": "power_factor"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/2/pf",
      "toTopic": "openWB/set/evu/PfPhase3",
      "emitType": "map",
      "wrapper":"power_factor",
       "template": {"$eval": "power_factor"}
    },
    {
     "fromTopic": "shellies/shellyem3/emeter/0/power",
      "toTopic": "openWB/set/evu/WPhase1",
      "emitType": "map",
      "wrapper": "power_in_0",
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/1/power",
      "toTopic": "openWB/set/evu/WPhase2",
     "emitType": "map",
      "wrapper": "power_in_1",
     "template": {"$eval": "power_in_1*1.021+967611"}
    },
   {
     "fromTopic": "shellies/shellyem3/emeter/2/power",
      "toTopic": "openWB/set/evu/WPhase3",
     "emitType": "map",
      "wrapper": "power_in_2",
     "template": {"$eval": "power_in_2*1.021+967611"}
    },
    {
 "fromTopics": ["shellies/shellyem3/emeter/0/total","shellies/shellyem3/emeter/1/total","shellies/shellyem3/emeter/2/total"],
 "toTopic": "calc/out/energy/sum",
 "emitType": "zipLast",
 "template": {"$eval": "(messages[0]+messages[1]+messages[2])*1.021+967611"}
  },
   {
 "fromTopic": "calc/out/energy/sum",
 "toTopic": "openWB/set/evu/WhImported",
 "emitType": "map",
 "wrapper": "energy_sum",
 "template": {"$eval": "energy_sum"}
  }
 ]
}
tg44 commented 1 year ago

I think Ill close this. Thanks for the debugging help @git-developer !