Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 'er_invalid_appkey' / 'Request is not encrypted' #101

Open
rob3r7 opened this issue Nov 30, 2023 · 211 comments
Open

Error 'er_invalid_appkey' / 'Request is not encrypted' #101

rob3r7 opened this issue Nov 30, 2023 · 211 comments

Comments

@rob3r7
Copy link

rob3r7 commented Nov 30, 2023

Since tonight I get with https://gateway.isolarcloud.eu in HA the following error:

ERROR: appkey is incorrect 'er_invalid_appkey

Checking with https://portaleu.isolarcloud.com/ I realized that the appkey could have changed to B0455FBE7AA0328DB57B59AA729F05D8 (at least I find this key when searching for the term appkey) .

When doing a direct request at /v1/userService/login at least I don't get any more an invalid_appkey error but now an Request is not encrypted error.

When looking at the source of https://portaleu.isolarcloud.com/#/dashboard there is the following function:

e.data.set("appkey", a.a.encryptHex(e.data.get("appkey"), h))

Did Sungrow changed the API access? How to deal with this change?

@BTDrink
Copy link

BTDrink commented Nov 30, 2023

It seems that the entire payload is encrypted:

e.data = a.a.encryptHex(JSON.stringify(e.data), h))
with a new encryption key per request ex.: "webDK6Xl15mzc2RW"

I think they are using the standard CryptoJS
CryptoJS.AES.encrypt("Message", "Secret Passphrase").ciphertext

as seen in their source:
encryptHex: function(e, t) { return i(e, t).ciphertext.toString() }

@jarg
Copy link

jarg commented Nov 30, 2023

Hi, same problem.

[09:36:41] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ... Error: appkey is incorrect 'er_invalid_appkey' Usage: GoSungrow api login [flags]

The key not change:
93D72E60331ABDCDC7B39ADC2D1F32B3

| --appkey          |            | GOSUNGROW_APPKEY          | SunGrow: api application key.  | 93D72E60331ABDCDC7B39ADC2D1F32B3 |
|                   |            |                           |                                | *                                |
| --host            |            | GOSUNGROW_HOST            | SunGrow: Provider API URL.     | https://gateway.isolarcloud.eu  

Regards

@Bartleby1980
Copy link

I have the same Problem.

[13:45:06] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ...
Error: appkey is incorrect 'er_invalid_appkey'

| --appkey | | GOSUNGROW_APPKEY | SunGrow: api application key. | 93D72E60331ABDCDC7B39ADC2D1F32B3

ERROR: appkey is incorrect 'er_invalid_appkey'
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

@jangoetz
Copy link

Hallo,
same problem, with the same error messages...

@monojk
Copy link

monojk commented Nov 30, 2023

Same problem

@julianjwong
Copy link

Same problem with the Australian server as well. I did upgrade my firmware and noticed I got a Session Expired error in the app which forced me to log in again

@Techfluent-au
Copy link

Same here, issue appears to start last week

https://augateway.isolarcloud.eu/

[3.0.7] - 2023-09-04

Tried

init: false
Init: true
hassio_role: default
host_pid: true

@Crisse771
Copy link

Crisse771 commented Nov 30, 2023

Hi,

I have the same Problem.

[20:55:36] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ...
Error: appkey is incorrect 'er_invalid_appkey'
Usage:
GoSungrow api login [flags]

Examples:
GoSungrow api login

Flags: Use "GoSungrow help flags" for more info.

Additional help topics:

ERROR: appkey is incorrect 'er_invalid_appkey'
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

It also says:
| --token-expiry | | GOSUNGROW_TOKEN_EXPIRY | SunGrow: last login. | 2023-11-19T16:14:03

@arekmic
Copy link

arekmic commented Nov 30, 2023

same problem, the same error

@rob3r7
Copy link
Author

rob3r7 commented Nov 30, 2023

As @BTDrink mentioned the payload is encrypted. The session_key (ie. "webDK6Xl15mzc2RW") is generated on client side. It is then encrypted with public key (rsaEncryption (PKCS 1)) and send in the header:

var _ = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNA ...."

var h = e.randomKey;
return c.a.isUndefinedOrNull(h) || (e.headers["x-random-secret-key"] = v.a.sgEncrypt(h, _),

@roabyd
Copy link

roabyd commented Nov 30, 2023

Same issue, following for a fix

@threepoints85
Copy link

Same Problem here

@Razor094
Copy link

Razor094 commented Dec 1, 2023

Same problme here - appkex 93D72E60331ABDCDC7B39ADC2D1F32B3 is used

[07:02:06] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ...
Error: appkey is incorrect 'er_invalid_appkey'
Usage:
GoSungrow api login [flags]

Examples:
GoSungrow api login

@kilador
Copy link

kilador commented Dec 1, 2023

same here

@lupus78
Copy link

lupus78 commented Dec 1, 2023

Same here.
I digged into the web interface's source code, and found they use an other key, which is called WebAppKey in the current repo here:

WebAppKey = "B0455FBE7AA0328DB57B59AA729F05D8"

If I use this appkey "B0455FBE7AA0328DB57B59AA729F05D8" than I get an other error... about encryption. They probably changed the encryption method.

./GoSungrow api login
Error: unknown error 'Request is not encrypted'
Usage:
  GoSungrow api login [flags]

Examples:
	GoSungrow api login  


Flags: Use "GoSungrow help flags" for more info.

Additional help topics:

ERROR: unknown error 'Request is not encrypted'

@metawops
Copy link

metawops commented Dec 1, 2023

same problem here. Hoping for a fix ... 😳 @MickMake

@rapptor7
Copy link

rapptor7 commented Dec 1, 2023

same problem, waiting for the correction.. thx

@0SkillAllLuck
Copy link

0SkillAllLuck commented Dec 1, 2023

Body is encrypted using the randomKey and standard AES in ECB mode with PKCS7 padding. Decryption is done using the same key and parameters.

The x-random-secret-key is the randomKey encrypted using the secretKey (app and web seem to have different keys) with RSA and pkcs1.
The secretKey seems to be related to x-access-key as changing one will break the encryption.

The randomKey is random generated by using a prefix (web or and) based on if you are using web or the android app. Guessing that ios would be ios but can't verify that atm.

Hope that helps bringing the project back to working.

Got the functions done in NodeJS but not in Go at this time:

import * as CryptoJS from "crypto-js";
import NodeRSA from "node-rsa";

export function randomKey() {
  return "and" + randomString(13);
}

export function encryptAES<T>(data: T, key: string): string {
  const d = CryptoJS.enc.Utf8.parse(JSON.stringify(data));
  const k = CryptoJS.enc.Utf8.parse(key);
  return CryptoJS.AES.encrypt(d, k, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7,
  })
    .ciphertext.toString()
    .toUpperCase();
}

export function decryptAES<T>(data: string, key: string): T {
  const d = CryptoJS.format.Hex.parse(data);
  const k = CryptoJS.enc.Utf8.parse(key);
  const dec = CryptoJS.AES.decrypt(d, k, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7,
  });
  return JSON.parse(CryptoJS.enc.Utf8.stringify(dec)) as T;
}

export function encryptRSA(publicKey: string, value: string): string {
  const key = new NodeRSA();
  key.setOptions({ encryptionScheme: "pkcs1" });
  key.importKey(publicKey, "pkcs8-public-pem");
  return key.encrypt(value, "base64");
}

@0SkillAllLuck
Copy link

0SkillAllLuck commented Dec 1, 2023

The key values for the app are:

const ACCESS_KEY = "kme8xdq4fp88wps563qd5d57vw6jxrf4"
const APP_KEY = "3A51762ED80A39AD3DF3DB3CE6767884"
const SECRET_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDlcwFJfpjOsy5U6KBpDEC9ZU_sgjD4AQ_Io0MuuGmQq8wdeLoozOdXRlkyZ2GovikSa6IXMkJ25NeChWGwBDTsnXuvZ3JIFqiTNt5eMtb42u2iHumWtv7fsjj17FFknOIIVzUMPBJ3eIb2"

@0SkillAllLuck
Copy link

Additionally there is the x-limit-obj header that needs to be send on all non-login requests. It is constructed by encrypting the user_id with the secretKey using the same RSA method used for the x-random-secret-key header

@triamazikamno
Copy link

It looks like there was an app key that allowed non-encrypted requests, but it's gone now. Some kind of integration got discontinued on their end perhaps?
This is some terrible practice from Sungrow... I guess they want to charge money for integration with their api

@nielstiben
Copy link

nielstiben commented Dec 1, 2023

Keys found for the web interface:

X_ACCESS_KEY = "9grzgbmxdsp3arfmmgq347xjbza4ysps"
SECRET_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkecphb6vgsBx4LJknKKes-eyj7-RKQ3fikF5B67EObZ3t4moFZyMGuuJPiadYdaxvRqtxyblIlVM7omAasROtKRhtgKwwRxo2a6878qBhTgUVlsqugpI_7ZC9RmO2Rpmr8WzDeAapGANfHN5bVr7G7GYGwIrjvyxMrAVit_oM4wIDAQAB'
APP_KEY = 'B0455FBE7AA0328DB57B59AA729F05D8'

@loucksg
Copy link

loucksg commented Dec 2, 2023

is there an easy patch path here? Changing definitely sees the change in error message, happy to test, as I can replicate this, just crawling through their .js tome

@jhillau
Copy link

jhillau commented Dec 2, 2023

Same issue. Following for fix. Please!

@Thibaut1976
Copy link

Same error here, pls explain way around

@sikelo83
Copy link

sikelo83 commented Dec 2, 2023

Hi, Same issue
It would be very generous to fix this issue.
Sorry my Go knowhow is too bad to do it on my own.
Thank you

@stefanknegt
Copy link

Same issue here

@rob3r7
Copy link
Author

rob3r7 commented Dec 2, 2023

Here we go. A first minimal MVP. The api_key_param is updated with each request before encryption.

import json
import random
import string
from base64 import b64decode, b64encode, urlsafe_b64decode
from datetime import datetime

import requests
from Crypto.Cipher import AES, PKCS1_v1_5
from Crypto.PublicKey import RSA
from Crypto.Util.Padding import pad, unpad

def encrypt_hex(data_str, key):
    cipher = AES.new(key.encode("UTF-8"), AES.MODE_ECB)
    date_byte = cipher.encrypt(pad(data_str.encode("UTF-8"), 16))
    return date_byte.hex()

def decrypt_hex(data_hex_str, key):
    cipher = AES.new(key.encode("UTF-8"), AES.MODE_ECB)
    text = unpad(cipher.decrypt(bytes.fromhex(data_hex_str)), 16).decode("UTF-8")
    return json.loads(text)

public_key = RSA.import_key(
    urlsafe_b64decode(
        "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkecphb6vgsBx4LJknKKes-eyj7-RKQ3fikF5B67EObZ3t4moFZyMGuuJPiadYdaxvRqtxyblIlVM7omAasROtKRhtgKwwRxo2a6878qBhTgUVlsqugpI_7ZC9RmO2Rpmr8WzDeAapGANfHN5bVr7G7GYGwIrjvyxMrAVit_oM4wIDAQAB"
    )
)
cipher = PKCS1_v1_5.new(public_key)

def encrypt_RSA(data_str):
    ciphertext = cipher.encrypt(data_str.encode("UTF-8"))
    return b64encode(ciphertext).decode("UTF-8")

def random_word(length):
    characters = string.ascii_lowercase + string.ascii_uppercase + string.digits
    random_word = "".join(random.choice(characters) for _ in range(length))
    return random_word

def get_data(url, data):
    random_key = "web" + random_word(13)
    data["api_key_param"] = {
        "timestamp": int(datetime.now().timestamp() * 1000),
        "nonce": random_word(32),
    }
    data["appkey"] = "B0455FBE7AA0328DB57B59AA729F05D8"
    data_str = json.dumps(data, separators=(",", ":"))
    data_hex = encrypt_hex(data_str, random_key)
    headers = {
        "content-type": "application/json;charset=UTF-8",
        "sys_code": "200",
        "x-access-key": "9grzgbmxdsp3arfmmgq347xjbza4ysps",
    }
    headers["x-random-secret-key"] = encrypt_RSA(random_key)

    response = requests.post(url, data=data_hex, headers=headers)
    return decrypt_hex(response.text, random_key)


token = get_data(
    "https://gateway.isolarcloud.eu/v1/userService/login",
    {
        "user_account": "[email protected]",
        "user_password": "XXXXXXXX",
    },
)["result_data"]["token"]

get_data(
    "https://gateway.isolarcloud.eu/v1/commonService/queryMutiPointDataList",
    {
        "ps_key": "XXXXXXX_14_1_2",
        "points": "p13003",
        "start_time_stamp": "20231108000000",
        "end_time_stamp": "20231109000000",
        "token": token,
    },
)

@0SkillAllLuck: Grüsse nach Bern!

@Pistro
Copy link

Pistro commented Dec 3, 2023

Here is another working Python example of how to use query the new Sungrow API.
Sadly, I forgot to refresh the page while working and didn't see the post of @rob3r7 ...

The scope of the code below is very similar to his contribution, with some extra additions:

  • I have added a call to log in to the portal (this requires a different RSA key)
  • My x-limit-obj adds the RSA encrypted user id, which is required for some calls, as also mentioned by @0SkillAllLuck

You will see that the post method has a isFormData flag. The code associated with that flag being true is reverse engineered based on what I was able to make out of minified Sungrow encryption code. I do not know a call for which the flag should be set to true, so in that particular case there may be some issues...

import base64
import string
import random
from typing import Optional
import time
import json

import requests
from cryptography.hazmat.primitives import serialization, asymmetric, padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend


# TODO: Getting these values directly from the files by the Sungrow API is better than hardcoding them...
LOGIN_RSA_PUBLIC_KEY: asymmetric.rsa.RSAPublicKey = serialization.load_pem_public_key(b"-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJRGV7eyd9peLPOIqFg3oionWqpmrjVik2wyJzWqv8it3yAvo/o4OR40ybrZPHq526k6ngvqHOCNJvhrN7wXNUEIT+PXyLuwfWP04I4EDBS3Bn3LcTMAnGVoIka0f5O6lo3I0YtPWwnyhcQhrHWuTietGC0CNwueI11Juq8NV2nwIDAQAB\n-----END PUBLIC KEY-----")
APP_RSA_PUBLIC_KEY: asymmetric.rsa.RSAPublicKey   = serialization.load_pem_public_key(bytes("-----BEGIN PUBLIC KEY-----\n" + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkecphb6vgsBx4LJknKKes-eyj7-RKQ3fikF5B67EObZ3t4moFZyMGuuJPiadYdaxvRqtxyblIlVM7omAasROtKRhtgKwwRxo2a6878qBhTgUVlsqugpI_7ZC9RmO2Rpmr8WzDeAapGANfHN5bVr7G7GYGwIrjvyxMrAVit_oM4wIDAQAB".replace("-", "+").replace("_", "/") + "\n-----END PUBLIC KEY-----",  'utf8'))
ACCESS_KEY = "9grzgbmxdsp3arfmmgq347xjbza4ysps"
APP_KEY = "B0455FBE7AA0328DB57B59AA729F05D8"

def encrypt_rsa(value: str, key: asymmetric.rsa.RSAPublicKey) -> str:
    # Encrypt the value
    encrypted = key.encrypt(
        value.encode(),
        asymmetric.padding.PKCS1v15(),
    )
    return base64.b64encode(encrypted).decode()

def encrypt_aes(data: str, key: str):
    key_bytes = key.encode('utf-8')
    data_bytes = data.encode('utf-8')

    # Ensure the key is 16 bytes (128 bits)
    if len(key_bytes) != 16:
        raise ValueError("Key must be 16 characters long")

    cipher = Cipher(algorithms.AES(key_bytes), modes.ECB(), backend=default_backend())
    encryptor = cipher.encryptor()
    padder = padding.PKCS7(algorithms.AES.block_size).padder()
    padded_data = padder.update(data_bytes) + padder.finalize()
    encrypted_data = encryptor.update(padded_data) + encryptor.finalize()
    return encrypted_data.hex()

def decrypt_aes(data: str, key: str):
    key_bytes = key.encode('utf-8')

    # Ensure the key is 16 bytes (128 bits)
    if len(key_bytes) != 16:
        raise ValueError("Key must be 16 characters long")

    encrypted_data = bytes.fromhex(data)
    cipher = Cipher(algorithms.AES(key_bytes), modes.ECB(), backend=default_backend())
    decryptor = cipher.decryptor()
    decrypted_padded_data = decryptor.update(encrypted_data) + decryptor.finalize()
    unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
    decrypted_data = unpadder.update(decrypted_padded_data) + unpadder.finalize()
    return decrypted_data.decode('utf-8')

def generate_random_word(length: int):
    char_pool = string.ascii_letters + string.digits
    random_word = ''.join(random.choice(char_pool) for _ in range(length))
    return random_word

class SungrowScraper:
    def __init__(self, username: str, password: str):
        self.baseUrl = "https://www.isolarcloud.com"
        # TODO: Set the gateway during the login procedure
        self.gatewayUrl = "https://gateway.isolarcloud.eu"
        self.username = username
        self.password = password
        self.session: "requests.Session" = requests.session()
        self.userToken: "str|None" = None

    def login(self):
        self.session = requests.session()
        resp = self.session.post(
            f"{self.baseUrl}/userLoginAction_login",
            data={
                "userAcct": self.username,
                "userPswd": encrypt_rsa(self.password, LOGIN_RSA_PUBLIC_KEY),
            },
            headers={
                "_isMd5": "1"
            },
            timeout=60,
        )
        self.userToken = resp.json()["user_token"]
        return self.userToken

    def post(self, relativeUrl: str, jsn: "Optional[dict]"=None, isFormData=False):
        userToken = self.userToken if self.userToken is not None else self.login()
        jsn = dict(jsn) if jsn is not None else {}
        nonce = generate_random_word(32)
        # TODO: Sungrow also adjusts for time difference between server and client
        # This is probably not a must though. The relevant call is:
        # https://gateway.isolarcloud.eu/v1/timestamp
        unixTimeMs = int(time.time() * 1000)
        jsn["api_key_param"] = {"timestamp": unixTimeMs, "nonce": nonce}
        randomKey = "web" + generate_random_word(13)
        userToken = self.userToken
        userId = userToken.split('_')[0]
        jsn["appkey"] = APP_KEY
        if "token" not in jsn:
            jsn["token"] = userToken
        jsn["sys_code"] = 200
        data: "dict|str"
        if isFormData:
            jsn["api_key_param"] = encrypt_aes(json.dumps(jsn["api_key_param"]), randomKey)
            jsn["appkey"] = encrypt_aes(jsn["appkey"], randomKey)
            jsn["token"] = encrypt_aes(jsn["token"], randomKey)
            data = jsn
        else:
            data = encrypt_aes(json.dumps(jsn, separators=(",", ":")), randomKey)
        resp = self.session.post(
            f"{self.gatewayUrl}{relativeUrl}",
            data=data,
            headers={
                "x-access-key": ACCESS_KEY,
                "x-random-secret-key": encrypt_rsa(randomKey, APP_RSA_PUBLIC_KEY),
                "x-limit-obj": encrypt_rsa(userId, APP_RSA_PUBLIC_KEY),
                "content-type": "application/json;charset=UTF-8"
            }
        )
        return decrypt_aes(resp.text, randomKey)

s = SungrowScraper("MY_USERNAME", "MY_PASSWORD")
resp = s.post(
    "/v1/powerStationService/getPsListNova",
    jsn={
        "share_type_list": ["0", "1", "2"]
    }
)
print(resp)

@grechi-diego
Copy link

grechi-diego commented Apr 23, 2024 via email

@grechi-diego
Copy link

grechi-diego commented Apr 23, 2024 via email

@howi303
Copy link

howi303 commented Apr 30, 2024

Hello @ALL !

use GoSungrow config write --appkey ANDROIDE13EC118BD7892FE7AB5A3F20 and it works ;-)

Greetings :)

@Sn0w3y where do I run this?

@Sn0w3y
Copy link

Sn0w3y commented Apr 30, 2024

Hello @ALL !
use GoSungrow config write --appkey ANDROIDE13EC118BD7892FE7AB5A3F20 and it works ;-)
Greetings :)

@Sn0w3y where do I run this?

Read the Instructions...

@Paraphraser
Copy link

Look, to be honest, I think recommending:

  • ANDROIDE13EC118BD7892FE7AB5A3F20

rather than:

  • B0455FBE7AA0328DB57B59AA729F05D8

might be bordering on bad advice. Please see the tests below.

If anyone is actually using the ANDROID key in a working system, can you please post additional details. In particular, which gateway you are using? I'm using augateway.isolarcloud.com. That's the only thing I can think of where a different API Key might be needed so it would be useful if we could try to figure that out.

Test using the "ANDROID" key - fails

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
[14:00:09] INFO: Setting up GoSungrow config ...
[14:00:10] INFO: Writing GoSungrow config ...
Using config file '/data/.GoSungrow/config.json'
New config:
+-------------------+------------+---------------------------+--------------------------------+-----------------------------------+
|       FLAG        | SHORT FLAG |        ENVIRONMENT        |          DESCRIPTION           |        VALUE (* = DEFAULT)        |
+-------------------+------------+---------------------------+--------------------------------+-----------------------------------+
| --config          |            | GOSUNGROW_CONFIG          | GoSungrow: config file.        | /data/.GoSungrow/config.json      |
| --debug           |            | GOSUNGROW_DEBUG           | GoSungrow: Debug mode.         | true                              |
| --quiet           |            | GOSUNGROW_QUIET           | GoSungrow: Silence all         | false *                           |
|                   |            |                           | messages.                      |                                   |
| --timeout         |            | GOSUNGROW_TIMEOUT         | Web timeout.                   | 1m0s                              |
| --user            | -u         | GOSUNGROW_USER            | SunGrow: api username.         | aabbccddee                        |
| --password        | -p         | GOSUNGROW_PASSWORD        | SunGrow: api password.         | secrets                |
| --appkey          |            | GOSUNGROW_APPKEY          | SunGrow: api application key.  | ANDROIDE13EC118BD7892FE7AB5A3F20  |
| --host            |            | GOSUNGROW_HOST            | SunGrow: Provider API URL.     | https://augateway.isolarcloud.com |
|                   |            |                           |                                | *                                 |
| --token-expiry    |            | GOSUNGROW_TOKEN_EXPIRY    | SunGrow: last login.           | 2024-04-23T15:18:30               |
| --save            | -s         | GOSUNGROW_SAVE            | Save output as a file.         | false *                           |
| --dir             |            | GOSUNGROW_DIR             | Save output base directory.    |  *                                |
| --mqtt-user       |            | GOSUNGROW_MQTT_USER       | HASSIO: mqtt username.         | moi                             |
| --mqtt-password   |            | GOSUNGROW_MQTT_PASSWORD   | HASSIO: mqtt password.         | secrets                           |
| --mqtt-host       |            | GOSUNGROW_MQTT_HOST       | HASSIO: mqtt host.             | core-mosquitto                    |
| --mqtt-port       |            | GOSUNGROW_MQTT_PORT       | HASSIO: mqtt port.             |                              1883 |
| --modbus-user     |            | GOSUNGROW_MODBUS_USER     | Modbus username.               |  *                                |
| --modbus-password |            | GOSUNGROW_MODBUS_PASSWORD | Modbus password.               |  *                                |
| --modbus-host     |            | GOSUNGROW_MODBUS_HOST     | Modbus host.                   |  *                                |
| --modbus-port     |            | GOSUNGROW_MODBUS_PORT     | Modbus port.                   | 502 *                             |
+-------------------+------------+---------------------------+--------------------------------+-----------------------------------+
[14:00:10] INFO: Login to iSolarCloud using gateway https://augateway.isolarcloud.com ...
Error: unknown error 'E914'
Usage:
  GoSungrow api login [flags]

Examples:
	GoSungrow api login  


Flags: Use "GoSungrow help flags" for more info.

Additional help topics:

ERROR: unknown error 'E914'
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

Test using the "B0455" key - succeeds

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
[14:01:28] INFO: Setting up GoSungrow config ...
[14:01:28] INFO: Writing GoSungrow config ...
Using config file '/data/.GoSungrow/config.json'
New config:
+-------------------+------------+---------------------------+--------------------------------+-----------------------------------+
|       FLAG        | SHORT FLAG |        ENVIRONMENT        |          DESCRIPTION           |        VALUE (* = DEFAULT)        |
+-------------------+------------+---------------------------+--------------------------------+-----------------------------------+
| --config          |            | GOSUNGROW_CONFIG          | GoSungrow: config file.        | /data/.GoSungrow/config.json      |
| --debug           |            | GOSUNGROW_DEBUG           | GoSungrow: Debug mode.         | true                              |
| --quiet           |            | GOSUNGROW_QUIET           | GoSungrow: Silence all         | false *                           |
|                   |            |                           | messages.                      |                                   |
| --timeout         |            | GOSUNGROW_TIMEOUT         | Web timeout.                   | 1m0s                              |
| --user            | -u         | GOSUNGROW_USER            | SunGrow: api username.         | aabbccddee                        |
| --password        | -p         | GOSUNGROW_PASSWORD        | SunGrow: api password.         | secrets                |
| --appkey          |            | GOSUNGROW_APPKEY          | SunGrow: api application key.  | B0455FBE7AA0328DB57B59AA729F05D8  |
| --host            |            | GOSUNGROW_HOST            | SunGrow: Provider API URL.     | https://augateway.isolarcloud.com |
|                   |            |                           |                                | *                                 |
| --token-expiry    |            | GOSUNGROW_TOKEN_EXPIRY    | SunGrow: last login.           | 2024-04-23T15:18:30               |
| --save            | -s         | GOSUNGROW_SAVE            | Save output as a file.         | false *                           |
| --dir             |            | GOSUNGROW_DIR             | Save output base directory.    |  *                                |
| --mqtt-user       |            | GOSUNGROW_MQTT_USER       | HASSIO: mqtt username.         | moi                             |
| --mqtt-password   |            | GOSUNGROW_MQTT_PASSWORD   | HASSIO: mqtt password.         | secrets                           |
| --mqtt-host       |            | GOSUNGROW_MQTT_HOST       | HASSIO: mqtt host.             | core-mosquitto                    |
| --mqtt-port       |            | GOSUNGROW_MQTT_PORT       | HASSIO: mqtt port.             |                              1883 |
| --modbus-user     |            | GOSUNGROW_MODBUS_USER     | Modbus username.               |  *                                |
| --modbus-password |            | GOSUNGROW_MODBUS_PASSWORD | Modbus password.               |  *                                |
| --modbus-host     |            | GOSUNGROW_MODBUS_HOST     | Modbus host.                   |  *                                |
| --modbus-port     |            | GOSUNGROW_MODBUS_PORT     | Modbus port.                   | 502 *                             |
+-------------------+------------+---------------------------+--------------------------------+-----------------------------------+
[14:01:28] INFO: Login to iSolarCloud using gateway https://augateway.isolarcloud.com ...
Email:	[email protected]
Create Date:	Thu Feb 09 13:14:55 CST 2023
Login Last Date:	2024-04-30 22:01:28
Login Last IP:	
Login State:	1
User Account:	aabbccddee
User Id:	374058
User Name:	Moi
Is Online:	false
Token:	374058_a4507409d7f24dedaaaa54f53a1f0848
Token File:	/data/.GoSungrow/AppService_login.json
Email:	[email protected]
Create Date:	Thu Feb 09 13:14:55 CST 2023
Login Last Date:	2024-04-30 22:01:29
Login Last IP:	
Login State:	1
User Account:	aabbccddee
User Id:	374058
User Name:	Moi
Is Online:	false
Token:	374058_f1e86ada8dbf40f7844d2345dc37d410
Token File:	/data/.GoSungrow/AppService_login.json
[14:01:29] INFO: Syncing data from gateway https://augateway.isolarcloud.com ...
Email:	[email protected]
Create Date:	Thu Feb 09 13:14:55 CST 2023
Login Last Date:	2024-04-30 22:01:29
Login Last IP:	
2024/04/30 14:01:29 INFO: Connecting to MQTT HASSIO Service...
2024/04/30 14:01:29 INFO: Connecting to SunGrow...
Login State:	1
User Account:	aabbccddee
User Id:	374058
User Name:	Moi
Is Online:	false
Token:	374058_f1e86ada8dbf40f7844d2345dc37d410
Token File:	/data/.GoSungrow/AppService_login.json
2024/04/30 14:01:29 INFO: Found SunGrow 3 devices
2024/04/30 14:01:29 INFO: Caching Sungrow metadata...
2024/04/30 14:01:29 INFO: Cached 975 Sungrow data points...
2024/04/30 14:01:29 INFO: Syncing 461 entries with HASSIO from queryDeviceList.
CU-CUCU-CUCUCUCUCUCU-CUCU-CU-CUCU----CUCUCU-----CU-CU-CU-CUCU
2024/04/30 14:01:30 INFO: Syncing 148 entries with HASSIO from getPsList.
CUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCU?CUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU
2024/04/30 14:01:30 INFO: Syncing 205 entries with HASSIO from getPsDetail.
2024/04/30 14:01:30 INFO: Starting ticker...
2024/04/30 14:01:30 INFO: Fetch Schedule: 5m
2024/04/30 14:01:30 INFO: Sleep Delay:    40s
CUCU??CUCUCUCUCUCUCUCU?CUCU?CU?CUCUCUCU?CUCUCU?CUCU?CUCU?CUCUCU?CUCU?CUCUCU??CUCUCU?CU?CUCUCU?CUCUCUCUCUCU??CU?CUCUCUCUCUCUCUCUCUCUCU?CUCUCU??CU?CU?CUCU?CUCUCU?CUCUCU?CUCUCUCU???CUCUCUCUCU?CUCUCU?CUCUCUCU?CUCUCUCU?CUCUCUCUCUCUCUCU?CUCUCUCU?CUCUCUCUCU?CU?CU????CUCU?CUCU?CUCUCUCUCUCUCUCUCUCUCU?CUCU??CU??CU?CUCUCU?CUCUCUCUCU??CUCUCUCUCUCUCUCUCUCUCUCU??CUCU

@Paraphraser
Copy link

@howi303 - see if this helps (the config write command is used when you run GoSungrow from the command line rather than in Home Assistant).

APIKey

@mattiassjogren
Copy link

I got the "unknown error 'Request is not encrypted'" earlier today. I was using the B0455* appkey and switched to the ANDROID* appkey and GoSungrow works again! I'm on the gateway.isolarcloud.eu host.

[19:22:10] INFO: Setting up GoSungrow config ...
[19:22:12] INFO: Writing GoSungrow config ...
Using config file '/data/.GoSungrow/config.json'
New config:
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
|       FLAG        | SHORT FLAG |        ENVIRONMENT        |          DESCRIPTION           |       VALUE (* = DEFAULT)        |
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
| --config          |            | GOSUNGROW_CONFIG          | GoSungrow: config file.        | /data/.GoSungrow/config.json     |
| --debug           |            | GOSUNGROW_DEBUG           | GoSungrow: Debug mode.         | false *                          |
| --quiet           |            | GOSUNGROW_QUIET           | GoSungrow: Silence all         | false *                          |
|                   |            |                           | messages.                      |                                  |
| --timeout         |            | GOSUNGROW_TIMEOUT         | Web timeout.                   | 1m0s                             |
| --user            | -u         | GOSUNGROW_USER            | SunGrow: api username.         | XXXXXXX                          |
| --password        | -p         | GOSUNGROW_PASSWORD        | SunGrow: api password.         | XXXXXXX                          |
| --appkey          |            | GOSUNGROW_APPKEY          | SunGrow: api application key.  | ANDROIDE13EC118BD7892FE7AB5A3F20 |
| --host            |            | GOSUNGROW_HOST            | SunGrow: Provider API URL.     | https://gateway.isolarcloud.eu   |
| --token-expiry    |            | GOSUNGROW_TOKEN_EXPIRY    | SunGrow: last login.           | 2024-04-13T04:23:09              |
| --save            | -s         | GOSUNGROW_SAVE            | Save output as a file.         | false *                          |
| --dir             |            | GOSUNGROW_DIR             | Save output base directory.    |  *                               |
| --mqtt-user       |            | GOSUNGROW_MQTT_USER       | HASSIO: mqtt username.         | XXXXXXX                          |
| --mqtt-password   |            | GOSUNGROW_MQTT_PASSWORD   | HASSIO: mqtt password.         | XXXXXXX                          |
| --mqtt-host       |            | GOSUNGROW_MQTT_HOST       | HASSIO: mqtt host.             | core-mosquitto                   |
| --mqtt-port       |            | GOSUNGROW_MQTT_PORT       | HASSIO: mqtt port.             |                             1883 |
| --modbus-user     |            | GOSUNGROW_MODBUS_USER     | Modbus username.               |  *                               |
| --modbus-password |            | GOSUNGROW_MODBUS_PASSWORD | Modbus password.               |  *                               |
| --modbus-host     |            | GOSUNGROW_MODBUS_HOST     | Modbus host.                   |  *                               |
| --modbus-port     |            | GOSUNGROW_MODBUS_PORT     | Modbus port.                   | 502 *                            |
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
[19:22:12] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ...
Email:	[email protected]
Create Date:	Tue Nov 07 18:08:40 CST 2023
Login Last Date:	2024-05-01 03:22:13
Login Last IP:	
Login State:	1
User Account:	XXXXXXX
User Id:	XXXXXX
User Name:	XXXXX
Is Online:	false
Token:	359009_9bXXXXXXXXXXXXXXXXXXXXXXX
Token File:	/data/.GoSungrow/AppService_login.json
[19:22:13] INFO: Syncing data from gateway https://gateway.isolarcloud.eu ...
2024/04/30 19:22:13 INFO: Connecting to MQTT HASSIO Service...
2024/04/30 19:22:13 INFO: Connecting to SunGrow...
2024/04/30 19:22:13 INFO: Found SunGrow 2 devices
2024/04/30 19:22:13 INFO: Caching Sungrow metadata...
2024/04/30 19:22:14 INFO: Cached 841 Sungrow data points...
2024/04/30 19:22:15 INFO: Syncing 164 entries with HASSIO from queryDeviceList.
CUCUCUCUCUCU-CUCU-CU--CU-
2024/04/30 19:22:15 INFO: Syncing 155 entries with HASSIO from getPsList.
2024/04/30 19:22:15 INFO: Syncing 212 entries with HASSIO from getPsDetail.
CU?CUCUCUCUCU???CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU
CU?CUCU??CUCUCUCUCU?CUCUCUCUCU?CU?CUCUCUCUCU?CUCUCUCU?CUCU?CUCUCUCU?CUCUCUCUCU?????CUCU??CU?CUCU?CU???CUCUCUCUCUCU????CUCUCU???CUCUCUCU?CUCUCUCU??CUCUCUCUCUCU?CUCUCUCU?CUCUCUCUCUCUCUCU?CU?CUCUCUCUCU?CU?CU?CU??CU???CUCU?CUCU???CUCUCUCUCUCU?CUCU???CU?CUCUCUCU?CUCUCU?CU?CUCUCUCUCUCUCU??CUCUCU?CU?CUCU?CUCUCUCU?CUCUCU???CUCUCU?CU??CUCUCUCUCUCUCUCUCUCU?CU??
2024/04/30 19:22:15 INFO: Starting ticker...
2024/04/30 19:22:15 INFO: Fetch Schedule: 5m
2024/04/30 19:22:15 INFO: Sleep Delay:    40s

@grechi-diego
Copy link

grechi-diego commented Apr 30, 2024 via email

@Sn0w3y
Copy link

Sn0w3y commented Apr 30, 2024

I got the "unknown error 'Request is not encrypted'" earlier today. I was using the B0455* appkey and switched to the ANDROID* appkey and GoSungrow works again! I'm on the gateway.isolarcloud.eu host.

[19:22:10] INFO: Setting up GoSungrow config ...
[19:22:12] INFO: Writing GoSungrow config ...
Using config file '/data/.GoSungrow/config.json'
New config:
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
|       FLAG        | SHORT FLAG |        ENVIRONMENT        |          DESCRIPTION           |       VALUE (* = DEFAULT)        |
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
| --config          |            | GOSUNGROW_CONFIG          | GoSungrow: config file.        | /data/.GoSungrow/config.json     |
| --debug           |            | GOSUNGROW_DEBUG           | GoSungrow: Debug mode.         | false *                          |
| --quiet           |            | GOSUNGROW_QUIET           | GoSungrow: Silence all         | false *                          |
|                   |            |                           | messages.                      |                                  |
| --timeout         |            | GOSUNGROW_TIMEOUT         | Web timeout.                   | 1m0s                             |
| --user            | -u         | GOSUNGROW_USER            | SunGrow: api username.         | XXXXXXX                          |
| --password        | -p         | GOSUNGROW_PASSWORD        | SunGrow: api password.         | XXXXXXX                          |
| --appkey          |            | GOSUNGROW_APPKEY          | SunGrow: api application key.  | ANDROIDE13EC118BD7892FE7AB5A3F20 |
| --host            |            | GOSUNGROW_HOST            | SunGrow: Provider API URL.     | https://gateway.isolarcloud.eu   |
| --token-expiry    |            | GOSUNGROW_TOKEN_EXPIRY    | SunGrow: last login.           | 2024-04-13T04:23:09              |
| --save            | -s         | GOSUNGROW_SAVE            | Save output as a file.         | false *                          |
| --dir             |            | GOSUNGROW_DIR             | Save output base directory.    |  *                               |
| --mqtt-user       |            | GOSUNGROW_MQTT_USER       | HASSIO: mqtt username.         | XXXXXXX                          |
| --mqtt-password   |            | GOSUNGROW_MQTT_PASSWORD   | HASSIO: mqtt password.         | XXXXXXX                          |
| --mqtt-host       |            | GOSUNGROW_MQTT_HOST       | HASSIO: mqtt host.             | core-mosquitto                   |
| --mqtt-port       |            | GOSUNGROW_MQTT_PORT       | HASSIO: mqtt port.             |                             1883 |
| --modbus-user     |            | GOSUNGROW_MODBUS_USER     | Modbus username.               |  *                               |
| --modbus-password |            | GOSUNGROW_MODBUS_PASSWORD | Modbus password.               |  *                               |
| --modbus-host     |            | GOSUNGROW_MODBUS_HOST     | Modbus host.                   |  *                               |
| --modbus-port     |            | GOSUNGROW_MODBUS_PORT     | Modbus port.                   | 502 *                            |
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
[19:22:12] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ...
Email:	[email protected]
Create Date:	Tue Nov 07 18:08:40 CST 2023
Login Last Date:	2024-05-01 03:22:13
Login Last IP:	
Login State:	1
User Account:	XXXXXXX
User Id:	XXXXXX
User Name:	XXXXX
Is Online:	false
Token:	359009_9bXXXXXXXXXXXXXXXXXXXXXXX
Token File:	/data/.GoSungrow/AppService_login.json
[19:22:13] INFO: Syncing data from gateway https://gateway.isolarcloud.eu ...
2024/04/30 19:22:13 INFO: Connecting to MQTT HASSIO Service...
2024/04/30 19:22:13 INFO: Connecting to SunGrow...
2024/04/30 19:22:13 INFO: Found SunGrow 2 devices
2024/04/30 19:22:13 INFO: Caching Sungrow metadata...
2024/04/30 19:22:14 INFO: Cached 841 Sungrow data points...
2024/04/30 19:22:15 INFO: Syncing 164 entries with HASSIO from queryDeviceList.
CUCUCUCUCUCU-CUCU-CU--CU-
2024/04/30 19:22:15 INFO: Syncing 155 entries with HASSIO from getPsList.
2024/04/30 19:22:15 INFO: Syncing 212 entries with HASSIO from getPsDetail.
CU?CUCUCUCUCU???CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCU?CUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCUCU
CU?CUCU??CUCUCUCUCU?CUCUCUCUCU?CU?CUCUCUCUCU?CUCUCUCU?CUCU?CUCUCUCU?CUCUCUCUCU?????CUCU??CU?CUCU?CU???CUCUCUCUCUCU????CUCUCU???CUCUCUCU?CUCUCUCU??CUCUCUCUCUCU?CUCUCUCU?CUCUCUCUCUCUCUCU?CU?CUCUCUCUCU?CU?CU?CU??CU???CUCU?CUCU???CUCUCUCUCUCU?CUCU???CU?CUCUCUCU?CUCUCU?CU?CUCUCUCUCUCUCU??CUCUCU?CU?CUCU?CUCUCUCU?CUCUCU???CUCUCU?CU??CUCUCUCUCUCUCUCUCUCU?CU??
2024/04/30 19:22:15 INFO: Starting ticker...
2024/04/30 19:22:15 INFO: Fetch Schedule: 5m
2024/04/30 19:22:15 INFO: Sleep Delay:    40s

sure it works :P i do not know why nobody believes me :D i also have been on eu

@Paraphraser
Copy link

@Sn0w3y I think it's less a question of (dis)believing what you say vs trying the ANDROID key and finding that it doesn't work in your own situation whereas the B0455 key does (touch wood).

Still, thanks to all the responses, the hypothesis that the actual value of the APPKEY might be tied to the iSolarCloud server seems to be gaining traction. I have updated the gist to consolidate everything about iSolarCloud host URLs and APPKEYs, as well as instructions for the three main use-cases (the HA add-on, the standalone binary, and manual editing of a JSON file). The new material is here.

Now, if anyone has anything to add/challenge/critique and, in particular, knows of different iSolarCloud servers and/or APPKeys then please mention it, either by adding to this issue or by making a comment on the gist.

@mark-bloom
Copy link

mark-bloom commented May 2, 2024

I got the "unknown error 'Request is not encrypted'" earlier today. I was using the B0455* appkey and switched to the ANDROID* appkey and GoSungrow works again! I'm on the gateway.isolarcloud.eu host.

Same situation here (except on the https://augateway.isolarcloud.com host). I use the HA add-on, and it was running fine after installing via Paraphraser's patching instructions a few couple months back, no indication in the logs about what sparked the 'Request is not encrypted' to return. Changing to the Android key immediately started working.

@Shaydengy
Copy link

I got the "unknown error 'Request is not encrypted'" earlier today. I was using the B0455* appkey and switched to the ANDROID* appkey and GoSungrow works again! I'm on the gateway.isolarcloud.eu host.

Same situation here (except on the https://augateway.isolarcloud.com host). I use the HA add-on, and it was running fine after installing via Paraphraser's patching instructions a few couple months back, no indication in the logs about what sparked the 'Request is not encrypted' to return. Changing to the Android key immediately started working.

I have had the exact same experience - augateway, B0455* used to work, and it stopped working a few days ago and was fixed by android* key just this morning.

@Paraphraser
Copy link

@Shaydengy so, do you recall doing anything between "when the B0445 key worked" and "when you had to switch to the ANDROID key that might explain this? I'm thinking things like "used to use iOS, just switched to an Android tablet", or "I logged into the web version of iSolarCloud" or anything else that might constitute a trigger event that could conceivably have caused the "cloud" side of things to decide to upgrade you to a new key?

@Shaydengy
Copy link

I can't say with confidence sorry. I'm completely new to HA and having been setting it all up over the last week, so have lost track of events, as you could imagine.

However, I've looked through the sensor historicals - it looks like my gosungrow sensors stopped working at 3:04:22am 30 April. I wouldn't have made any edits after 10pm the night prior, so it doesn't seem to be from anything I've done. Let me know if there's anything further you'd like me to check.

@alexandrechoske
Copy link

Here the ANDROID app_key shows another error:

ERROR: Appkey: empty string

When using any other:

ERROR: appkey is incorrect 'er_invalid_appkey'

@Paraphraser
Copy link

A bit more context might help but, for now, on the assumption you are using Home Assistant, please review gist part 2 and double check that you followed all the steps, including the steps at configuration.

The first error sounds like you didn't have an appkey at all. The second one is either not following all the steps in part 2 or perhaps not trying both appkeys in the configuration section. I'm using the B0455 key while others report needing the ANDROID key. There doesn't seem to be a rule you can follow about which appkey to use so it's wise to try both. But whichever server+appkey combination you need, none of it will work if you haven't followed part 2 correctly.

@alexandrechoske
Copy link

A bit more context might help but, for now, on the assumption you are using Home Assistant, please review gist part 2 and double check that you followed all the steps, including the steps at configuration.

The first error sounds like you didn't have an appkey at all. The second one is either not following all the steps in part 2 or perhaps not trying both appkeys in the configuration section. I'm using the B0455 key while others report needing the ANDROID key. There doesn't seem to be a rule you can follow about which appkey to use so it's wise to try both. But whichever server+appkey combination you need, none of it will work if you haven't followed part 2 correctly.

Thanks man you are a GOD.

image
Now everything seems to work properly, I will have a fun now :)

@rootsid-NRN
Copy link

would be very generous to fix this issue.
Sorry my Go kn

For authentication i am getting below error code:

{ "result_msg":null, "result_data":null, "result_code":"E914" }

are you aware about this

@rootsid-NRN
Copy link

rootsid-NRN commented Jul 16, 2024

th some extra additions:

@Pistro From where did you find LOGIN_RSA_PUBLIC_KEY

@Paraphraser
Copy link

would be very generous to fix this issue.
Sorry my Go kn

The basic issue reported at the point when that comment was written (Dec 2023) has been fixed.

For authentication i am getting below error code:

{ "result_msg":null, "result_data":null, "result_code":"E914" }

are you aware about this

No. As far as I know, this is the first mention of a result code E914. I have no idea what it means.

th some extra additions:

From where did you find APP_RSA_PUBLIC_KEY

No idea. The string APP_RSA_PUBLIC_KEY doesn’t seem to get a mention in the source code in this repository. For example:

$ git grep APP_RSA_PUBLIC_KEY

returns no hits. The only place that string seems to be mentioned is in this issue where it’s part of some code provided by @Pistro but whether that code is original or borrowed/adapted from somewhere else is something I don’t know. I think it became the basis of the fix provided by @triamazikamno but I don’t know that for certain.

However, if you take a snippet from the assignment on the right hand side of that code and do something like:

$ git grep -oH MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkecphb6vgsBx4LJknKKes
docs/data/js/app.884c24c2.js:MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkecphb6vgsBx4LJknKKes
docs/data/js/app.b8da93af.js:MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkecphb6vgsBx4LJknKKes

then you do get hits. But those are buried in the docs folder and would not seem to be all that relevant to the problem at hand.


Now, let me put all that to one side. It’s not at all clear exactly what problem you are facing or how you are trying to run GoSungrow.

GoSungrow can be run:

  1. As an add-on to Home Assistant.
  2. From the command line as a separate binary.
  3. From a Docker container, either mimicking the Home Assistant add-on (a Docker container) or with a different launch command.

You need to explain what you are trying to do.

And, then, if you are seeing errors, you need to provide all of the context. If you whittle it down to just the line you think is the error you make it really hard for anyone to help you. In this situation, less is not more.

To the best of my knowledge, if you:

  1. Read this gist;
  2. Figure out from the initial paragraphs exactly what you are trying to do (labelled as Part 1 through Part 4); and then
  3. Follow all the steps in the part you chose,

then GoSungrow will start working again.

I think the only people who continue to have trouble once they’ve followed the gist are those who have multiple Sungrow inverters on a single account. There seems to be some problem which shows up as an inability of GoSungrow to convert a non-integer string to an integer. Insofar as I’m aware, there’s no fix for that. We will simply have to wait until this site’s maintainer gets back.

@allocater2
Copy link

sungrow may have changed something. I am getting:

[result_msg] => Abnormal network environment
[result_data] =>
[result_code] => E903

@allocater2
Copy link

I went to their website and it said "The system has detected abnormality in your account, for the security of your account, please change your password immediately."

I just confirmed the message and now the API connection works again. 🤷‍♂️

@Moischen
Copy link

Hi,

I'm trying to get it work... I've installed goSunGrow and use de android appkey, I don't see any error about key or encription but i do not get the properly data i think. This is what i've got in the log:

15:59:23] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ...
Email: [email protected]
Create Date: Thu Sep 12 21:03:16 CST 2024
Login Last Date: 2024-09-12 23:59:24
Login Last IP:
Login State: 1
User Account: ef175bzhct
User Id: 543217
User Name:
Is Online: false
Token: 543217_9778ac51265b4087b00866d323e51a1a
Token File: /data/.GoSungrow/AppService_login.json
[15:59:24] INFO: Syncing data from gateway https://gateway.isolarcloud.eu ...
2024/09/12 15:59:24 INFO: Connecting to MQTT HASSIO Service...
2024/09/12 15:59:24 INFO: Connecting to SunGrow...
2024/09/12 15:59:25 INFO: Found SunGrow 0 devices
No results found.
No results found.
CU
2024/09/12 15:59:25 INFO: Caching Sungrow metadata...
2024/09/12 15:59:25 INFO: Cached 0 Sungrow data points...
2024/09/12 15:59:25 INFO: Syncing 1 entries with HASSIO from getPsList.
2024/09/12 15:59:25 INFO: Starting ticker...
2024/09/12 15:59:25 INFO: Fetch Schedule: 5m
2024/09/12 15:59:25 INFO: Sleep Delay: 40s
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
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
[16:00:24] INFO: Setting up GoSungrow config ...
[16:00:25] INFO: Writing GoSungrow config ...
Using config file '/data/.GoSungrow/config.json'
New config:
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
| FLAG | SHORT FLAG | ENVIRONMENT | DESCRIPTION | VALUE (* = DEFAULT) |
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
| --config | | GOSUNGROW_CONFIG | GoSungrow: config file. | /data/.GoSungrow/config.json |
| --debug | | GOSUNGROW_DEBUG | GoSungrow: Debug mode. | false * |
| --quiet | | GOSUNGROW_QUIET | GoSungrow: Silence all | false * |
| | | | messages. | |
| --timeout | | GOSUNGROW_TIMEOUT | Web timeout. | 1m0s |
| --user | -u | GOSUNGROW_USER | SunGrow: api username. | [email protected] |
| --password | -p | GOSUNGROW_PASSWORD | SunGrow: api password. | XXXXXX |
| --appkey | | GOSUNGROW_APPKEY | SunGrow: api application key. | ANDROIDE13EC118BD7892FE7AB5A3F20 |
| --host | | GOSUNGROW_HOST | SunGrow: Provider API URL. | https://gateway.isolarcloud.eu |
| --token-expiry | | GOSUNGROW_TOKEN_EXPIRY | SunGrow: last login. | 2024-09-12T23:59:24 |
| --save | -s | GOSUNGROW_SAVE | Save output as a file. | false * |
| --dir | | GOSUNGROW_DIR | Save output base directory. | * |
| --mqtt-user | | GOSUNGROW_MQTT_USER | HASSIO: mqtt username. | mosquito |
| --mqtt-password | | GOSUNGROW_MQTT_PASSWORD | HASSIO: mqtt password. | mosquito |
| --mqtt-host | | GOSUNGROW_MQTT_HOST | HASSIO: mqtt host. | core-mosquitto |
| --mqtt-port | | GOSUNGROW_MQTT_PORT | HASSIO: mqtt port. | 1883 |
| --modbus-user | | GOSUNGROW_MODBUS_USER | Modbus username. | * |
| --modbus-password | | GOSUNGROW_MODBUS_PASSWORD | Modbus password. | * |
| --modbus-host | | GOSUNGROW_MODBUS_HOST | Modbus host. | * |
| --modbus-port | | GOSUNGROW_MODBUS_PORT | Modbus port. | 502 * |
+-------------------+------------+---------------------------+--------------------------------+----------------------------------+
[16:00:25] INFO: Login to iSolarCloud using gateway https://gateway.isolarcloud.eu ...
Email: [email protected]
Create Date: Thu Sep 12 21:03:16 CST 2024
Login Last Date: 2024-09-13 00:00:25
Login Last IP:
Login State: 1
User Account: ef175bzhct
User Id: 543217
User Name:
Is Online: false
Token: 543217_1a580278ea7c47249625089a94626fc1
Token File: /data/.GoSungrow/AppService_login.json
[16:00:25] INFO: Syncing data from gateway https://gateway.isolarcloud.eu ...
2024/09/12 16:00:25 INFO: Connecting to MQTT HASSIO Service...
2024/09/12 16:00:25 INFO: Connecting to SunGrow...
2024/09/12 16:00:25 INFO: Found SunGrow 0 devices
No results found.
CU
2024/09/12 16:00:25 INFO: Caching Sungrow metadata...
2024/09/12 16:00:25 INFO: Cached 0 Sungrow data points...
2024/09/12 16:00:25 INFO: Syncing 1 entries with HASSIO from getPsList.
2024/09/12 16:00:25 INFO: Starting ticker...
2024/09/12 16:00:25 INFO: Fetch Schedule: 5m
2024/09/12 16:00:25 INFO: Sleep Delay: 40s
No results found.
2024/09/12 16:06:26 INFO: Syncing 1 entries with HASSIO from getPsList.
U
2024/09/12 16:12:16 INFO: Syncing 1 entries with HASSIO from getPsList.
No results found.
U

Any Idea o help???

@allocater2
Copy link

I am getting no results from getPsList. Not sure why, maybe because I don't own any, I just have share access? Maybe you have the same issue? Do I have to send parameters with getPsList? The doc lists nothing: https://github.com/MickMake/GoSungrow/blob/master/iSolarCloud/AppService/getPsList/data.go

My getPsList result is:

[req_serial_num] => 20240914162048f7974b356cc0e1d00b
[result_code] => 1
[result_msg] => success
[result_data] => 

nothing in result_data.

Otherwise every other api call works if I pass the ps_id I got from the website.

@Paraphraser
Copy link

No idea. I just ran a test. The output is below (sanitised to remove account details and paid etc but otherwise exactly what I see).

[marble Sat Sep 14 18:05:28 ~] $ GoSungrow-mac api login
Email:  [email protected]
Create Date:    Thu Feb 09 13:14:55 CST 2023
Login Last Date:        2024-09-14 16:05:41
Login Last IP:  
Login State:    1
User Account:   aabbccddee
User Id:        374058
User Name:      Moi
Is Online:      false
Token:  374058_2a80e443820d4d6e9c326591c3de31a0
Token File:     /Users/moi/.GoSungrow/AppService_login.json
[marble Sat Sep 14 18:05:41 ~] $ GoSungrow-mac 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          │ B2222334445 │ SUNGROW      │ SG5.0RS        ┃
┃ 9999999_7_1_1    │ 9999999 │ 7           │ 1           │ 1          │ B2222334445 │ SUNGROW      │ SG Smart Meter ┃
┃ 9999999_22_247_1 │ 9999999 │ 22          │ 247         │ 1          │ B2222334445 │ SUNGROW      │ WiNet-S        ┃
┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┛

[marble Sat Sep 14 18:05:56 ~] $

"GoSungrow-mac" because I've cross-compiled for other platforms and I want to know which binary I'm looking at.

@chultquist
Copy link

I am getting no results from getPsList. Not sure why, maybe because I don't own any, I just have share access? Maybe you have the same issue? Do I have to send parameters with getPsList? The doc lists nothing: https://github.com/MickMake/GoSungrow/blob/master/iSolarCloud/AppService/getPsList/data.go

My getPsList result is:

[req_serial_num] => 20240914162048f7974b356cc0e1d00b
[result_code] => 1
[result_msg] => success
[result_data] => 

nothing in result_data.

Otherwise every other api call works if I pass the ps_id I got from the website.

@allocater2 I have the same issue - the plant is shared with me and I can't see it in the PsList. Did you figure out how to work around this? If you can also share how you obtained your ps_id from the website that would be helpful.

@munichseb
Copy link

Thank you so much everyone here. I got the ps_id and current production by polling getPsList:

userId = token.split('_')[0]
limitObj = encrypt_rsa(userId, APP_RSA_PUBLIC_KEY),

payload = get_data2(
"https://gateway.isolarcloud.eu/v1/powerStationService/getPsList",
{
"user_id": userId,
"x-access-key": "9grzgbmxdsp3arfmmgq347xjbza4ysps",
"token": token,
}, str(limitObj),
)

The getData also needs to provide the x-limit-obj

def get_data2(url, data, limitObj):
random_key = "web" + random_word(13)
data["api_key_param"] = {
"timestamp": int(datetime.now().timestamp() * 1000),
"nonce": random_word(32),
}
data["appkey"] = "B0455FBE7AA0328DB57B59AA729F05D8"
data_str = json.dumps(data, separators=(",", ":"))
data_hex = encrypt_hex(data_str, random_key)
headers = {
"content-type": "application/json;charset=UTF-8",
"sys_code": "200",
"x-limit-obj": limitObj,
"x-access-key": "9grzgbmxdsp3arfmmgq347xjbza4ysps",
}
headers["x-random-secret-key"] = encrypt_RSA(random_key)
response = requests.post(url, data=data_hex, headers=headers)
return decrypt_hex(response.text, random_key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests