mpepping / solarman-mqtt

Send Solarman Smart PV inverter metrics to MQTT
Apache License 2.0
61 stars 21 forks source link

what is passhash #9

Closed pepelillo closed 2 years ago

pepelillo commented 2 years ago

Hello. Trying to deploy this project but, What does passhash means? The hash calculation of the password used in Solarman platform?

pepelillo commented 2 years ago

in this case, what algorithm?

mpepping commented 2 years ago

Basically, it's a sha256 hash of your solarman account password. Using Python you should be able to get it via:

import hashlib
string="myPassword"
encoded=string.encode()
result = hashlib.sha256(encoded)
print(result.hexdigest())

There are online sha256 hash tools as well .. but I wouldn't recommend using something like that.

pepelillo commented 2 years ago

thanks using openssl in linux. I guess that the inverter, logger id are serials, I'll give it a try

pepelillo commented 2 years ago

I've just tried, using my inverter S/N as InverterID, the logger S/N as loggerID and the user key as StationID I receive some error.

Please can you specify what are these "ID's"?

pepelillo commented 2 years ago

Traceback (most recent call last): File "/home/jose/Descargas/solarman-mqtt-main/run.py", line 225, in main() File "/home/jose/Descargas/solarman-mqtt-main/run.py", line 217, in main single_run(args.file) File "/home/jose/Descargas/solarman-mqtt-main/run.py", line 128, in single_run station_data = get_station_realtime(config["url"], config["stationId"], token) File "/home/jose/Descargas/solarman-mqtt-main/run.py", line 71, in get_station_realtime 'Authorization': "bearer " + token TypeError: can only concatenate str (not "NoneType") to str

mpepping commented 2 years ago

I'll extends the README.md on that. Here's an example file with dummy values, so you have an idea on values and value types:

{
  "name": "Trannergy",
  "url": "api.solarmanpv.com",
  "appid": "202012345678901",
  "secret": "abcdef1234567890abcdef1234567890",
  "username": "email@example.com",
  "passhash": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "stationId": 1234567,
  "inverterId": "XYZ1231230001",
  "loggerId": "0123456789",
  "mqtt":{
    "broker": "10.0.0.10",
    "port": 1883,
    "username": "user",
    "password": "pass"
  }
}

Hope that clarifies things a bit for now.

mpepping commented 2 years ago

@pepelillo The README is updated with details on the config file values, a --validate flag is added to validate the config file syntax and a --create-passhash flagg is added to generate a password hash.

mpepping commented 2 years ago

@pepelillo the latest version + README are updated to make things more clear. Just let me know if you run into something!