[myenergi] MyEnergi Binding

oh, cool. thx. how does it work? do you have an example? thanks in advance!

For all those interested: the programmer of the binding is working on updating the binding and getting it into the OH distro in the coming weeks ā€” great news :slight_smile:
The code will include sending the charge mode for the Zappi.

2 Likes

Hi Stephen. Sorry, that it took so long for me to get back to you.
Iā€™m just making a few changes to support missing features and though Iā€™d also incorporate the EDDI changes. However, I canā€™t see you PR. Did you submit this against my github repo?
Iā€™ve renamed the branch to myenergi_binding_3.4.x to distinguish it from the work Iā€™m doing for OH 4.0.

Otherwise, if you let me have your source code, Iā€™ll figure out the changes myself.

Many thanks,
Rene

Just a quick update:

Iā€™ve merged the support for Eddi contributed by @stephenc and made a couple of smaller changes to the Zappi code so that for example charge mode can be changed through the item as well as an new action.

Initial build seems to be working fine and Iā€™m just tidying up my code a bit, complete any missing unit tests and then do a final 3.4.x build for the market place.
Once thatā€™s published Iā€™m planning to rebase on the main branch and submit the PR for the official 4.x distro.

Iā€™ve just uploaded the latest build with Eddi and writable Zappi charging mode support. Let me know if everything work as expected or not.

Many thanks,
Rene

Thank you Rene for updating this binding :+1:

It seems to work for all other values / parametersā€¦

The parameter:
image

chargingMode	Number	Boost, Fast, Eco or Eco+

How can this be set to STOP?

I can change between the settingsā€¦ but not issue stop.

Also, despite the channel being a string, the item


is a string too, but shows a number (2 = ECO?!) in the item view.
(This could be just silly old me ā€œnot getting itā€)


Two maps for general interest:

zappi_command_status.map

1=trying
2=trying
3=trying
4=trying
5=trying
6=trying
7=trying
8=trying
9=trying
10=trying
254=ACK OK
255=Never sent
-=undefined

zappi_locking_mode.map

0=Locked now
2=Lock when plugged in
4=Locked when unplugged
8=Charge when locked
16=Charge session allowed, even when locked
-=undefined

Hi Max

Iā€™m not sure, I understand what you mean with ā€œStopā€. There is no charging mode where itā€™s stopped.

Regarding the charging mode, yes, this is how enumeration channels should be represented. The corresponding item definition is:

<channel-type id="chargingModeType">
	<item-type>String</item-type>
	<label>Charging Mode</label>
	<description>The current charging mode of the device</description>
	<state readOnly="false">
		<options>
			<option value="0">Boost</option>
			<option value="1">Fast</option>
			<option value="2">Eco</option>
			<option value="3">Eco+</option>
		</options>
	</state>
</channel-type>

Behind the scenes, the item is represented by a string, but contains a numeric value. This allows for displaying the ā€œnameā€-equivalent (e.g. ā€œFastā€), but the item value is ā€œ1ā€.
If you want to change the charging mode through the console or in a script, you have to send it the corresponding numeric value as a string. e.g.

openhab> openhab:send Zappi_ChargingMode "3"

will set the mode to ā€œEco+ā€. Iā€™ll extend the documentation a bit more, to make that clear.

The command status could potentially also be represented as an enumeration, but I didnā€™t see a big benefit, so just left it as a number.

<channel-type id="commandTriesType">
	<item-type>Number</item-type>
	<label>Command Status/Retries</label>
	<description>0-10 Trying, 253 Acked and Failed, 254 Acked and OK, 255 No command has ever been sent</description>
	<state readOnly="true" pattern="%d"/>
</channel-type>

The locking mode is a bitmap, so more than one bit can be set at any point in time. e.g. 12 = ā€œLocked when unpluggedā€ as well as ā€œcharge when lockedā€.

1 Like

To explain my use caseā€¦

I charge with excess solar.
OH will provide me with generation, consumption and export values.
Once my home battery is at 95% and solar is >1.5kW then switch Zappi ECO ON.
Once the it is past 15:00 and the solar generation provides less than 1.5kW, switch the charging OFF = Stop; please see below.

[I use ECO instead of ECO+ to avoid the constant alerts that charging has stopped.]

Without the ability to issue STOP charging, this use case does not work :slight_smile:

Number enumeration is perfect; allows users to show words in their native language.

Youā€™re right. I did a bit of digging and there seems to be now a STOP mode (with code 4) where the Zappi never charges. Iā€™ll just add that into the code and build a new version. Should be available this evening.

1 Like

Hope you had a great Easter break. I kept looking on your Google drive for the latest version, but the last one shown is from April 2.

It also seem that the myengi API seems to have problems, as I am getting 253s ever y30 seconds since 01:00 UTC+10. The app says the same.

As for the bitmap for the locking modes, maybe you can add the docu what these non-listed combinations may mean?!

Other than that, the binding seems to be working without fault.
The OH rules trigger ECO, and STOP; the latter of course fails until implemented. :slight_smile:

Hi Max

Iā€™ve uploaded a new version just before Easter (8th April), this contains the STOP mode change. Let me know if you still canā€™t see it on the drive.
Iā€™ll have a look if I can find anything about the nightly issue around 1am. Iā€™m getting the same and then it recovers again after a while. Maybe some maintenance window on the Myenergi servers.

Kind regards,
Rene

1 Like

Thank youā€¦ browser refresh shows new jarā€¦ installedā€¦ works. :smiley:

I think the API errors where on their endā€¦ these showed in their app as wellā€¦

I also noticed, compared to the channels listed in your O.P. this channel:

<channel id="status" typeId="statusType"/>

ā€¦ seems missing.

The following was observed on 2023-04-16 12:03 UTC+10, which seems another problem at their end? Not sure if and how to improve on this error message.

2023-04-16 12:03:52.547 [INFO ] [.myenergi.internal.MyEnergiApiClient] - Re-initializing Api connection after exception caught
java.util.concurrent.ExecutionException: java.io.EOFException: HttpConnectionOverHTTP@6e43ea::DecryptedEndPoint@13979da{l=/192.168.1.5:49080,r=s18.myenergi.net/54.195.158.93:443,OPEN,fill=-,flush=-,to=31604/0}
Caused by: java.io.EOFException: HttpConnectionOverHTTP@6e43ea::DecryptedEndPoint@13979da{l=/192.168.1.5:49080,r=s18.myenergi.net/54.195.158.93:443,OPEN,fill=-,flush=-,to=31604/0}
2023-04-16 12:03:55.581 [INFO ] [.myenergi.internal.MyEnergiApiClient] - Re-initializing Api connection after code: 0, reason: 
2023-04-16 12:03:58.598 [INFO ] [.myenergi.internal.MyEnergiApiClient] - Re-initializing Api connection after code: 0, reason: 
2023-04-16 12:04:01.608 [WARN ] [al.handler.MyEnergiBaseDeviceHandler] - Exception from API - myenergi:zappi:api:16181111
org.openhab.binding.myenergi.internal.exception.ApiException: Http error after several attemps: 0 - 

Hi,
thanks for providing this Binding.
Iā€™ve managed to install it in my Docker-Based Openhab 4.1 installation.
First Iā€™ve create an API Key on the myenergi webpage und then I created a things file in the corresponding folder.

Used my Myenergi Webpage login and password for the file and updated the serial numbers for my Zappi and the Harvi.

After saving the things file I get the following error message: {hubSerialNumber=Der Parameter wird benƶtigt.}

But I canā€™t find a place to enter a hub serial number.

Is the API Key also need for the configuration? Iā€™ve tried to use it a username or password but always the same problem :frowning:

2024-02-05 20:12:43.507 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'myenergi:bridge:api' changed from UNINITIALIZED (HANDLER_CONFIGURATION_PENDING): {hubSerialNumber=Der Parameter wird benƶtigt.} to UNINITIALIZED
2024-02-05 20:12:43.512 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'myenergi:bridge:api' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2024-02-05 20:12:45.939 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'myenergi:bridge:api' changed from UNINITIALIZED (DISABLED) to UNINITIALIZED (HANDLER_CONFIGURATION_PENDING): {hubSerialNumber=Der Parameter wird benƶtigt.}

Thatā€™s my things file:

Bridge myenergi:bridge:api "MyEnergi API Bridge" [ username="MYUSERNAME", password="MYPASSWORD", refreshInterval=24 ] {
  Thing zappi 21088888 "MyEnergi Zappi" [ refreshInterval=30 ]
  Thing harvi 1947777 "MyEnergi Harvi" [ refreshInterval=30 ]
}

Appreciate your help :slight_smile:

The hub serial number goes into the API bridge thing.

UID: myenergi:bridge:api
label: myenergi API Bridge
thingTypeUID: myenergi:bridge
configuration:
  hubSerialNumber: "12345678"
  refreshInterval: 24
  password: PanucD3IxZkKI8uOx796gXTX
location: 3-port Garage

Meaning you have two things:

  1. API thing
  2. Zappi thing

Hi @Max_G,
thanks so much.
I finally got it working.
Andy