Custom Component: ABB/Power-One/FIMER PV Inverters - SunSpec Modbus TCP

I think I’ve found the problem. If I’m correct the logger accept only 1 connection to the API.
The second one gets an error.

Since in my Node flow I’ve selected the keepalive option this remains active even between the various GET request.

I’ve duplicated the http request node in my flow and 1 gets the data, the other gets an error.

I’ll make some more test.

Thank you Fabiano. If needed, you can find me on Discord: alexdelprete

OK, mistery solved…It wasn’t the number of connection but 2 different problems.

  1. wrong password :frowning:
  2. the client needs to authenticate without prior challenge, with wget:
wget -v --auth-no-challenge --http-user=reader --http-password=*correct password* http://192.168.1.102/v1/livedata
--2023-07-23 21:59:02--  http://192.168.1.102/v1/livedata
Connecting to 192.168.1.102:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]
Saving to: ‘livedata’

So you need to find a way to insert that parameter in your python code…
Hope it helps

Interesting finding, thanks. So the VSN700 doesn’t challenge at connect, that means it requires “Preemptive Authentication”, will modify the code accordingly.

Two things:

  1. on the VSN300 there’s a GUEST user who is read-only (no password). Is there anything like that onVSN700? If so, I could use that without requiring users to input user/password.

  2. Can you please test these two URLs and post the result? Thanks.

wget -v --auth-no-challenge --http-user=reader --http-password=*correct password* http://192.168.1.102/v1/status
wget -v --auth-no-challenge --http-user=reader --http-password=*correct password* http://192.168.1.102/v1/feeds

Hi Alex, both URL are available also on my logger, I can’t’ post the log but the download was succesful.

As per the default account my Inverter/Logger doesn’t have the Guest account, my system have a “Utente” account originally without password, don’t know if it comes from the factory fw or if it was created by my installer during set-up.

I’d need the output of all available URLs to check the format and what data is available since I need to map it inside the component. When you can, if you can provide the raw output of all 3 urls It would be really helpful.

Yes the VSN300 has a default read-only account without password, can you check if UTENTE on the VSN700 has read rights by using that one with no password? Strange that the user name is in italian. :slight_smile:

Also, I finished implementing the Preemptive Basic Authentication handler, and I’m using /v1/livedata as URL for the VSN700 right now, could you test last version and report back if auth is working finally and if data is coming back? Thanks.

Thanks a lot for helping me Fabiano. :slight_smile:

Ciao Alex,
all three URL are available to the “Utente” user, without setting a password

wget -v --auth-no-challenge --http-user=Utente --http-password= http://192.168.1.102/v1/status 
--2023-07-24 19:05:07--  http://192.168.1.102/v1/status
Connecting to 192.168.1.102:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]
Saving to: ‘status’

status                                  [ <=>                                                                ]      76  --.-KB/s    in 0s      

2023-07-24 19:05:07 (2.06 MB/s) - ‘status’ saved [76]


get -v --auth-no-challenge --http-user=Utente --http-password= http://192.168.1.102/v1/feeds
--2023-07-24 19:05:44--  http://192.168.1.102/v1/feeds
Connecting to 192.168.1.102:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]
Saving to: ‘feeds’

feeds                                   [  <=>                                                               ]  46.86K   147KB/s    in 0.3s    

2023-07-24 19:05:49 (147 KB/s) - ‘feeds’ saved [47988]




wget -v --auth-no-challenge --http-user=Utente --http-password= http://192.168.1.102/v1/livedata
--2023-07-24 19:06:03--  http://192.168.1.102/v1/livedata
Connecting to 192.168.1.102:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]
Saving to: ‘livedata’

livedata                                [ <=>                                                                ]   7.71K  --.-KB/s    in 0.04s   

2023-07-24 19:06:03 (208 KB/s) - ‘livedata’ saved [7894]

I’ve got the files, I’ve redacted the client ID (I think the MAC address of the logger), I’ll find a way to send it to you.

Thanks Fabiano.

When you can, please try last version of the python app to check if finally we’re able to auth to the VSN700 and receive data. :slight_smile:

Now I have another error

This is my cfg

[VSNX00]
# vsnmodel: VSN300 or VSN700
# hostname: hostname/IP of the VSN datalogger
# username: guest or admin
# password: if user is admin, set the password

vsnmodel = VSN700
host = 192.168.1.102
#host = cb4ef93b-9322-4bcd-bb65-95c236569503.mock.pstmn.io
username = Utente
password = 
#password = vsn700

and the result is:

python vsnx00-monitor.py 
Traceback (most recent call last):
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 377, in <module>
    print(main())
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 364, in main
    vsnx00_data = func_get_vsnx00_data(config)
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 250, in func_get_vsnx00_data
    return_data = pv_meter.get_vsn700_live_data()
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 161, in get_vsn700_live_data
    if not self.sys_data['device.invID']['Value']:
KeyError: 'device.invID'

I get the same error if I set the cfg with correct userid/password

Ok…at least it passes the authentication…the problem is how the data is formatted, since I didn’t analyze it yet…

Let me just print everything…I’ll let you know in a few minutes.

Can you try again now? I just print whatever comes from the VSN700 with no parsing…

If you use the --debug option, you will get more detailed log…

Let me know, thanks.

With “Utente” as username and no pwd I get auth error:

$ python vsnx00-monitor.py 
2023-07-24 20:36:18,065 - __main__ - ERROR - HTTP Error 401: Unauthorized
2023-07-24 20:36:18,067 - root - WARNING - No live_data received from VSNX00 logger. Exiting.
Traceback (most recent call last):
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 378, in <module>
    print(main())
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 365, in main
    vsnx00_data = func_get_vsnx00_data(config)
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 264, in func_get_vsnx00_data
    sys_data.update(live_data)
TypeError: 'NoneType' object is not iterable

With username and pwd the error is different

$ python vsnx00-monitor.py --debug
2023-07-24 20:39:26,722 - root - INFO - STARTING VSNX00 data capture
2023-07-24 20:39:26,722 - root - INFO - Capturing live data from ABB VSNX00 logger
2023-07-24 20:39:26,723 - __main__ - DEBUG - Check VSN model: vsn700
2023-07-24 20:39:26,725 - root - DEBUG - Start - get_vsn700_live_data
2023-07-24 20:39:26,725 - __main__ - INFO - Getting VSNX00 data from: http://192.168.1.102/v1/livedata
2023-07-24 20:39:26,726 - __main__ - ERROR - a bytes-like object is required, not 'str'
2023-07-24 20:39:26,726 - root - WARNING - No live_data received from VSNX00 logger. Exiting.
2023-07-24 20:39:26,726 - root - DEBUG - End - get_vsn700_live_data
2023-07-24 20:39:26,726 - root - DEBUG - =======live_data===========
2023-07-24 20:39:26,727 - root - DEBUG - None
Traceback (most recent call last):
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 378, in <module>
    print(main())
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 365, in main
    vsnx00_data = func_get_vsnx00_data(config)
  File "/home/oper/IOT/vsnx00-monitor/vsnx00-monitor.py", line 264, in func_get_vsnx00_data
    sys_data.update(live_data)
TypeError: 'NoneType' object is not iterable

Seems like auth was successful, but there’s a problem with the returned data. I changed the url from /v1/livedata to /v1/status (line 166), try with this one. You can also try to modify with /v1/feeds later.

Let me know…

Nope, same error with all 3 URL.
If i use wget the command downlad a text file with a json object inside.

The status path download a “status” file that contains

{"time":1690233831,"keys":{"logger.loggerId":{"value":"XX:XX:XX:XX:XX:XX"}}}

I redacted the ID value, is a kind of mac address, but not the logger MAC, I checked on my arp and it’s different.

I’m not a developer but it seems the code doesn’t interpret the data as a json object but as a string, could you modify the code to dump the raw data it gets from the URL?

Not a dev either since more than 20y (last time I worked as a developer, Python didn’t even exist), but I like to tinker and make things work. :slight_smile:

Jokes apart, I found the bug: it was not related to the JSON data, it was the basic authentication stuff, I wasn’t encoding/decoding the user:pw when adding the header.

            raw = "%s:%s" % (user, pw)
            raw_b64 = base64.standard_b64encode(raw.encode('utf-8'))
            auth_val = 'Basic %s' % raw_b64.decode('utf-8').strip()
            req.add_unredirected_header(self.auth_header, auth_val)

So now for the VSN700 since I don’t have the whole dataset, I’m dumping everything raw without parsing, exactly like you do with wget/curl. At line 160 you see I’m using /v1/status, you can modify it /v1/livedata or /v1/feeds so we can see the different data sets.

Last thing: I modified the config file, now you need to enter the URL to the logger, including prefix HTTP/HTTPS. Had to do it because the mock server works only via https.

Let me know…and thanks for all the help.

OK, It works,
I’ve been able to gather all 3 patths JSON dump, How can I send you the results?

Great. :slight_smile:

I’ll write you in DM.

Ciao Alex, credo tu sia italiano quindi ti scrivo in italiano.
Ho un UNO-DM-3.0-TL-PLUS ma non riesco a capire che valori per
Modbus slave addr
Modbus Register …
ho fatto svariate prove ma non riesco ad avere una configurazione valida per ottenere le varie entità.
grazie 1000
Pietro