MickMake / GoSungrow

GoLang implementation to access the iSolarCloud API updated by SunGrow inverters.
https://mickmake.com/
GNU General Public License v2.0
187 stars 48 forks source link

Unable to get PS ID?? #58

Closed hboltz closed 1 year ago

hboltz commented 1 year ago

Hi Mick,

I installed your Addon to HA and it worked so far:

2023/06/06 14:29:38 INFO: Connecting to SunGrow... 2023/06/06 14:29:38 INFO: Found SunGrow 2 devices 2023/06/06 14:29:38 INFO: Caching Sungrow metadata... 2023/06/06 14:29:38 INFO: Cached 256 Sungrow data points... 2023/06/06 14:29:39 INFO: Syncing 1565 entries with HASSIO from queryDeviceList. CU--CUCUCU-CUCUCU--CUCUCUCUCUCUCUCU-CU-CUCU-CUCUCUCUCUCUCUCUCU-CUCUCUCUCUCU-CUCU-CUCUCUCUCU-CUCU--CUCU-CUCU-CUCUCUCUCUCU---CUCU-CU-CUCU---CU-CUCU-CU-CU-CUCU---CU-CUCUCU--CU--------CUCUCUCUCUCUCUCUCU-CUCU--CUCUCUCUCUCUCUCUCUCUCU-----CUCUCU-CUCU-CUCU--CUCUCUCUCU-CU--CUCUCUCU----CU-CUCU 2023/06/06 14:29:39 INFO: Syncing 148 entries with HASSIO from getPsList. 2023/06/06 14:29:39 INFO: Syncing 246 entries with HASSIO from getPsDetail. CUCUCUCUCUCUCUCUCUCUCUCUCU??CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU ?CUCU?CUCUCU?CUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCU?CU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCU?CUCUCUCUCUCUCUCU 2023/06/06 14:29:39 INFO: Starting ticker... 2023/06/06 14:29:39 INFO: Fetch Schedule: 5m 2023/06/06 14:29:39 INFO: Sleep Delay: 40s

To go on with the graphical part, I need to know my PS ID but unfortunatelly I can't issue any command from your description in the Terminal (see attachment). Any hint for me??

HA_GoSunGrow

Paraphraser commented 1 year ago

Well, I don't know if this will help but, when I did all this shortly after my SG5.0RS was installed last Feb, I'm pretty sure I just followed the README.

For me, the tricky bit came after establishing basic connectivity, figuring out which metrics I actually wanted to extract every day.

To make sure the basic setup still works "as documented" (well, for me, at least), I just did the following.


Move the existing GoSungrow configuration out of the way so I'm starting from a clean slate.

$ cd
$ mv .GoSungrow .GoSungrow.off

Initialise a new configuration. If I remember correctly, the email address and password were set up as part of getting the iPad app going and connected to the inverter.

$ GoSungrow config write --user=my.email@my.domain.com --password=mypassword
Using config file '~/.GoSungrow/config.json'
New config:
+-----------------+------------+-------------------------+--------------------------------+-----------------------------------+
|      FLAG       | SHORT FLAG |       ENVIRONMENT       |          DESCRIPTION           |        VALUE (* = DEFAULT)        |
+-----------------+------------+-------------------------+--------------------------------+-----------------------------------+
| --config        |            | GOSUNGROW_CONFIG        | GoSungrow: config file.        | ~/.GoSungrow/config.json   |
| --debug         |            | GOSUNGROW_DEBUG         | GoSungrow: Debug mode.         | false *                           |
| --quiet         |            | GOSUNGROW_QUIET         | GoSungrow: Silence all         | false *                           |
|                 |            |                         | messages.                      |                                   |
| --timeout       |            | GOSUNGROW_TIMEOUT       | Web timeout.                   | 30s *                             |
| --user          | -u         | GOSUNGROW_USER          | SunGrow: api username.         | my.email@my.domain.com             |
| --password      | -p         | GOSUNGROW_PASSWORD      | SunGrow: api password.         | mypassword                |
| --appkey        |            | GOSUNGROW_APPKEY        | SunGrow: api application key.  | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA  |
|                 |            |                         |                                | *                                 |
| --host          |            | GOSUNGROW_HOST          | SunGrow: Provider API URL.     | https://augateway.isolarcloud.com |
|                 |            |                         |                                | *                                 |
| --token-expiry  |            | GOSUNGROW_TOKEN_EXPIRY  | SunGrow: last login.           |  *                                |
| --save          | -s         | GOSUNGROW_SAVE          | Save output as a file.         | false *                           |
| --mqtt-user     |            | GOSUNGROW_MQTT_USER     | HASSIO: mqtt username.         |  *                                |
| --mqtt-password |            | GOSUNGROW_MQTT_PASSWORD | HASSIO: mqtt password.         |  *                                |
| --mqtt-host     |            | GOSUNGROW_MQTT_HOST     | HASSIO: mqtt host.             |  *                                |
| --mqtt-port     |            | GOSUNGROW_MQTT_PORT     | HASSIO: mqtt port.             |  *                                |
+-----------------+------------+-------------------------+--------------------------------+-----------------------------------+

Trigger a login.

$ GoSungrow api login
Email:  my.email@my.domain.com
Create Date:    Thu Feb 09 13:14:55 CST 2023
Login Last Date:    2023-06-08 10:24:05
Login Last IP:  
Login State:    1
User Account:   xxxxxxxxxx
User Id:    999999
User Name:  myname
Is Online:  false
Token:  123456_123456789abcdef123456789abcedf00
Token File: ~/.GoSungrow/AppService_login.json

Show my devices.

$ GoSungrow show ps list
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Ps Key           ┃ Ps Id   ┃ Device Type ┃ Device Code ┃ Channel Id ┃ Serial #    ┃ Factory Name ┃ Device Model   ┃
┣━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┫
┃ 9999999_1_1_1    │ 9999999 │ 1           │ 1           │ 1          │ B9999999999 │ SUNGROW      │ SG5.0RS        ┃
┃ 9999999_22_247_1 │ 9999999 │ 22          │ 247         │ 1          │ B9999999999 │ SUNGROW      │ WiNet-S        ┃
┃ 9999999_7_1_1    │ 9999999 │ 7           │ 1           │ 1          │ B9999999999 │ SUNGROW      │ SG Smart Meter ┃
┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┛

My PS ID is 9999999 (well, it isn't, I did a global search and replace on a lot of this to protect the innocent, as it were, but you get the general idea).

Anyway, starting from scratch still works "as documented", at least for me.


Now, I don't use Home Assistant so I can't help with that side of things.

As to your screen shot, I have a couple of observations. First, as a general rule, running as "root" is not a good idea. I don't say that lightly or flippantly. I've lost count of the number of times over my career that problems have been traced to someone doing things as root that would be better done as a garden-variety user.

I don't believe root/non-root is implicated here but … it just makes me twitchy.

The fact that your command prompt is $ (usually means non-root) rather than # (usually means root) adds to my unease.

Second, in the context of the output of the pwd command, the command:

./bin/GoSungrow

means:

/root/bin/GoSungrow

so the GoSungrow executable should be installed in the directory /root/bin, and that will need to be created if it does not exist. Something like this:

$ mkdir -p /root/bin
$ cd /root/bin
$ wget -q https://github.com/MickMake/GoSungrow/releases/download/v3.0.4/GoSungrow-linux_arm64.tar.gz
$ tar -xzf GoSungrow-linux_arm64.tar.gz
$ rm GoSungrow-linux_arm64.tar.gz
$ cd ..
$ ./bin/GoSungrow config write --user=YOUR-EMAIL-ADDRESS --password=YOUR-PASSWORD
$ ./bin/GoSungrow api login
$ ./bin/GoSungrow show ps list

You'll need to replace the GoSungrow-linux_arm64 with the correct architecture for your system. In words:

  1. Create the bin directory if it does not exist.
  2. Change into the bin directory.
  3. Download the distribution from GitHub.
  4. Unpack the compressed archive into the current directory (ie bin).
  5. Remove the distribution.
  6. Change into the parent directory (ie /root).
  7. Run the command to create the configuration.
  8. Trigger an API login.
  9. Fetch the PS list and make a note of your ID.

I hope all this helps you get started. My experience with GoSungrow is that it hasn't missed a beat since I got it to do what I wanted. That's a daily cron job to pull down "yesterday's" data for the 12 metrics I'm actually interested in.

hboltz commented 1 year ago

Thanks a lot for this hints! But unfortunately I can't see the .GoSungrow directory from the first point of your explanation.

image

Also the directory which was mentioned in the log of the Addon, is not visible for me:

s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [06:37:07] INFO: Setting up GoSungrow config ... [06:37:08] INFO: Writing GoSungrow config ... New config: Using config file '/data/.GoSungrow/config.json'

I cannot find the config.json file! But I think that's not the real problem. I can't issue any of the Golang commands in my terminal of HA. So I am not able to get my PS ID.

Paraphraser commented 1 year ago

What system (hardware, OS, etc) are you using? I've never seen that pattern before where everything is symlinked out of root's home directory. This is what I see on a Raspberry Pi:

image

A fair bit of that would likely be the result of an unintended side effect of sudo. Still, no symlinks!

However, your output says the .GoSungrow directory is in the /data directory, rather than in /root. Are you saying it isn't there when you go looking in /data?

But let's rule a line under all that. You said your goal is to discover your PSID. Let's assume, for the sake of argument, that there is some inherent problem on this HA system you're using that will never let you get any further trying to run GoSungrow from the command line.

I've run GoSungrow, successfully, as a non-root user, on both macOS and Raspberry Pi OS, and in each case as both a compile-from-scratch and a download of precompiled binaries from this repo. It has always worked as documented.

Perhaps consider trying a different system - Windows (which I don't have so I can't test) or macOS? If you are running HA as an "appliance" on a Raspberry Pi, you could always just build a standard Raspbian system on another SD/SSD. Or if you're on a ProxMox system, spin up a one-off VE. Anything to get past this roadblock. If all you need to get HA going is your PSID then that should do it. Other than that I really don't know what to suggest.

hboltz commented 1 year ago

However, your output says the .GoSungrow directory is in the /data directory, rather than in /root. Are you saying it isn't there when you go looking in /data?

That's right! Her is the content of /data:

image

And you're right - I am running HA as an appliance in a VM under Proxmox. I'll try to install the GoSungrow on my MAC. Maybe there's a possibility to get the PS ID......

Paraphraser commented 1 year ago

That's weird. It's almost as if, even though whoami says you're root, you're not actually root, so, while you can list /data because of the group+world "x", you don't have write permissions so .GoSungrow doesn't actually get created.

I reckon you'll have a lot more luck on the Mac.

hboltz commented 1 year ago

Good News today: I setup a Ubuntu VM on my Proxmox and within this, I could issue all GoSungrow commands. So now I have my PS ID!! Is anyone aware how to proceed with the graphical part of the installation of the GoSungrow Addon in Home Assistant? Any help is welcome.

hboltz commented 1 year ago

See above