pmcgn / dbus-modbus-client-kostal-smartmeter

13 stars 3 forks source link

KSEM device cannot be found #7

Closed cRaErBs closed 1 month ago

cRaErBs commented 8 months ago

Hello Phil,

many thanks for sharing your KSEM implementation. Unfortunately I am not getting it to run on the VenusOS and I am running out of ideas what I could try in addition. I hope you could give me some hints.

Used versions: KSEM HW0100 with FW 2.4.1 RPi 3B+ with VenusOS v3.13

After following all the installation steps, I only have in the log file: @40000000658ae52a1c6f8c74 starting dbus-modbus-client @40000000658ae52e0bd434b4 INFO Waiting for localsettings @40000000658ae52e16f042d4 INFO registered ourselves on D-Bus as com.victronenergy.modbusclient.tcp @40000000658ae6ac13316de4 INFO Starting background scan @40000000658ae6ac149c061c INFO Scanning 192.168.20.129/24 @40000000658ae6c412d3e494 INFO Scan completed in 23 seconds

Strange is that after reboot "dbus-modbus-client.cpython-38.pyc" seems still not to exist. Another guess is that since I am using the latest FW from the KSEM that the Device ID is changed. So I am trying the helper script but also running into a dead end there. I will open another ticket for that.

Best regards

cRaErBs commented 8 months ago

DeviceID is 18514, so that is not the failure.

pmcgn commented 8 months ago

Hi, that's interesting.

Can you check, if the pycache exists with another trailing number (instead of 38)? Use this Command on the VenusOS Device: ls /opt/victronenergy/dbus-modbus-client/__pycache__/ | grep Kostal If it dowsn't exist, we know that it was not compiled/detected by the venusOS. If that's the case, please open the Kostal_SmartEnergyMeter.py with a text editor on the VEnusOS and check if it contains any HTML. Maybe the download has failed and it contains a github html error page.

As you can read the device id from you computer, we know that the KSEM is configured correctly (=Modus Server running) and that you know the correct IP ;) and that the id is correct for the script.

cRaErBs commented 8 months ago

Hello pmcgn,

ls /opt/victronenergy/dbus-modbus-client/pycache/ | grep Kostal

returns: _KostalSmartEnergyMeter.cpython-38.pyc

only dbus-modbus-client.cpython-38.pyc does not exist

cRaErBs commented 8 months ago

Sorry for the trouble. I used the RPi via WLAN for the start to get it installed. Now that I connectit via cable it is working. So LAN connection is a must.

Modbus TCP scan is still not working on my side. But that can be because the KSEM is in another subnet than the RPi/Venus OS at the moment. Also that will change in the future but is currently the case and I guess therefore the scan is not returning any devices.

Thanks for your help and many thanks for enabling this!

cRaErBs commented 8 months ago

Mh, one extra thing. I also tried an older VenusOS version. Since it was also not working there, I changed to LAN and it worked. Now I am upgrading to v3.13 again. and despite the LAN connection, the KSEM is not visible.

It is running with VenusOS v3.10 and LAN. With v3.13 it seems not to work also with LAN connection.

cRaErBs commented 8 months ago

Here some additional tests:

Result -- Image not ok -- venus-image-large-raspberrypi2-20231205211402-v3.13.rootfs.wic.gz & venus-image-large-raspberrypi2.wic.gz not ok -- venus-image-large-raspberrypi2-20231030212506-v3.12.rootfs.wic.gz not ok -- venus-image-large-raspberrypi2-20231009045315-v3.11.rootfs.wic.gz ok -- venus-image-large-raspberrypi2-20230911151152-v3.10.rootfs.wic.gz

gristoph commented 7 months ago

I had similar problem when using venus os 3.13 and I solved it by commenting out these lines at Kostal_SmartEnergyMeter.py

#class Reg_u64b(Reg_num):
# def __init__(self, base, *args, scale=1, **kwargs):
# super(Reg_u64b, self).__init__(self, base, *args, **kwargs)
# self.coding = ('>Q', '>4H')
# self.scale = float(self.scale)

I'm not a Python developer, but obviously with the update at Venus OS there is an attribute "count" expected, which is missing at this overriding part of Reg_u64b, so I always got

   File "/opt/victronenergy/dbus-modbus-client/Kostal_SmartEnergyMeter.py", line 46, in device_init
     Reg_u32b(0x001A, '/Ac/Frequency',         1000,  '%.1f Hz'),
   File "/opt/victronenergy/dbus-modbus-client/Kostal_SmartEnergyMeter.py", line 46, in device_init
     Reg_u32b(0x001A, '/Ac/Frequency',         1000,  '%.1f Hz'),
   File "/opt/victronenergy/dbus-modbus-client/Kostal_SmartEnergyMeter.py", line 13, in __init__
     def __init__(self, base, *args, scale=1, **kwargs):
   File "/opt/victronenergy/dbus-modbus-client/register.py", line 59, in __init__
     super().__init__(base, self.count, name, text, write, **kwargs)
 AttributeError: 'Reg_u64b' object has no attribute 'count'
GitSoDE commented 7 months ago

You made my day, can't believe it - it's working now !!!! 😍 😍

Ich verwende VOS v3.12

Habe auch in /opt/victronenergy/dbus-modbus-client/pycache die Datei dbus-modbus-client.cpython-38.pyc gelöscht.

Und dann reboot - perfect !!

Allerdings werden einige Werte nicht ganz sauber übernommen. 2024-01-27 10 11 2859

Die kWh-Werte sind statisch, hier werden vielleicht falsche Register gelesen.

cRaErBs commented 1 month ago

Deleting/ commenting out the lines also works on my side:

class Reg_u64b(Reg_num):

def init(self, base, *args, scale=1, **kwargs):

super(Reg_u64b, self).init(self, base, *args, **kwargs)

self.coding = ('>Q', '>4H')

self.scale = float(self.scale)

Thanks for the information. It would be great if the "Kostal_SmartEnergyMeter.py" file could be updated.