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

Cannot connect #40

Open
jvinkovic opened this issue Jan 19, 2024 · 37 comments
Open

Cannot connect #40

jvinkovic opened this issue Jan 19, 2024 · 37 comments

Comments

@jvinkovic
Copy link
Contributor

image

@z-master42
Copy link

A little more information would be nice. Are the environment variables set correctly?

@jvinkovic
Copy link
Contributor Author

Yes. They are correct.

@z-master42
Copy link

What else is in the log?

@jvinkovic
Copy link
Contributor Author

jvinkovic commented Feb 2, 2024 via email

@z-master42
Copy link

Ok, that's not really helpful.

@dabenzel
Copy link

dabenzel commented Feb 4, 2024

Same Issue here.
Changed my SolarFlow to "Germany" as Region
These env-Configs do not work:

ZEN_MQTT = mqtt.zen-iot.com
ZEN_API = https://app.zendure.tech

or

ZEN_MQTT = mqtt.zen-iot.com
ZEN_API = https://app.zendure.tech/eu

or

ZEN_MQTT = mqtteu.zen-iot.com
ZEN_API = https://app.zendure.tech

Also not providing both ENV-Variables do not work.

Logs:

solarflow-statuspage  | 2024-02-04 12:02:18,767:INFO: Authenticating with Zendure ...
solarflow-statuspage  | 2024-02-04 12:02:20,341:INFO: Getting device list ...
solarflow-statuspage  | 2024-02-04 12:02:20,888:INFO: []
solarflow-statuspage  | 2024-02-04 12:02:20,889:ERROR: Connecting to Zendure's MQTT broker failed!
solarflow-statuspage  | Traceback (most recent call last):
solarflow-statuspage  |   File "//solarflow-status.py", line 295, in zendure_mqtt_background_task
solarflow-statuspage  |     auth = get_auth()
solarflow-statuspage  |   File "//solarflow-status.py", line 288, in get_auth
solarflow-statuspage  |     log.info(f'Zendure Auth: {auth}')
solarflow-statuspage  | NameError: name 'auth' is not defined`

@z-master42
Copy link

Have you re-registered your SolarFlow on the EU server using the curl command?

@dabenzel
Copy link

dabenzel commented Feb 4, 2024

Hi!
Yes, I think:

curl -i -v --json "{'snNumber': 'XXXX', 'account': 'XXXX'}" https://app.zendure.tech/eu/developer/api/apply
<__Removed__>
<
{"code":200,"success":true,"data":{"appKey":"XXXX","secret":"XXXX","mqttUrl":"mqtt.zen-iot.com","port":1883},"msg":"Successful operation"}* Connection #0 to host app.zendure.tech left intact```

@z-master42
Copy link

Does it work if you use the two URLs? The one from your curl command and the one from the answer?

@dabenzel
Copy link

dabenzel commented Feb 4, 2024

You mean like this:

ZEN_MQTT = mqtt.zen-iot.com
ZEN_API = https://app.zendure.tech/eu/developer/api/apply

Nope. Other ways, I showed at my first comment.

How do you use it with EU-Server?

@z-master42
Copy link

I didn't switch because I didn't want to lose the statistics in the app.

I have now played around with ZEN_MQTT and ZEN_API. I can specify whatever I want. The EU server, the global server or just a jumble of letters. It always works. Apparently it always falls back to the fallback, which is the global server.

Have you tried changing that directly in the config.ini and loading it into the container?

@dabenzel
Copy link

dabenzel commented Feb 4, 2024

Okay, I switched to global server and it works again.
I'm not good in Python, but I think, it tries to append "v2" to both API-URLS, but the EU Url does'nt have "v2".
Reference Line 21 and Line 28:

SF_API_URL = "https://app.zendure.tech"
SF_API_VERSION = "v2"
SF_API_BASE_URL = f'{SF_API_URL}/{SF_API_VERSION}'
class ZendureAPI():
''' An API class to handle communication with the Zendure API '''
def __init__(self, verifySSL=True, zen_api="https://app.zendure.tech", parameters=None):
self.baseUrl = f'{zen_api}/{SF_API_VERSION}'

But Global and Europe URL are the following:
Global: https://app.zendure.tech/v2/developer/api/apply
Europe: https://app.zendure.tech/eu/developer/api/apply

@jvinkovic
Copy link
Contributor Author

Looks like easiest would be just to use complete url in config and clean up the script.

@tuxianerDE
Copy link

@jvinkovic you wanna create a pull request for that change suggestion? Happy to take this into consideration, for the next merge given that Zendure is handling URLs so badly.

@jvinkovic
Copy link
Contributor Author

Sure, I'll try to make it these days hopefully (quite busy). Will try to make it backward compatible.

@z-master42
Copy link

I have a new hub and wanted to use it today with the status page, but now I get the same error as in this issue here. I haven't changed anything on my container or in the app.

Log:

2024-04-19 16:59:29,265:ERROR: No configuration file (config.ini) found in execution directory! Using environment variables.
2024-04-19 16:59:29,479:INFO: Authenticating with Zendure ...
2024-04-19 16:59:29,489:DEBUG: Starting new HTTPS connection (1): app.zendure.tech:443
2024-04-19 16:59:31,106:DEBUG: https://app.zendure.tech:443 "POST /v2/auth/app/token HTTP/1.1" 200 None
2024-04-19 16:59:31,108:INFO: Getting device list ...
2024-04-19 16:59:31,794:DEBUG: https://app.zendure.tech:443 "POST /v2/productModule/device/queryDeviceListByConsumerId HTTP/1.1" 200 None
2024-04-19 16:59:31,798:INFO: []
2024-04-19 16:59:31,812:ERROR: Connecting to Zendure's MQTT broker failed!
Traceback (most recent call last):
  File "//solarflow-status.py", line 295, in zendure_mqtt_background_task
    auth = get_auth()
  File "//solarflow-status.py", line 288, in get_auth
    log.info(f'Zendure Auth: {auth}')

NameError: name 'auth' is not defined

@z-master42
Copy link

Update: Found the error. New hub means new device sharing for the second account. Oh boy.

@joe63
Copy link

joe63 commented Jun 7, 2024

I can also not connect:

docker run --rm --env-file .env -p 127.0.0.1:5000:5000 --name solarflow-statuspage rbrandstaedter/solarflow-statuspage:master --online
2024-06-07 06:47:28,357:ERROR: No configuration file (config.ini) found in execution directory! Using environment variables.
2024-06-07 06:47:28,392:INFO: Authenticating with Zendure ...
2024-06-07 06:47:31,634:INFO: Getting device list ...
2024-06-07 06:47:32,793:INFO: []
2024-06-07 06:47:32,795:ERROR: Connecting to Zendure's MQTT broker failed!
Traceback (most recent call last):
File "//solarflow-status.py", line 295, in zendure_mqtt_background_task
auth = get_auth()
File "//solarflow-status.py", line 288, in get_auth
log.info(f'Zendure Auth: {auth}')
NameError: name 'auth' is not defined

curl -i -v --json "{'snNumber': 'H**********', 'account': 'j*******@gmx.at'}" https://app.zendure.tech/eu/developer/api/apply

{"code":200,"success":true,"data":{"appKey":"2****","secret":"8***********","mqttUrl":"mqtt.zen-iot.com","port":1883},"msg":"Successful operation"}* Connection #0 to host app.zendure.tech left intact

my .env-file

ZEN_USER=z*******
ZEN_PASSWD=Z****
MQTT_HOST=mqtt.zen-iot.com
MQTT_PORT=1883
MQTT_USER=2****
MQTT_PWD=8***********
PROD_NAME=SolarFlow Hub 2000

can you pls give me a hint?

@z-master42
Copy link

z-master42 commented Jun 7, 2024

You are on the EU server. The status page only works as it is here with the global server.

You would have to adapt the code manually yourself.

@joe63
Copy link

joe63 commented Jun 7, 2024

Aha,

where (in the Dockerfile) an how (what I have to change)?

@switch to global:
means to delete the mobile-app and register once more?

@joe63
Copy link

joe63 commented Jun 7, 2024 via email

@z-master42
Copy link

Wenn ich nichts übersehen habe muss nur in der ZendureAPI.py v2 auf eu geändert werden. Sicherheitshalber ist das in den anderen .py auch noch gegen zu checken.

Wechsel auf global heißt Gerät aus der App löschen, Region in der App ändern, Gerät neu hinzufügen.

Dann über curl Gerät neu am globalen Server (v2) registrieren.

Hinweis: Beim wechsel der Region in der App verbleibt die bisherige Statistik in der App auf dem "alten Server", ist danach also nicht mehr einsehbar.

@joe63
Copy link

joe63 commented Jun 7, 2024

Danke der Connect funktioniert jetzt! Ich habe die Region gewechselt!

@additionally the statuspage can push the data it reads from Zendure's cloud service to a local MQTT broker
wie funktioniert das?

@z-master42
Copy link

Da wo du in deiner env-Datei den Zendure-Broker angegeben hast kommt eigentlich wenn dann dein lokaler Broker rein, wenn du einen hast. Die "Statuspage" stellt die einzelnen Hubwerte dann über das Topic solarflow-hub bereit.

ZEN_USER=z*******
ZEN_PASSWD=Z****
MQTT_HOST=mqtt.zen-iot.com
MQTT_PORT=1883
MQTT_USER=2****
MQTT_PWD=8***********
PROD_NAME=SolarFlow Hub 2000

@z-master42
Copy link

z-master42 commented Jun 7, 2024

Ich sehe gerade, EU-Server wird bald auch gehen, nur muss dies explizit über ZEN_API mitgeteilt werden. Hat @jvinkovic vor zwei Tagen erst gepushed. Den Stand hatte ich noch nicht.

@mdillmann https://github.com/reinhard-brandstaedter/solarflow-statuspage/blob/master/README.md?plain=1#L39 hier ist ein ` zuviel.

@joe63
Copy link

joe63 commented Jun 7, 2024

Ich sehe gerade, EU-Server geht mittlerweile auch, nur muss dies explizit über ZEN_API mitgeteilt werden. Hat @jvinkovic vor zwei Tagen erst gepushed. Den Stand hatte ich noch nicht.

@mdillmann https://github.com/reinhard-brandstaedter/solarflow-statuspage/blob/master/README.md?plain=1#L39 hier ist ein ` zuviel.

Wenn man diese Änderung um File durchführt, muss man dann den Container lokal erzeugen??

@joe63
Copy link

joe63 commented Jun 7, 2024

Da wo du in deiner env-Datei den Zendure-Broker angegeben hast kommt eigentlich wenn dann dein lokaler Broker rein, wenn du einen hast. Die "Statuspage" stellt die einzelnen Hubwerte dann über das Topic solarflow-hub bereit.

Danke, so ist es sehr gut um es weiterzuverarbeiten.

Ein letztes noch für heute:

image

Welche Werte sollten hier drin stehen?

@z-master42
Copy link

Ich sehe gerade, EU-Server geht mittlerweile auch, nur muss dies explizit über ZEN_API mitgeteilt werden. Hat @jvinkovic vor zwei Tagen erst gepushed. Den Stand hatte ich noch nicht.

@mdillmann https://github.com/reinhard-brandstaedter/solarflow-statuspage/blob/master/README.md?plain=1#L39 hier ist ein ` zuviel.

Wenn man diese Änderung um File durchführt, muss man dann den Container lokal erzeugen??

Ja, solange es noch nicht im master-Branch ist.

@z-master42
Copy link

Da wo du in deiner env-Datei den Zendure-Broker angegeben hast kommt eigentlich wenn dann dein lokaler Broker rein, wenn du einen hast. Die "Statuspage" stellt die einzelnen Hubwerte dann über das Topic solarflow-hub bereit.

Danke, so ist es sehr gut um es weiterzuverarbeiten.

Ein letztes noch für heute:

image

Welche Werte sollten hier drin stehen?

Der aktuelle Verbrauch deines Stromzählers, wenn dieser Wert per MQTT mitgeteilt werden sollte.

@mdillmann
Copy link
Contributor

Ich sehe gerade, EU-Server wird bald auch gehen, nur muss dies explizit über ZEN_API mitgeteilt werden. Hat @jvinkovic vor zwei Tagen erst gepushed. Den Stand hatte ich noch nicht.

@mdillmann https://github.com/reinhard-brandstaedter/solarflow-statuspage/blob/master/README.md?plain=1#L39 hier ist ein ` zuviel.

Thanks, I created a PR to correct that typo (VS-Code is sometimes over-enthusiastic ...)

@joe63
Copy link

joe63 commented Jun 7, 2024

@der aktuelle Verbrauch deines Stromzählers, wenn dieser Wert per MQTT mitgeteilt werden sollte.

über diesen Weg?
you can already today publish to the topic iot/73bkTV//properties/write and the statuspage will forward it to to the Zendure MQTT to set properties of the hub.

wird das irgendwo näher beschrieben, wie z.B.: diese Property für den Verbrauch heißen muss damit die Werte dann in diesem Feld angezeigt werden?

@z-master42
Copy link

@der aktuelle Verbrauch deines Stromzählers, wenn dieser Wert per MQTT mitgeteilt werden sollte.

über diesen Weg? you can already today publish to the topic iot/73bkTV//properties/write and the statuspage will forward it to to the Zendure MQTT to set properties of the hub.

wird das irgendwo näher beschrieben, wie z.B.: diese Property für den Verbrauch heißen muss damit die Werte dann in diesem Feld angezeigt werden?

Nein, damit kannst du den SolarFlow Hub regeln.

Um deinen aktuellen Bezug in Watt in der Statuspage anzuzeigen musst du diese als reinen Zahlenwert unter dem Topic solarflow-hub/control/homeUsage veröffentlichen.

@joe63
Copy link

joe63 commented Jun 7, 2024

danke funktioniert!
image

@romestylez
Copy link

romestylez commented Jun 18, 2024

Ich habe mal eine Frage. Ich habe mein HUB2000 freigegeben. Wenn ich das Ding aber registrieren will geht das nur mit dem Haupt-Account welchen ich auf meinem Handy nutze. Gebe ich das Gerät für einen anderen Account frei und nehme dort die Freigabe an sehe ich nur folgenden Fehler.

{"code":400,"success":false,"data":{},"msg":"Please bind the device first"}

@romestylez
Copy link

Okay its working now when i use the jason on the account which is initially connected with the HUB. Its not working with shared devices. This really isnt that nice as i want to use the main account on my phone but when i relogin on my phone and restart the docker container i get a login failed again.

@reinhard-brandstaedter
Copy link
Owner

Everytime you log in to the Zendure API (with your user/email) a new authentication token is generated for their MQTT server (which is where all the data for the App/statuspage is coming from). So you can't use the statuspage and the app in parallel.
The idea is to use the statuspage for offline hubs and/or do the controlling og the hub via sf-control and Homeassistant integration (or any other HA system via the local MQTT).

@z-master42
Copy link

Use your main account to bind and the secondary account to connect via the status page. Works for me too.

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

8 participants