The first 12 lines should be the same to be able to connect to the inverter.
The ID used in line 17 and 18 are part of the JSON response.
The value in “keys” should be the same, I assume.
What you could to is add a line before line 17/18 with “print r.text” to see what is the returned value.
Otherwise send me a private message, I can update the script for you to test. If it works for you, I can post the rest here
I have had the same error as Toon, but I finally managed to make the script work by changing the cmd_query_total_today and cmd_query_spot_ac_power. As you can see below, I have to include the src_serial to the message, as the original script hdo did.
For some reason, they differ from yours, while I also have a SB-4000TL. I have used Wireshark to analyze the packets sent from my PC to the inverter when using the “Sunny Explorer” S/W from SMA.
I noticed that the src_serial is NOT the serial number of my inverter. I do not know to what it corresponds, but I had to extract it from a packet analyzed with Wireshark.
For info, while “Sunny Explorer” is running and connected to the inverter, just log all packets transmitted by the PC and look for ffffffffffff00007800 which is then followed by the src_serial in hex (intel format, little endian)
Hi guys, just a heads up, SMA has MODBUS integrated in their inverter.
activate this in the device and just connect with the modbus binding from openhab.
i can read actual data. (total production in kWh, current production in W, status of the inverter …)
File "sma.py", line 32, in <module>
cmd_login = '534d4100000402a000000001003a001060650ea0ffffffffffff00017800%s00010000000004800c04fdff07000000840300004c20cb5100000000%s00000000' % (struct.pack('<I', src_serial).encode('hex'), get_encoded_pw(user_pw))
AttributeError: 'bytes' object has no attribute 'encode'
For me it still works fine. However I struggle supporting the script w/o having the hardware to debug. As kahlder pointed out there seem to be some differences between the inverters which you have to analyze with Wireshark. Or you give the modbus binding a shot.
All done in Paper UI
create MODBUS TCP Slave Thing. = modbus bridge
IP ADRESS
Port: 502
ID:3
time between transactions 60
next Thing: SMA current Power
Modbus Binding - > Regular Poll
bridge = the one we created.
Poll interval : 500 ms
Lengt: 2
Maximum tries 3
Start: 30775
Type: Input register
next thing: Modbus binding , modbus Data
bridge = modbus poll we just created.
read adress: 30775
read value type: 32bit signed integer (int32)
read transform: default
write transform : default
This things has 11 channels, the channel : Value as number is the one i use to read out the current power production in W from my sma invertor.
Forget my previous post. In the meantime I figured it out a bit more.
Only thing is that my Modbus data stays offline. Modbus TCP Slave and Regular Poll are online.
I suspect you use modbus2 binding?
I use modbus2 for another device (I do have an SMA solar inverter as well, but it´s not connected through modbus yet). I went for manual modbus config files, as it´s alot easier to handle. You can find my setup in this thread.
Basicly it should be the same connecting anything else using modbus2 binding, as long as you´ve got the modbus data for your inverter.
(When I get the time, I´ll try to figure how to add my SMA TPL6000 inverter through modbus as well, but I´m in no hurry, as I´ve got the SMA Energy Meter connected insted, which gives me the same detail the inverter can give me).
I receive data from the Modbus now. Only thing is that it’s probably not in correct format.
Address 30775 (32bit signed integer) receives every ten seconds a permanent number: 2147483648.
Do I need some kind of conversion in the field ‘Read transform’ ?
Hmm my SMA SunnyBoy Storage 2.5 got BT… But it´s connected via speedwire (LAN)…
My problem is, I simply cant understand this SBFspot thing, and how to get from there to openhab.
Atm I´m using the SMA Energy Meter (connected via LAN) and the openhab binding. But it really lack information and options, which is in the Energy Meter. I have tried rise an request, but I dont think there is anymore support or development for the binding anymore.