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

Unable to add a new Gardena Water Computer #117550

Open
alistair23 opened this issue May 16, 2024 · 14 comments
Open

Unable to add a new Gardena Water Computer #117550

alistair23 opened this issue May 16, 2024 · 14 comments

Comments

@alistair23
Copy link
Contributor

The problem

When attempting to add a new computer I keep getting this error

2024-05-16 14:58:32.604 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Gardena 
Water Computer for gardena_bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/gardena_bluetooth/__init__.py", line 55, in async
_setup_entry
    sw_version = await client.read_char(DeviceInformation.firmware_version, None)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/gardena_bluetooth/client.py", line 180, in read_char
    return char.decode(await self.read_char_raw(char.uuid))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/gardena_bluetooth/parse.py", line 82, in decode
    return data.decode("ASCII")
           ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 3: ordinal not in range(128)

What version of Home Assistant Core has the issue?

core-2024.5.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

gardena_bluetooth

Link to integration documentation on our website

https://www.home-assistant.io/integrations/gardena_bluetooth

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @elupus, mind taking a look at this issue as it has been labeled with an integration (gardena_bluetooth) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of gardena_bluetooth can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign gardena_bluetooth Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


gardena_bluetooth documentation
gardena_bluetooth source
(message by IssueLinks)

@elupus
Copy link
Contributor

elupus commented May 17, 2024

Can you check with the official client what firmware that report (full string including any special characters)

@alistair23
Copy link
Contributor Author

This is what I get from manually running your Python scripts

Service: 0000180a-0000-1000-8000-00805f9b34fb (Handle: 16): Gardena DeviceInformation
 -  00002a26-0000-1000-8000-00805f9b34fb (Handle: 21): Gardena DeviceInformation Firmware Version
 -  ['read']
 -  Data: bytearray(b'1.7.23.29')
 -  00002a29-0000-1000-8000-00805f9b34fb (Handle: 19): Gardena DeviceInformation Manufacturer Name
 -  ['read']
 -  Data: bytearray(b'Husqvarna AB')
 -  00002a24-0000-1000-8000-00805f9b34fb (Handle: 17): Gardena DeviceInformation Model Number
 -  ['read']
 -  Data: bytearray(b'Model Number TBD')

If I remove the default argument to read_char() I get this error

gardena_bluetooth.exceptions.CharacteristicNotFound: Unable to find characteristic CharacteristicString(u
uid='00002a26-0000-1000-8000-00805f9b34fb', name='Firmware Version')

So for some reason it can't read the characteristic and by default it returns None, which then can't be decoded

@elupus
Copy link
Contributor

elupus commented May 17, 2024

I cant make what you wrote above make sense. First it seems like it did read the firmware version, then you then say didnt.

Are you sure both those attempts are from the same device? Also its not showing same error as it did in HA, so further indicate a different device.

@elupus
Copy link
Contributor

elupus commented May 17, 2024

Ps. None would not be equal to the hex char 0xe4 mentioned in your initial log.

@alistair23
Copy link
Contributor Author

Are you sure both those attempts are from the same device? Also its not showing same error as it did in HA, so further indicate a different device.

It's possible the first error is from a Husqvarna mower. The integration doesn't print addresses or allow specifying one so it's hard to be sure

@elupus
Copy link
Contributor

elupus commented May 17, 2024

It should not list the mower, so aught to have been a watering computer.

@alistair23
Copy link
Contributor Author

This diff fixes the issue

diff --git a/homeassistant/components/gardena_bluetooth/config_flow.py b/homeassistant/components/gardena_bluetooth/config_flow.py
index c7631b62f4..cd6070bc41 100644
--- a/homeassistant/components/gardena_bluetooth/config_flow.py
+++ b/homeassistant/components/gardena_bluetooth/config_flow.py
@@ -76,8 +76,6 @@ class GardenaBluetoothConfigFlow(ConfigFlow, domain=DOMAIN):
             raise AbortFlow(
                 "cannot_connect", description_placeholders={"error": str(exception)}
             ) from exception
-        finally:
-            await client.disconnect()
 
         return {CONF_ADDRESS: self.address}

It looks like the disconnect and connect are too quick for ESPHome, so the setup fails. Running firmware 1.7.23.29 on a Gardena device

@elupus
Copy link
Contributor

elupus commented May 17, 2024

That is the old change of never disconnecting which is not acceptable.

What espproxy version are you using?

@elupus
Copy link
Contributor

elupus commented May 17, 2024

For the original issue here. A change in the library to ignore unknown chars on decode would be acceptable.

@elupus
Copy link
Contributor

elupus commented May 17, 2024

The fast reconnect we could solve with some explicit delay after disconnect.

@alistair23
Copy link
Contributor Author

That is the old change of never disconnecting which is not acceptable.

It's just not disconnecting during initial setup. I really never understood why you think it's not a good idea

What espproxy version are you using?

2024.5.0

@elupus
Copy link
Contributor

elupus commented May 17, 2024

Because the client object is not shared. It will construct a new object when the entry is setup. So now there are two clients active, one that will potentially disconnect at some random time in the future.

Did you try the suggested esp idf upgrade that bdraco suggested in the other thread.

@alistair23
Copy link
Contributor Author

ESPHome 2024.5.0 uses esp idf 4.4.7, it's the latest and greatest

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

No branches or pull requests

2 participants