rewardone / homeassistant-culligan-water-softener

Home Assistant specific integration for Culligan Water Softeners
MIT License
3 stars 1 forks source link

Something unknown happened. #11

Closed loictinant closed 4 days ago

loictinant commented 1 week ago

Hello,

I can’t connect, I get a “Something unknown happened” error.

What should I do?

Capture d’écran 2024-11-14 190927

rewardone commented 1 week ago

Ultimately I'm not sure how Culligan devices interact. I don't know if they are regional or not. I added a region selector because the underlying Ayla API has different endpoints for certain EU devices.

You can try:

Currently, the sign in code doesn't pass the EU bool to Ayla.

loictinant commented 1 week ago

It doesn't change anything by activating EU or other. And how to activate the journal since I can't activate it?

loictinant commented 1 week ago

Enregistreur: custom_components.culligan Source: custom_components/culligan/config_flow.py:94 intégration: Culligan (documentation, problèmes) S'est produit pour la première fois: 12:10:26 (2 occurrences) Dernier enregistrement: 12:10:39

Unexpected exception Traceback (most recent call last): File "/config/custom_components/culligan/config_flow.py", line 94, in validate_input await culligan.async_sign_in() File "/usr/local/lib/python3.12/site-packages/culligan/uniapi_culliganiot.py", line 158, in async_sign_in self._set_credentials(resp.status, await resp.json()) File "/usr/local/lib/python3.12/site-packages/culligan/uniapi_culliganiot.py", line 120, in _set_credentials self._ayla_access_token = login_result["data"]["linkedAccounts"]["ayla"]["access_token"]


KeyError: 'ayla'
rewardone commented 1 week ago

You can try v1.3.5-beta1 and see what debug/error messages are different.

loictinant commented 1 week ago

Unknown error occurred or The username field must be an email address, even though I entered my email address correctly.

rewardone commented 1 week ago

There is a regex that is supposed to capture most valid email addresses. You can test to see if this regex is not validating your email and let me know what is missing.

loictinant commented 1 week ago

sorry I didn't understand what to do (I'm French)

rewardone commented 1 week ago

Try in Python to see if your email matches. Replace "emailaddress@email.com" with your email.

I would start removing characters in your email address until the regex says your email matches. There will probably be a specific character that needs to be added to the regex, especially of the character is unique to other languages (e.g. accents or other markings).

loictinant commented 1 week ago

I recreated an account with a Gmail email address (before it was Hotmail), and I managed to connect.

Now the integration finds nothing.

Enregistreur: homeassistant.config_entries Source: config_entries.py:635 S'est produit pour la première fois: 23:05:40 (1 occurrences) Dernier enregistrement: 23:05:40

Error setting up entry Culligan - for culligan Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 635, in async_setup_with_context result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/culligan/init__.py", line 111, in async_setup_entry if len(culliganiot_devices) > 0 and len(culligan_devices) > 0: ^^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'culligan_devices' where it is not associated with a value

loictinant commented 1 week ago

So what I just saw is weird.

My new email address already doesn't work anymore and the old one does. In fact, as soon as I add my softener to the app, I can't connect to the integration anymore.

rewardone commented 1 week ago

You can try beta2. I tried to add additional logic to the device array selection code

loictinant commented 1 week ago

Beta2

Enregistreur: homeassistant.config_entries Source: config_entries.py:635 S'est produit pour la première fois: 15:35:33 (1 occurrences) Dernier enregistrement: 15:35:33

Error setting up entry Culligan - for culligan Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 635, in async_setup_with_context result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/culligan/init__.py", line 111, in async_setup_entry if culliganiot_devices and culligan_devices: ^^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'culligan_devices' where it is not associated with a value

I just noticed that if I remove the softener from my Culligan account, the connection goes through fine without any problems, but as soon as I add it back it crashes.

rewardone commented 1 week ago

Gotcha, so something is happening when the integration queries for devices ... and the checks aren't working as expected.

If you have debug logging enabled, there should be a few lines of logs regarding: x num of devices, etc.. Do you have any of those debug logs?

loictinant commented 1 week ago

Where can I find these newspapers?

bchretien commented 4 days ago

Hi,

I got the same initial error and digged a bit into it. Several bugs remain:

After that, the integration no longer fails, but no device/entity is present in HA. With the culligan Python API though, I can access my device through get_devices(), call update() on it and read its properties just fine. Maybe my device is just not supported? https://github.com/rewardone/Culligan/blob/8bb06c2af7e22fbf9ad9d04bf77c36a520e6df60/src/culligan/uniapi_culliganiot.py#L349 -> you can probably add Smart Modernity there (model now commercialized here in France).

rewardone commented 4 days ago

A great point. If you have VS Code plugin or another way to edit code, you can modify this integration's supported classes and include the class from the library. It doesn't include the generic CulliganIoTDevice, which the device would possible be cast to.

If you can confirm that Smart Modernity is your device["name"], I'll get those changes added and we can test them.

bchretien commented 4 days ago

@rewardone yes that's the name:

import culligan

c = culligan.CulliganApi(username, password, api_id)
c.sign_in()
print(c.get_devices()[0].name)
# Smart Modernity

I'll try to test this in the next few days, when I find the time.

rewardone commented 4 days ago

I released beta3, which bumps the version for the Culligan library which now includes Smart Modernity. Fingers crossed for some progress :)

bchretien commented 4 days ago

Oh by the way, I got a bunch of errors when trying culligan with Python 3.9, due to https://github.com/rewardone/ayla-iot-unofficial relying on newer Python features (e.g. here -> Foo | None for optional is a Python 3.10 feature), but culligan is supposedly supporting Python 3.7.

rewardone commented 4 days ago

I'll have to bump it. The Fujitsu code is an addon contributed by another member. It was added a year or so ago. I recommended that it not be part of Ayla and split off like Culligan was. That has not been done and it is now supporting a Core integration.

The culligan library shouldn't call any Ayla code unless the ["access_token"] is provided in the response from culligan, but from a requirements.txt perspective, Ayla is listed and probably pulled in/executed causes those errors.

From a HA perspective, I think < 3.10 is not supported anymore and they use 3.12 currently.

bchretien commented 4 days ago

I released beta3, which bumps the version for the Culligan library which now includes Smart Modernity. Fingers crossed for some progress :)

I still had to fix the _dsn + culligan_devices errors I explained above, but after that: it works! 🎉 1 device and 67 entities 🚀

rewardone commented 4 days ago

Pushed beta4. I bumped Culligan again to add the _dsn property to the class. Someone is using Smart HE and didn't report the issues, so I'm cautious of breaking things. This should allow the existing join(_dsn) code to work.

Indented the button and switch to be within their respective loops.

Initialized the culligan_devices array.

bchretien commented 4 days ago

Pushed beta4. I bumped Culligan again to add the _dsn property to the class. Someone is using Smart HE and didn't report the issues, so I'm cautious of breaking things. This should allow the existing join(_dsn) code to work.

Indented the button and switch to be within their respective loops.

Initialized the culligan_devices array.

It seems to be working, kudos 👍 Thanks a lot!

rewardone commented 4 days ago

And thank you for the support in developing a fix! 1.3.5 released

loictinant commented 3 days ago

Thank you very much, everything works.