SMA Energy Meter Binding yields unplausible values

I wouldn’t see it that pessimistic. You still have the option to filter the wrong readings in a rule.
Or you use the script I have provided earlier in the thread. My PV system is similar to yours and it works quite well (at least after I have learned to deal with the pecularities of the SMA inverters).
But in the end you are right. It’s a pity not having a 100% working binding.

I’ve updated old PR to OH 3.4-SNAPSHOT. If you can please give it a try, cause I have no access to necessary hardware.

Thanks for building a new version.
I don’t use snapshots. Can you attach a OH 3.3 version?
Does the new version address the issues mentioned in [26], especially the ressource leak?

@splatch In the meantime I have a working OH 3.4-SNAPSHOT on my PC. So if you provide me an updated version of the binding I can offer to test it.

@splatch I have been following this discussion for some time, but could not contribute anything due to lack of detailed knowledge.
However, I would also offer to test the new binding based on OH 3.4

Hi

I have installed OH3.4-SNAPSHOT on my laptop (date 18/11/22). The SMA binding also says the same version number. Is this the new version, or do I have to load some thing else as well before testing?

PJG

The binding from OH3.4-SNAPSHOT still receives the wrong packets so it is problably the old one. I think we should get a new version for testing.

Ok. I will wait till there is a confirmed updated version before testing.

PJG

@splatch
I’ve two OH3 Systems in parallel to test the binding and I’ve a SMA Home Manager 2 and a SMA Smart Meter 10. The Meters are using different multicast IPs, to due the fact that the old Binding can’t use the serial. So I can also test this part of the binding, as soon as the binding works fine for one meter.

My productive OpenHab Version is 3.3 and getting wrong values quite often. Here the screenshot from three days.

My test OpenHab is on the 3.4.0-SNAPSHOT - Build #3175. Here the screenshot from the same days.

Regards,

Christian

Can you check version from PR http://code-house.org/downloads/openhab/org.openhab.binding.smaenergymeter-3.4.0-20221126.jar? I am not certain what are contents of build you mentioned.

@tomE same version but with OH 3.3 baseline: http://code-house.org/downloads/openhab/org.openhab.binding.smaenergymeter-3.3.0-20221126.jar

Edit
Build for OH 4.0.x: http://code-house.org/downloads/openhab/org.openhab.binding.smaenergymeter-4.0.4-20230921.jar

Build for OH 4.1.x: http://code-house.org/downloads/openhab/org.openhab.binding.smaenergymeter-4.1.0-20230921.jar

Thanks for your jar file.
I’ve installed your version and check the bundle version in the console.

It looks good so far. I’m on a business trip next week. I’ve the wrong values at least every two days, so the week will be a good test window.

I have problems to get the jar files working. I have tried the 3.4 version on windows with 3-4-0 snapshot and the 3.3. version on openhabian with openhab 3.3.0.
I have tried two different procedures to install the binding:

  1. The method you described in post 7 (update in karaf console)
  2. Uninstall the old binding, stop openhab.service, copy the binding into folder /usr/share/openhab/addons and start openhab.service again.
    With both methods the log contains the follwoing messages:
2022-11-27 12:41:51.509 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/OH-INF/thing/energyMeter.xml' in module 'org.openhab.binding.smaenergymeter' could not be parsed: 

---- Debugging information ----

cause-exception     : java.lang.IllegalArgumentException

cause-message       : No enum constant org.openhab.core.config.core.ConfigDescriptionParameter.Type.STRING

class               : org.openhab.core.config.core.ConfigDescriptionParameter

required-type       : org.openhab.core.config.core.ConfigDescriptionParameter

converter-type      : org.openhab.core.config.xml.ConfigDescriptionParameterConverter

path                : /thing-descriptions/thing-type/config-description/parameter

line number         : 35

class[1]            : java.util.ArrayList

required-type[1]    : java.util.ArrayList

converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter

class[2]            : org.openhab.core.config.core.ConfigDescription

required-type[2]    : org.openhab.core.config.core.ConfigDescription

converter-type[2]   : org.openhab.core.config.xml.ConfigDescriptionConverter

class[3]            : org.openhab.core.thing.xml.internal.ThingTypeXmlResult

required-type[3]    : org.openhab.core.thing.xml.internal.ThingTypeXmlResult

converter-type[3]   : org.openhab.core.thing.xml.internal.ThingTypeConverter

class[4]            : org.openhab.core.thing.xml.internal.ThingDescriptionList

required-type[4]    : org.openhab.core.thing.xml.internal.ThingDescriptionList

converter-type[4]   : org.openhab.core.thing.xml.internal.ThingDescriptionConverter

version             : 1.4.19

-------------------------------

com.thoughtworks.xstream.converters.ConversionException: 

---- Debugging information ----

cause-exception     : java.lang.IllegalArgumentException

cause-message       : No enum constant org.openhab.core.config.core.ConfigDescriptionParameter.Type.STRING

class               : org.openhab.core.config.core.ConfigDescriptionParameter

required-type       : org.openhab.core.config.core.ConfigDescriptionParameter

converter-type      : org.openhab.core.config.xml.ConfigDescriptionParameterConverter

path                : /thing-descriptions/thing-type/config-description/parameter

line number         : 35

class[1]            : java.util.ArrayList

required-type[1]    : java.util.ArrayList

converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter

class[2]            : org.openhab.core.config.core.ConfigDescription

required-type[2]    : org.openhab.core.config.core.ConfigDescription

converter-type[2]   : org.openhab.core.config.xml.ConfigDescriptionConverter

class[3]            : org.openhab.core.thing.xml.internal.ThingTypeXmlResult

required-type[3]    : org.openhab.core.thing.xml.internal.ThingTypeXmlResult

converter-type[3]   : org.openhab.core.thing.xml.internal.ThingTypeConverter

class[4]            : org.openhab.core.thing.xml.internal.ThingDescriptionList

required-type[4]    : org.openhab.core.thing.xml.internal.ThingDescriptionList

converter-type[4]   : org.openhab.core.thing.xml.internal.ThingDescriptionConverter

version             : 1.4.19

-------------------------------

The debug info points to line 35. Any idea what is going wrong here?

The serialNumber config parameter was improperly declared (string vs text), fixed this and updated pull request. New builds are:

http://code-house.org/downloads/openhab/org.openhab.binding.smaenergymeter-3.4.0-20221127.jar
http://code-house.org/downloads/openhab/org.openhab.binding.smaenergymeter-3.3.0-20221127.jar

Now installation of the 3.3 version worked. 3.4.0 not yet tried.
Will continue testing tomorrow.

I have tested the 3.3.0 version of the binding. Result summary:

  1. The binding can be installed and is working, during a period of 16 h there where no false readings.
  2. After installation two energymeter things appear in the UI. One is online with the correct serial number, the other one is in error state and shows no serial number in the detailed view.
  3. The event count of the energymeter items in OpenHAB metrics is doubled compared to the expected value. The logs show the expected number of item changes. Restart of the service has no effect on the event count.
  4. Deleting the additional thing has no effect on the event count.
  5. Setting poll rate to 0 caused error in openhab.log and events were no longer updated.

Test setup

Binding version: openhab/org.openhab.binding.smaenergymeter-3.3.0-20221127.jar
Testsystem: Raspberry Pi 4B, 4 GB, OpenHABbian, 64 bit, with openHAB 3.3.0 - Release Build
Testsoftware: File based DSL rules, items and things.
Thing definition:

smaenergymeter:energymeter:1234567890 [pollingPeriod="36000", serialNumber="1234567890"]

The polling period is a fictive value, the energymeter is polled in a rule every 1 sec.
Installation procedure:

  • Remove old binding in UI
  • Stop openhab.service
  • Copy new binding into folder /usr/share/openhab/addons
  • Clear cache with command openhab-cli clean-cache
  • Restart openhab.service

Results:

  1. The measurements of the new binding have been compared with the measurements achieved by means of a python script over a period of 16h. There were no siginificant differences visible. Especially the wrong readings did not appear.

  2. Two things are showning up in the UI:
    grafik
    Deletion of the second thing is possible and has no noticeable effect on the system function.

  3. The event count in openHAB metrics is doubled compared to the expected value: 240 vs 120 (refresh every 1 second over a period of 2 minutes).
    Restart of the service has no noticeable effect.
    Deletion of the second thing has no noticeable effect.

  4. Setting poll rate to 0 in things file caused error in openhab.log and events were no longer updated. Restart of service was necessary. Log file content:

2022-11-28 15:52:41.353 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.thingUpdated()' on 'org.openhab.binding.smaenergymeter.internal.handler.SMAEnergyMeterHandler@33f7fc95': null

java.lang.IllegalArgumentException: null

	at java.util.concurrent.ScheduledThreadPoolExecutor.scheduleWithFixedDelay(ScheduledThreadPoolExecutor.java:671) ~[?:?]

	at org.openhab.core.common.ThreadPoolManager$UnstoppableScheduledExecutorService.scheduleWithFixedDelay(ThreadPoolManager.java:307) ~[bundleFile:?]

	at org.openhab.binding.smaenergymeter.internal.handler.SMAEnergyMeterHandler.initialize(SMAEnergyMeterHandler.java:110) ~[?:?]

	at org.openhab.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:155) ~[?:?]

	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]

	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]

	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]

	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]

	at java.lang.Thread.run(Thread.java:829) [?:?]

@splatch

I tried to install your new jar file for 3.4.0 from 20221127, but got some errors during the startup.

2022-12-09 12:25:43.001 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.smaenergymeter-3.4.0-20221127.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.smaenergymeter [26]
  Unresolved requirement: Import-Package: org.openhab.core.config.core

I ignored the error and tried to add the smartmeter as a thing from the inbox. The thing is permanent in the state “Uninitialized” and I get the following errors in the log:

2022-12-09 12:31:29.242 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'smaenergymeter:energymeter:3002134196' to inbox.
2022-12-09 12:31:54.438 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.smaenergymeter.internal.handler.SMAEnergyMeterHandler@9a8b18': null
java.lang.UnsupportedOperationException: null
	at java.util.Collections$UnmodifiableMap.put(Collections.java:1457) ~[?:?]
	at org.openhab.binding.smaenergymeter.internal.handler.SMAEnergyMeterHandler.initialize(SMAEnergyMeterHandler.java:92) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]
2022-12-09 12:31:54.451 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'smaenergymeter:energymeter:3002134196': null
java.lang.UnsupportedOperationException: null
	at java.util.Collections$UnmodifiableMap.put(Collections.java:1457) ~[?:?]
	at org.openhab.binding.smaenergymeter.internal.handler.SMAEnergyMeterHandler.initialize(SMAEnergyMeterHandler.java:92) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]

Thanks for your help. Christian

Which OS you are speaking about? Windows? How many energymeters are active in your system?

I could install org.openhab.binding.smaenergymeter-3.4.0-20221127.jar on window 10 / openhab-3.4.0-snapshot. Works similar to the 3.3.0 version which I tested on Raspberry / Debian, see my previous post.

The following procudure has been used for the installation on windows:

  1. Start openhab → start.bat
  2. Log into UI and delete the installed energymeter binding
  3. Logout from karaf console
  4. Copy the new bindung into directory …\openhab-3.4.0-snapshot\addons
  5. Start openhab again

If you have one energymeter installed in your system, in the UI under ‘things’ you should see two energymeter things: One with status ‘ONLINE’ which shows the automatically discovered serial number of your installed energymeter and a second one with status ‘ERROR:HANDLER’ which shows the default serial number. This thing can be deleted without a visible impact to the system.
Btw. I should mention that I use text based rules, items and thing definitions.

I have just installed the 3.3.0_0221127.jar binding on my second house system running openHabian 3.3.0 Stable on a raspberry. This system has 3 SMA devices.

Home Manager 2.0 3002857362
Sunny Boy PV Inverter 3005990149
Sunny Boy Battery Inverter 3004092287

This system has been working for over a year and give correct values in the SMA -Sunny Portal.

Once I loaded the *.jar binding into the add-ons directory, the binding appeared in the bindings list and by clicking on it, it showed two SMA Energy Meters. The first had the correct serial number for the Home Manager. I added this as a thing, it immediately showed ONLINE and so I imported the fields into my house model. So far all the fields are showing sensible values with no spurious readings.

I then tried to install the second SMA Energy Meter. This had no serial number shown, so I entered the number for the PV inverter, will all other fields set the same as the Home Controller. This thing failed to go online and after 20sec, reported that the thing had GONE. The same thing occured when using the battery inverter number.

Before I start to find the problem, can someone confirm that this SMA binding does work with more than one meter device on the same system? Has anyone yet used it with Manager, Inverter and Battery?

PJG

Not sure if I really understood what you wanted to achieve. According to your list you have three SMA devices, one of them is an energy meter. The binding found correctly the one energy meter in your system. It can only serve energymeters not inverters. So I don’t understand why you use the serial numbers of the two inverters as input for the energymeter binding? For the inverters you have to use the modbus binding.
Regarding the number of supported energy meters splatch should be able to give an answer.

This is my confusion with the set up.

The SMA Smart Home meter simply measures power to and from the grid. But I want to see, at any time, the amount of power being generated by the PV inverter and the power into or out from the battery. Both the PV inverter and the battery inverter measure these values and as I understand, broadcast them as they are displayed on the Sunny Portal page.

Are you saying that the binding only supports the Smart Home meter and that I need to have a separate modbus binding to access the power values from the two inverters?

PJG