SMA Energy Meter in Home Assistant

Hi @Nicko1, that seems fairly fundamental, what arch are you using? You can see that from info/the supervisor logs

I’ve got armv7l (32-bit R-Pi4), but these all use the same docker base image.

Do you see anything more in the supervisor logs?

Open your Home Assistant instance and show your Supervisor system logs.

A successful build should look like this:

21-03-10 03:18:15 INFO (SyncWorker_0) [supervisor.docker.addon] Starting build for 6a2c1c7a/armv7-addon-sma-em:0.5
21-03-10 03:19:04 INFO (SyncWorker_0) [supervisor.docker.addon] Build 6a2c1c7a/armv7-addon-sma-em:0.5 done
21-03-10 03:19:04 INFO (MainThread) [supervisor.addons] Add-on '6a2c1c7a_sma-em' successfully rebuilt
21-03-10 03:19:05 INFO (SyncWorker_1) [supervisor.docker.addon] Starting Docker add-on 6a2c1c7a/armv7-addon-sma-em with version 0.5

Yes @tropfen, if you have the latest Home Assistant & the my Home Assistant integration you can click this button to open the Supervisor add-on repository config, then just add the URL

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

1 Like

Hi @kellerza
Thanks for helping with this
Im probably doing thing wrong here

—> 1c9cf6b54197
Step 3/15 : RUN apk add --no-cache git
—> Running in ff1ba8aae4ab
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/armv7/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/armv7/APKINDEX.tar.gz
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: temporary error (try again later)

WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/community: temporary error (try again later)

ERROR: unable to select packages:

git (no such package):
required by: world[git]
Removing intermediate container ff1ba8aae4ab

21-03-10 01:54:36 INFO (SyncWorker_5) [supervisor.docker.addon] Starting build for 6a2c1c7a/armv7-addon-sma-em:0.5
21-03-10 01:54:51 ERROR (SyncWorker_5) [supervisor.docker.addon] Can’t build 6a2c1c7a/armv7-addon-sma-em:0.5: The command ‘/bin/ash -o pipefail -c apk add --no-cache git’ returned a non-zero code: 1
21-03-10 01:54:51 ERROR (SyncWorker_5) [supervisor.docker.addon] Build log:
Step 1/15 : ARG BUILD_FROM
Step 2/15 : FROM ${BUILD_FROM}
—> 1c9cf6b54197
Step 3/15 : RUN apk add --no-cache git
—> Running in 916d2765fa73
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/armv7/APKINDEX.tar.gz
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: temporary error (try again later)

fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/armv7/APKINDEX.tar.gz
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/community: temporary error (try again later)

ERROR: unable to select packages:

git (no such package):
required by: world[git]
Removing intermediate container 916d2765fa73

Hi @Nicko1 I seem it says “temporary error”, there seems to be DNS issues for some 3.13 alpine linux users

I’ve added a ping to the Dockerfile build process to see if you can reach the repo

“Reload” your add-on repos (under the three dots in the Add-On Store window). The upgrade the add-on to 0.5.3). See if you can successfully ping the alpine linux repo in those logs

1 Like

Hello kellerza,

i have installed the AddOn. The protokoll - tab shows the following lines

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
ic| 'No SMA_SERIALS configured, capturing a SINGLE debug packet'
serial: value:3007889749

The configuration is pre filled.

What are the next steps to configure and get the SMA EM values?

Thanks in advance
Frank

That 300xxx value you see there is your serial number. Fill it into SMA_SERIALS in the config & start the addon again

Hello Kellerza,

Thanks, added the number.

Sorry for asking again and again. Is there a read.me saying what to do to get the AddOn working?
If have added to following lines to configuration.yaml

  - platform: filter
    name: grid power 1min
    entity_id: sensor.grid_power
    filters:
      - filter: time_simple_moving_average
        window_size: 00:01

  - platform: filter
    name: total yield 5min
    entity_id: sensor.total_yield
    filters:
      - filter: time_throttle
        window_size: 00:05

utility_meter:
  daily_yield:
    source: sensor.total_yield
    cycle: daily
  monthly_yield:
    source: sensor.total_yield
    cycle: monthly

After a restart i get 4 new sensor entries.

For two entries (daily_yield, monthly_yield) i get the value 0, for grid power 1min i get an unknown and total yield 5min i get nothing. Ok its dark outside.

But selecting each entry, i get the information that the entity has no unique ID.

Frank

Hi @kellerza
Looks like i have some thing different now
and how do i load 0.5.3

21-03-11 04:54:35 ERROR (SyncWorker_4) [supervisor.docker.addon] Can’t build 6a2c1c7a/armv7-addon-sma-em:0.5.4: The command ‘/bin/ash -o pipefail -c pip3 install --no-cache-dir paho-mqtt~=1.5.0 requests~=2.24.0 icecream’ returned a non-zero code: 1
21-03-11 04:54:35 ERROR (SyncWorker_4) [supervisor.docker.addon] Build log:
Step 1/15 : ARG BUILD_FROM
Step 2/15 : FROM ${BUILD_FROM}
—> 1c9cf6b54197
Step 3/15 : RUN pip3 install --no-cache-dir paho-mqtt~=1.5.0 requests~=2.24.0 icecream
—> Running in c32b3969b533
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.HTTPSConnection object at 0xb56d9808>: Failed to establish a new connection: [Errno -3] Try again’)’: /simple/paho-mqtt/

WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.HTTPSConnection object at 0xb56d9868>: Failed to establish a new connection: [Errno -3] Try again’)’: /simple/paho-mqtt/

WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.HTTPSConnection object at 0xb5674868>: Failed to establish a new connection: [Errno -3] Try again’)’: /simple/paho-mqtt/

WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.HTTPSConnection object at 0xb5674af0>: Failed to establish a new connection: [Errno -3] Try again’)’: /simple/paho-mqtt/

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.HTTPSConnection object at 0xb56749e8>: Failed to establish a new connection: [Errno -3] Try again’)’: /simple/paho-mqtt/

ERROR: Could not find a version that satisfies the requirement paho-mqtt~=1.5.0 (from versions: none)

ERROR: No matching distribution found for paho-mqtt~=1.5.0

Removing intermediate container c32b3969b533

@tropfen that config you added is only examples of filters, updated the add-on docs to make this more clear and explain exactly what they do.

To update the add-on and get the new docs see here

@Nicko1 You still seem to have connectivity issues, in the latest version I swapped pip & apk install see here. This is really fundamental networking stuff and I would check: Internet connection & DNS. Are you behind some proxy? Do you use some DNS addon like pi-hole/adguard - in which case you need static config for your IP&DNS on your Pi.

@kellerza yes thats correct I use Dnsmasq
My pi has a Static ip and the DNS server address in the Dnsmasq config
Ive had this problem for a long time Its like the programs within the Pi are not able to access the DNS server.
i might have to start a new thread and see if i can get to the bottom of this
Thanks for your help Mate really appreciate the help :grinning:

:+1: good luck! Important to get this right…

In Home Assistant OS you can even set static IPs/DNS through the UI these days:

Supervisor -> System tab --> Host

Hello kellerza,

Thanks for the hint. I missed the content of docs.md.
With debug-level 1, I see that there are values for the three default entries.

mqtt: sma-em topic SMA-EM/status/3007889749 data published 19:39:13:{"pconsume": 0.5, "pconsumecounter": 537.1287, "u1": 222.673, "timestamp": 1615574353.8046048}
mqtt: publishing SMA-EM/status/3007889749/pconsume:0.5
mqtt: publishing SMA-EM/status/3007889749/pconsumecounter:537.1287
mqtt: publishing SMA-EM/status/3007889749/u1:222.673
mqtt: publishing SMA-EM/status/3007889749/timestamp:1615574353.8046048

What I can’t figure out is the way to get access to the fields / sensors. For the following step

Assume FIELDS=pconsume,pconsumecounter,u1, and the auto-discovered sensors have been renamed according to the table below

i have no idea.

Thanks in advance
Frank

Hi @tropfen,

When you add the integration, you can look for the sensors in the Configuration menu, under Devices. There should be a SMA Energy meter and if you click on it you will see the devices and its related entities

Initially they will be called. You cna then rename their entity IDs or use them just like this.

  • sensor.pconsume
  • sensor.pconsumecounter
  • sensor.u1

Thanks for sharing the code. In which platform have you written this. I am searching codes to write in python.

Since i changed to the SMA integration, the scan_interval parameter is missing… now the SMA device is polled every 5 seconds or something. WAY to much for my liking.
Is there a way to change the polling rate?
Thanks!

edit: logs are flooded every 5 seconds, this is crazy… disabling integration for now :frowning:

now it is solved!

Hi,
i am using the same sensors pconsume, psupply etc.
I figured out that on the sunny boy ui the value of total amount daily grid usage is different from pconsumecounter. which is the correct one?

Hi What did you solve?

The SMA energy meter is a true power meter, it only reports power into the home and power sent out.
The daily grid usage from the sunny boy might be pconsume + solar energy consume.
The sunny boy have a many number of different values it reports some add two values together to give you a total power consumed from solar and grid together.
hope this helps.

Hi All, I’ve made some updates to the SMA Energy meter HASS IO plugin - SMA Energy Meter in Home Assistant - #120 by kellerza

Once you add the repo, you can try the (dev) version.
It introduced a new way of reading the values. If there are no change, the avg will be reported every 60 seconds. If there is a big change (kettle, oven, geyser etc) you can get a change withon a second. This opens up some new opportunities for automation.

With the dev version you can also get rid of filter in HomeAssistant, since it is already filtered at the source