ha_openems icon indicating copy to clipboard operation
ha_openems copied to clipboard

Connection issue with OpenEMS

Open GrisuBerlin opened this issue 1 month ago • 10 comments

Hi, not sure if someone with OpenEMS (no commercial Fenecon) already sucessfully tested your integration? But I cannot connect to my openEMS instance. Looks like something is wrong with the internal configuration? I configurated in HA like this:

Image

But I received always an "Unknown error". After I created additional websocket on port 8084 (as I had error messages in the log in HA pointing to 8084) I was able to submit the config to my openEMS Server but still was not able to get any data. Using the error message and AI I added my host in openems.py directly:

Image

And now I receive data and all is fine.

GrisuBerlin avatar Nov 21 '25 14:11 GrisuBerlin

I test the integration on a regular base with OpenEMS.

Furthermore, the parameter you changed in the code is used exclusively for internal IDs and naming of devices / entities. It is not relevant while making connections to the OpenEMS system.

So I am a bit confused currently 🤔

Edit: Does your OpenEMS system not have a _host component and a Hostname? This could explain the problem.

In my local OpenEMS system this component always exists by default. I can add an extra fallback logic. But I wonder to what value. Maybe you could first check why this component does not exist.

At the minimum, I can handle to problem better and provide users with a more clear error message in this case.

Lamarqe avatar Nov 21 '25 23:11 Lamarqe

One more comment regarding the port number: The integration is implemented to work with an OpenEMS system which was set up as described here: https://openems.github.io/openems.io/openems/latest/gettingstarted.html The howto lists the port numbers which are even the default values when setting up an OpenEMS system.

To handle more unique setups, I had explicitly added the WebSocket connection URL option. This should be sufficiently generic. I believe this is also not your problem currently. I guess the missing _host component is the root cause.

Lamarqe avatar Nov 22 '25 00:11 Lamarqe

Ah, this is the host from openEMS comonent and not from the HA component? The _host in my openEMS seems to be emtpy.

Image

I'll need to check how to configure that. Thanks for the support. I'll try this (probably not before beginning of next week) and give feedback. Have a nice weekend!

GrisuBerlin avatar Nov 22 '25 06:11 GrisuBerlin

The integration takes the value of the _host/Hostname channel and uses it for purposes like internal IDs or even user visible strings to identify the system by a name.

You can query the the channel value also via REST.

For my OpenEMS system, this returns: {"address":"_host/Hostname","type":"STRING","accessMode":"RO","text":"","unit":"","value":"linuxlaptop"}

I never configured anything in this regard in OpenEMS myself. For me, this works like that just right away, after starting OpenEMS Edge and enabling the REST controller.

Lamarqe avatar Nov 22 '25 13:11 Lamarqe

Image

it is also filled for me.

Can you please summarize for me what is required? I need one websocket which is the one for the regular UI (in my case on Port 8075).

Image

Do I need anything in addition? Do I also need the "Controller Api REST/JSON Read-Write"? And if so, on which Port?

Thank you and best regards, Rico

GrisuBerlin avatar Nov 27 '25 08:11 GrisuBerlin

I guess you want to connect directly to the OpenEMS edge, not via the backend? Thats the 3rd connection option in the connection dialogue.

For this, I always enable in the Edge Apache Felix Web Console (running by default on port 8080):

  • Controller Api Websocket (default config: port 8085)
  • Controller Api REST/JSON Read-Only (default config: port 8084)

Lamarqe avatar Nov 27 '25 20:11 Lamarqe

Thank you!

  • Controller Api REST/JSON Read-Only (default config: port 8084)

This was the missing piece. After configuring this in OpenEMS everything works as expected (I still need the custom url, as my UI default port is not 8085 but 8075).

Perhaps you could add a note that the websocket on Port 8085 (or whatever) needs to be active (which is quite clear) but also a Controller Api REST/JSON Read-Only on Port 8084 is mandatory (that was not clear to me). That would help people like me installing everything smoothly :-)

Thank you so much for the integration and also for you support!

GrisuBerlin avatar Nov 28 '25 09:11 GrisuBerlin

I might simply remove the usage of the REST interface for all connection types.

It is already removed for the FEMS online portal (which does not provide the REST API). This seems to be working fine. So I will most likely access the required information in the same way also for the local monitoring.

This will also reduce the overall implementation footprint and avoid the necessity to make the REST port configurable and make the config dialogue even more complex.

Lamarqe avatar Nov 29 '25 09:11 Lamarqe

Changed as proposed via 073621ad65e96dc3b90b5cea46932ba0dbf07da4. Now it should also work without setting up the the REST controller in OpenEMS.

Could you try it and share feedback?

Edit: This change is now also available in the new pre-release version v1.2.1 Edit2: Please dont switch to v1.2.1 yet. There are some bugs in this version, due to unrelated changes. I will have to fix it as soon as I find time.

Lamarqe avatar Nov 29 '25 10:11 Lamarqe

Hi. Ok, thanks for your feedback. I'll test it out once it is fixed. Just let me know. Habe a nice week :-)

GrisuBerlin avatar Dec 01 '25 06:12 GrisuBerlin

There is now a v1.2.2 which solves the previous problems and is hopefully not introducing new ones. 🙈

Lamarqe avatar Dec 06 '25 16:12 Lamarqe

Thank you! I reinstalled everything and now it works fine. Have a nice christmas time :-)

GrisuBerlin avatar Dec 09 '25 11:12 GrisuBerlin