catalinsanda / org.openhab.binding.solarman

Binding used to communicate with Solarman (IGEN-Tech) v5 based solar inverter data loggers
Eclipse Public License 2.0
8 stars 2 forks source link

Openhab 4 - incorrect channels #23

Closed PottiMc closed 9 months ago

PottiMc commented 1 year ago

Hi,

I can install the binding without problems and it is connecting to my SUN800G3 logger with the profile deye_2mppt. I can create new items in the channel but the default type for the item is always "Switch" and there is a question mark after the channel description. When I change all values by hand to the right one (frequency, voltage, ...) the binding is pulling the values correct but without units and without decimals.

grafik

grafik

Strange thing is I can't even find the new created items in the developer sidebar. If I open the item in the Model tab the channel ist with a question mark. Sometimes Openhab tells me the channel is broken and if I want to delete it.

grafik

After a restart of Openhab, all channels and links in the binding will be deleted!

This is the only binding this is happening. All others are working fine even when defining new channels and links.

Any idea why this is happening?


Openhab Version: 4.0.1 Binding version: 0.2.4 + 0.2.2 (tried both, same issues)

catalinsanda commented 1 year ago

Hey,

So it seems there are three issues:

  1. Default Item type is set to switch - I'll look into it and see if I can add the type when defining the channel.
  2. Item's don't get the correct value - Can you provide some debugging logs after issuing a log:set TRACE org.openhab.binding.solarman in the console?
  3. Channels are seen as invalid - I'll try to replicate that. It might be caused by the fact that this binding defines the channels dynamically, not statically like most others do. Either OpenHAB is caching some channel values or I have a bug when defining them (or both).

Regards, Catalin

PottiMc commented 1 year ago

Thanks for that fast answer!

Here is the trace: grafik

And here is the new created item. The semantic options and the item type are set by me. grafik

catalinsanda commented 1 year ago

Can you post the logs as text?

PottiMc commented 1 year ago

Texts are coming. I gotta go get the logs.

This is after a restart. No channels are there anymore. grafik

Here are the logs directly after restart:

`2023-08-02 09:43:26.198 [WARN ] [core.thing.internal.ThingManagerImpl] - Channel types or config descriptions for thing 'solarman:logger:a43bb0cd18' are missing in the respective registry for more than 120s. In case it does not happen immediately after an upgrade, it should be fixed in the binding.

2023-08-02 09:43:26.199 [WARN ] [core.thing.internal.ThingManagerImpl] - Failed to normalize configuration for thing 'solarman:logger:a43bb0cd18': {thing/channel=Type description solarman:running_status for solarman:logger:a43bb0cd18:inverter#running_status not found, although we checked the presence before.}

2023-08-02 09:43:26.202 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'solarman:logger:a43bb0cd18' changed from UNINITIALIZED (NOT_YET_READY) to INITIALIZING

2023-08-02 09:43:26.204 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'solarman:logger:a43bb0cd18' changed from INITIALIZING to UNKNOWN

2023-08-02 09:43:26.252 [DEBUG] [arman.internal.SolarmanLoggerHandler] - Found definition for deye_2mppt

2023-08-02 09:43:26.271 [DEBUG] [arman.internal.SolarmanLoggerHandler] - Fetching data from logger

2023-08-02 09:43:26.375 [DEBUG] [rnal.modbus.SolarmanLoggerConnection] - Request frame: A5170010450000B4D547F902000000000000000000000000000001030003007E35EADB15

2023-08-02 09:43:26.708 [DEBUG] [rnal.modbus.SolarmanLoggerConnection] - Response frame: A50F01101500D5B4D547F90201FCDC5100AE290000212C78640103FC3233303232353832313600010000120C070001010116121800001F4000000201004B0000003C170802092A1A000000000ABE07081450128E000000000000139C002C00000000000000000064000000000001000000000001000000000001FFF50000000A00020000000000000000000000040000000000000A7500000000000000000000051D0000050D0000094C00000000000200000000139200000000000000000000000002A80000000000000B540000000000000000000000000000000000000000000000000000000000000000000000000108000C012E000B0000000000000000000000000000000000000000000000000000000000000000C04FF515

2023-08-02 09:43:26.712 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'solarman:logger:a43bb0cd18' changed from UNKNOWN to ONLINE

2023-08-02 09:44:26.270 [DEBUG] [arman.internal.SolarmanLoggerHandler] - Fetching data from logger

2023-08-02 09:44:26.274 [DEBUG] [rnal.modbus.SolarmanLoggerConnection] - Request frame: A5170010450000B4D547F902000000000000000000000000000001030003007E35EADB15

2023-08-02 09:44:26.603 [DEBUG] [rnal.modbus.SolarmanLoggerConnection] - Response frame: A50F01101500D7B4D547F9020138DD5100EA290000212C78640103FC3233303232353832313600010000120C070001010116121800001F4000000201004B0000003C170802092A1A000000000ABE07081450128E000000000000139C002C00000000000000000064000000000001000000000001000000000001FFF50000000A00020000000000000000000000040000000000000A7500000000000000000000051D0000050D0000094C00000000000200000000139200000000000000000000000002A80000000000000B540000000000000000000000000000000000000000000000000000000000000000000000000108000C012E000B0000000000000000000000000000000000000000000000000000000000000000C04F7015`

catalinsanda commented 1 year ago

So looking at the logs I see:

[0x006D]: 0x0108 (264)
[0x006E]: 0x000C (12)
[0x006F]: 0x012E (302)
[0x0070]: 0x000B (11)

So, PV1 Voltage/Current is 26.4V & 1.2A and PV2 Voltage/Current is 30.2V & 1.1A. Aren't those the values you see?

catalinsanda commented 1 year ago

I'll look into the other bugs later on, as it requires a bit of digging.

PottiMc commented 1 year ago

As I said, I can see those values with no decimals like in my screenshot. When defining the state description with decimals they are changing correct.

But after that I can't find any of the linked items in the developer sidebar which is quite strange. Never had this case in years of using openhab. I can find the new item (PV1 Voltage in this case) in the item search anyway, so it is there. And it's not possible to connect the item to pages for example.

grafik

After restarting all channels are gone and the Solarman thing is useless in the UI. But still sending and receiving log entries every 60 seconds.

Let me know if you need anything more.

catalinsanda commented 1 year ago

Not at this moment.

I think the value is correct. The lack of decimals is just caused by the way is displayed. I'll see if I can define the format on the channel. Regarding the channels disappearing, there is an issue with them, as other people have complained as well. Myself, I don't define the things/items with the UI, but with files, and this problem has never manifested.

Anyways, I'll try to setup the binding entirely through the UI and hopefully figure out what's going on.

catalinsanda commented 1 year ago

Okey, I've solved the issue with the question mark and type always being Switch. Haven't created a release yet as I hope to fix the channel problem as well.

Regarding the channels, I have a general idea what's causing it, but I don't know how to fix it in code yet. Not sure if you care for the low level details.

Anyways, to work around it, until (hopefully) a proper fix is in place:

  1. Stop OpenHAB
  2. Open $OPENHABDIR/userdata/jsondb/org.openhab.core.thing.Thing.json, locate the solarman thing in there, and delete the items in the list of channels. After you're done it should look something like this:
    {
    "solarman:logger:c13a41c5b8": {
    "class": "org.openhab.core.thing.internal.ThingStorageEntity",
    "value": {
      "isBridge": false,
      "channels": [
      ],
      "label": "Solarman Binding Thing",
      "configuration": {
        "hostname": "a.b.c.d",
        "inverterType": "deye_......",
        "port": 8899,
        "refreshInterval": 60,
        "serialNumber": "1234567890"
      },
      "properties": {},
      "UID": "solarman:logger:c13a41c5b8",
      "thingTypeUID": "solarman:logger"
    }
    }
    }

    Save and especially if you are on Windows, remember to close the file.

  3. Restart OpenHAB

After startup and binding initialization, if you re-open the same file, you should see that now it contains the right channels for your inverter. If you don't update the inverter type, you shouldn't run into this problem again. I've seen that the problem manifests when defining the Solarman thing, saving it with an inverter type and then changing the value.

Hope this helps, Catalin

PottiMc commented 1 year ago

I am able to restart with this workaround and not losing the channels. Thank you for that quick response. If you want me to test your release with the defined channels please let me know.

After startup and binding initialization, if you re-open the same file, you should see that now it contains the right channels for your inverter. If you don't update the inverter type, you shouldn't run into this problem again. I've seen that the problem manifests when defining the Solarman thing, saving it with an inverter type and then changing the value.

=> I don't think I actually did change it afterwards.

catalinsanda commented 1 year ago

I don't think I actually did change it afterwards.

In hindsight I would have loved to see the old list of channels that were in that file before deleting them. Maybe it would have helped with the debugging.

Thanks, I'll be keeping this issue open until I come up with a fix for this.

catalinsanda commented 1 year ago

In hindsight I would have loved to see the old list of channels that were in that file before deleting them. Maybe it would have helped with the debugging.

On second thought, if you go to $OPENHABDIR/userdata/jsondb/backup - there are old versions of the file in the format ${timestamp}--org.openhab.core.thing.Thing.json. Maybe you can find the old list of channels in there. If you do can you please paste it here?

Thanks, Catalin

PottiMc commented 1 year ago

I am sorry, backups are all from this morning since I created a lot of new things when switching to the Hue v2 binding and restarting afterwards. And now I just created all the new channel items for your binding and I don't want to uninstall it again. Is that okay for you or do you want the logs so badly? :D

catalinsanda commented 1 year ago

No, it's ok. don't worry. They might have helped, but I'm sure I'll be able to figure it out without them.

catalinsanda commented 1 year ago

Can you give this release a try: https://github.com/catalinsanda/org.openhab.binding.solarman/releases/tag/v0.3.0 ?

The good news is that I believe I have fixed the issue. The bad news is that I had to change the IDs of the channels, so items have to be re-linked.

PottiMc commented 1 year ago

Hi, I tested your release. It is working fine for my deye_2mppt now and even after a reboot all channels are still there. Thank you!

Still, the items are missing a (internal) state description and type. One has to change that by hand for every item. Of course I know that is not a bug but very convenient to have it ready from start.

Example: PV1 Current

Here is the item fresh from your binding: (Value is only "1") grafik

Here is my adjusted one: (Value is "1,3 A") => Type Number:ElectricCurrent, State Description: %.1f A grafik

catalinsanda commented 1 year ago

Okey, let me see what I can do, and thanks for testing the release.

catalinsanda commented 1 year ago

@PottiMc - can you give this release a try: https://github.com/catalinsanda/org.openhab.binding.solarman/releases/tag/v0.3.1 ? It should solve the issues you pointed out. Here are some items being created using the defaults: image

PottiMc commented 1 year ago

Unfortunately in my case with a deye_2mppt it is still not right. grafik

catalinsanda commented 1 year ago

That's very strange. Here is how deye_2mppt looks on my install.

It either did not pick up the new version, or is again a caching problem, where it has cached the old channels config descriptors and is using that instead of what the binding provides.

image