[myenergi] Binding for myenergi Ltd devices (Zappi, Eddi, Harvi)

I’ve recently had a Zappi EV-charger installed and I’m thinking of writing a binding to access the myenergi (https://myenergi.com/) API through openHAB. I know some of the measurements could simply be implemented with the HTTP binding, but for the more active management (e…g Zappi), it would be great to have some actions etc. to use in rules.

Does anyone know of any effort already under way? Although the API is still under development and not “officially available”, there is some python and php code available and the engineers from myenergi do provide basic support in their forums.

The sort of features I’m planning to implement are:

  • measurement of power consumption (grid, car, solar etc.)
  • change of charging mode, boost settings and schedule for Zappi
  • charging status (e.g. for alerting if charging stops unexpectedly)

Cheers,
Rene

3 Likes

Hi, I wonder whether you made any progress with this? If so I’d be interested in it. Have not installed any myenergi equipment yet but intending to do so soon.

Thanks

Hi Simon
I’ve got a working version with the following features:

  • read consumption and generation from Harvi & Zappi (probably also works with Eddi, but not tested)
  • change Zappi charging modes (Fast, Eco, Eco+)
  • read Boost information (I’m currently working on setting scheduled boosts)

There is a small problem at the moment that every so often I receive an http error 400, but I’m working to resolve that.

2 Likes

Sounds promising!

Any progress with this, I am considering getting the Eddi for solar PV diversion but would love to pull the data into my home automation system. Is your code anywhere I can have a look at?

Cheers!
Ben

Hello, any progress on this? i have a zappi charger and want to monitor/automate it with openhab

1 Like

Hi Rene, @scherer!

This sounds super interesting! Is the code available somewhere? I don’t have much spare time, but I’d be happy to contribute if you’d like.

Take care,
Henrik

1 Like

Hi @henriksvensson

Sorry, I haven’t had a lot of time working on it recently. The latest code is here: https://github.com/renescherer/openhab-addons/tree/myenergi_binding

I’ve had it running in my OH instance for a while, but mainly read-only (getting energy readings). At least the following would need to be done before I can ask for a PR:

  • testing of “writeable” features (e.g. change of boost mode/time etc.)
  • I think there is an issue with error handling if the API returns http error. Haven’t been able to reproduce.
  • code tidying up (logging etc.)

Kind regards,
Rene

1 Like

Thanks, that’s awesome! Personally, I think the read-only version would be quite interesting to release as a first version of the binding. I’ll see if I manage to get it up running on my setup.

Take care,
Henrik

I’ve built a version for the latest OH 3.2-SNAPSHOT (works also with 3.1) and a couple of example config files: Google Drive

5 Likes

Hi @scherer , hi @henriksvensson ,

thanks for that!

Tried to install the version from 07th September on openHAB 3.1.0.M3, but error.log stated:

2021-10-28 21:47:39.552 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openhab/addons/org.openhab.binding.myenergi-3.2.0-SNAPSHOT.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.myenergi [131]

  Unresolved requirement: Import-Package: javax.measure; version="[2.1.0,3.0.0)"

    at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]

    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]

    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]

    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]

    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4]

    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4]

    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]

    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Something went wrong. What I’m missing?

Thanks in advance.

Kind Rgds
André

Maybe some knowledge can be gleaned from here:

As an openHAB user I am definitely interested in the OH solutions/binding.

Maybe this will be my final nudge to migrate to OHv3 :smiley:

Thanks, I got it to work with my Zappi and Harvi, GREAT WORK!
But after some time, or maybe restart of OpenHAB I retrieve old values back from August

Looking in log an see that API calls url https://s1.myenergi.net/, and when I got correct values API call was toward https://s18.myenergi.net /

Seems like randomly select s1 or s18 after openhab restart? Have you seen this issue.

Similar issue is discussed here:
API returning old data - myenergi

with the openHAB 3.2.0.M5 it works.

still struggling with login:

2021-12-10 20:51:48.287 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'myenergi.things'
2021-12-10 20:51:48.484 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'jdbc.persist'
2021-12-10 20:51:50.684 [INFO ] [.myenergi.internal.MyEnergiApiClient] - sending API request attempt# 1: https://se.myenergi.net/cgi-jstatus-*
2021-12-10 20:51:50.904 [INFO ] [.myenergi.internal.MyEnergiApiClient] - Re-initializing Api connection after exception caught
java.util.concurrent.ExecutionException: java.net.UnknownHostException: se.myenergi.net: Name or service not known
	at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118) ~[bundleFile:9.4.43.v20210629]
	at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101) ~[bundleFile:9.4.43.v20210629]
	at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:730) ~[bundleFile:9.4.43.v20210629]
	at org.openhab.binding.myenergi.internal.MyEnergiApiClient.executeApiCallHttpClient(MyEnergiApiClient.java:367) [bundleFile:?]
	at org.openhab.binding.myenergi.internal.MyEnergiApiClient.executeApiCall(MyEnergiApiClient.java:338) [bundleFile:?]
	at org.openhab.binding.myenergi.internal.MyEnergiApiClient.getDeviceSummaryList(MyEnergiApiClient.java:208) [bundleFile:?]
	at org.openhab.binding.myenergi.internal.MyEnergiApiClient.updateTopologyCache(MyEnergiApiClient.java:157) [bundleFile:?]
	at org.openhab.binding.myenergi.internal.handler.MyEnergiBridgeHandler.initialize(MyEnergiBridgeHandler.java:86) [bundleFile:?]
	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) [?:?]
Caused by: java.net.UnknownHostException: se.myenergi.net: Name or service not known
	at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[?:?]
	at java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929) ~[?:?]
	at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1519) ~[?:?]
	at java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848) ~[?:?]
	at java.net.InetAddress.getAllByName0(InetAddress.java:1509) ~[?:?]
	at java.net.InetAddress.getAllByName(InetAddress.java:1368) ~[?:?]
	at java.net.InetAddress.getAllByName(InetAddress.java:1302) ~[?:?]
	at org.eclipse.jetty.util.SocketAddressResolver$Async.lambda$resolve$1(SocketAddressResolver.java:170) ~[?:?]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) ~[?:?]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) ~[?:?]
	... 1 more
2021-12-10 20:51:53.945 [INFO ] [.myenergi.internal.MyEnergiApiClient] - Re-initializing Api connection after code: 0, reason: 
2021-12-10 20:51:55.620 [WARN ] [core.thing.internal.ThingManagerImpl] - Initializing handler for thing 'myenergi:bridge:api' takes more than 5000ms.
2021-12-10 20:51:57.014 [INFO ] [.myenergi.internal.MyEnergiApiClient] - Re-initializing Api connection after code: 0, reason: 

ok for documentation reasons: GitHub - twonk/MyEnergi-App-Api: Investigation of the MyEnergi App describes the solution for the login issue and how to handle. o)

hi,

does any body know, why I’m getting allways the first entry for power clamp back and not the latest one?

2021-12-21 07:55:10.177 [INFO ] [.myenergi.internal.MyEnergiApiClient] - sending API request attempt# 1: https://s6.myenergi.net/cgi-jstatus-H12345678

2021-12-21 07:55:10.234 [INFO ] [.myenergi.internal.MyEnergiApiClient] - Api response: {"harvi":[{"sno":12345678,"dat":"17-11-2021","tim":"14:24:13","ectp1":360,"ectp2":7,"ectp3":47,"ectt1":"Grid","ectt2":"Grid","ectt3":"Grid","ect1p":1,"ect2p":2,"ect3p":3,"fwv":""}

]}

Thanks

Rgds
Andre

Hi, I just got my Zappi and HUB installed and I was keen on getting this integrated into Openhab 3.2.
Unfortunately, I am not able to log in. I am certain my username (HUB serial number, only digits) and password are correct but I am immediately getting

22:37:31.629 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'myenergi:bridge:1c8899c841' changed from OFFLINE (CONFIGURATION_ERROR): Authentication Error (Invalid API key or account number) to UNKNOWN
22:37:31.651 [INFO ] [g.myenergi.internal.MyEnergiApiClient] - sending API request attempt# 1: https://s2.myenergi.net/cgi-jstatus-*
22:37:32.061 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'myenergi:bridge:1c8899c841' changed from UNKNOWN to OFFLINE (CONFIGURATION_ERROR): Authentication Error (Invalid API key or account number)

Any idea how to fix this?

Hi,

had the same issue.

Solution: It’s not the https://myaccount.myenergi.com password (yet, because the piece to integrate that system isn’t done yet). It’s the password you used when you installed the phone app, based on the auth-code from your Zappi and you hub serial number.

and see also

Hi Rene,

thank you for providing the myenergi binding! Are you still planning on implementation of changing of the charging mode via the binding?

Thanks again and kind regards,
Franz

Thanks for the reply. I asked myenergi to reset the hub so now I am certain about the App password. Unfortunately, this did not help:

Thing 'myenergi:bridge:6e39860cbf' changed from UNKNOWN to OFFLINE (CONFIGURATION_ERROR): Authentication Error (Invalid API key or account number)