www-ShapeLabs-de / Judo-i-soft-save-plus-to-mqtt-bridge

A small device to write and read settings to Judo i-soft safe+ water softening system with homeassistant
MIT License
24 stars 8 forks source link

Scriptfehler #23

Open threadstone83 opened 1 month ago

threadstone83 commented 1 month ago

Since today I get the following script errors and find no solution how to solve that.

2024-09-16 22:03:36.690828 INFO AppDaemon: Calling initialize() for main_app Lade gespeicherte Variablen

Letzte Fehler-ID: 581270 Wasserverbrauch gestern: 416 Offset für heutigen Wasserverbrauch: 31867 Letzte Ausführung des Scripts: 16 da: 0x1 dt: 0x33 serial: 002187732972 token: xxxxxxxxxx avergage regeneration interval: 52h counter for avg-calc: 93 last regenerations count: 93 timestamp of last regeneration: 1726383644s Softwater prop. since Regeneration: 21.814L Hardwater prop. since Regeneration: 9.81L Initialisierung erfolgreich! 2024-09-16 22:03:36.850168 INFO AppDaemon: Calling initialize() for hello_world Verbunden mit MQTT Broker... Topics wurden abonniert... Autoconfigs wurden gesendet... 2024-09-16 22:03:37.187090 INFO hello_world: Hello from AppDaemon 2024-09-16 22:03:37.190760 INFO hello_world: You are now ready to run Apps! 2024-09-16 22:03:37.194165 INFO AppDaemon: App initialization complete ['Scriptfehler - Fehler beim Holen und Auswerten der Gerätedaten in Zeile: 402', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Auswerten des Fehlerspeichers in Zeile: 523', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Holen und Auswerten der Gerätedaten in Zeile: 402', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Auswerten des Fehlerspeichers in Zeile: 523', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Holen und Auswerten der Gerätedaten in Zeile: 402', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Auswerten des Fehlerspeichers in Zeile: 523', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Holen und Auswerten der Gerätedaten in Zeile: 402', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Auswerten des Fehlerspeichers in Zeile: 523', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Holen und Auswerten der Gerätedaten in Zeile: 402', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ['Scriptfehler - Fehler beim Auswerten des Fehlerspeichers in Zeile: 523', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')] ...

Does anyone have the same problem? Can anyone help? @www-ShapeLabs-de @danielegger1 eventually you?

threadstone83 commented 1 month ago

I played a little bit. Now I get the following error:

['Scriptfehler - Judo-login fehlgeschlagen in Zeile: 293', JSONDecodeError('Expecting value: line 1 column 1 (char 0)')]

I tried to access https://www.myjudo.eu/interface/?group=register&command=login&name=login&user={username}&password={pwmd5}&nohash=Service&role=customer but I also get the error, that the login is not possible. At the homepage I can login without any problems but the link looks completely different after login.

Eventually Judo have changed their login?!

threadstone83 commented 1 month ago

Yes, it looks like Judo have changed something. Also at the iobroker integration they have problems: https://github.com/arteck/ioBroker.judoisoft/issues/40 https://forum.iobroker.net/topic/40337/test-wasserenth%C3%A4rtung-judo-i-soft-plus-adapter/174

hankipanky commented 1 month ago

Looks like their API endpoint blocks HTTP requests from scripts, based on the user-agent header 🤦

This works:

curl 'https://www.myjudo.eu/interface/?token={token}&group=register&command=get%20device%20data' -H 'User-Agent: Mozilla'

Without the user-agent header, or with the default python-urllib/3, the response body is empty.

threadstone83 commented 1 month ago

Any idea how to modify the code in getjudo.py (line 292 round about)?

def judo_login(username, password):
    pwmd5 = hashlib.md5(password.encode("utf-8")).hexdigest()
    try:
        login_response = http.request('GET', f"https://www.myjudo.eu/interface/?group=register&command=login&name=login&user={username}&password={pwmd5}&nohash=Service&role=customer")
        login_response_json = json.loads(login_response.data)
        if "token" in login_response_json:
            print(messages_getjudo.debug[22].format(login_response_json['token']))
            return login_response_json['token']
        else:
            notify.publish(messages_getjudo.debug[21], 2)
            sys.exit()
    except Exception as e:
        notify.publish([messages_getjudo.debug[28].format(sys.exc_info()[-1].tb_lineno),e], 3)
        sys.exit()
hankipanky commented 1 month ago

The urllib3.PoolManager can be instructed to use default headers for all requests:

user_agent = {'user-agent':'Mozilla'}
http = urllib3.PoolManager(10, headers=user_agent)

I'll create a PR tomorrow.

gmbh07 commented 1 month ago

i always get this errors but i have no idea what to do, can you help me pls?

['Scriptfehler - Fehler beim Auswerten des Fehlerspeichers in Zeile: 396', "Expecting value: line 1 column 1 (char 0) - b''"] ['Scriptfehler - Fehler beim Auswerten des Fehlerspeichers in Zeile: 500', "Expecting value: line 1 column 1 (char 0) - b''"]

hankipanky commented 1 month ago

i always get this errors but i have no idea what to do, can you help me pls?

I've filed a PR (see #24 ). Either you can wait for it to be merged, or you can make the simple change yourself.

deluxestyle commented 1 month ago

The urllib3.PoolManager can be instructed to use default headers for all requests:

user_agent = {'user-agent':'Mozilla'}
http = urllib3.PoolManager(10, headers=user_agent)

I'll create a PR tomorrow.

seems to work. Thank you

gohakn commented 1 month ago

For me it also works fine. Thank you

udoersam commented 1 month ago

I can confirm that the workaround / fix works as aprected. Thanks

threadstone83 commented 1 month ago

I an also confirm. With the code / the workaround all works again. Thank you very much!!

Is it possible to add the the missed consumption values ​​in HA? I think I know how to do it in the energy dashboard, but in the entities?

Towerlein commented 1 month ago

Mein Home Assistant zeigt den gleichen Fehler an. könnt ihr mir bitte erklären, in welcher Datei ihr was verändert habt? Herzlichen Dank

Towerlein commented 1 month ago

Ah, if you look you will find. "Deluxstyle". you are great. How do you come up with a solution like that? Thank you, for this... https://github.com/www-ShapeLabs-de/Judo-i-soft-save-plus-to-mqtt-bridge/pull/24/commits/1fb0e0399f62ad99104eb48f84d2c8f2de45b873

deluxestyle commented 1 month ago

Ah, if you look you will find. "Deluxstyle". you are great. How do you come up with a solution like that? Thank you, for this... 1fb0e03

Was not me. It was @hankipanky

Towerlein commented 1 month ago

oh, sorry that's right, thank you @hankipanky :-)

threadstone83 commented 1 month ago

Since today I have the same error. @hankipanky do you have a solution again?

EDIT: I had this happen also a few days ago. A reboot fixed it. It seems like I get logged out every 2 days at night. Anyone have any ideas?

EDIT 2: I don't know what that was, but after I had to restart AppDeamon twice (after it was no longer able to retrieve data), everything has been running as it should for a few days now. So my question is no longer relevant.

mike4001 commented 3 weeks ago

Since this morning it is not working for me.

Logs say

['Scriptfehler - Fehler beim Holen und Auswerten der Gerätedaten in Zeile: 409', KeyError('7')]

gmbh07 commented 3 weeks ago

me too, same error

mike4001 commented 3 weeks ago

OK, it the Integration just correctly updated again.

Probably was just a server-side issue on Judo´s part.

Hope this is it ....

deluxestyle commented 3 weeks ago

Mine is working. But it seems there have been no values over night