core icon indicating copy to clipboard operation
core copied to clipboard

Keymitt MicroBot Push error

Open jflefebvre06 opened this issue 1 year ago • 16 comments

The problem

Since last HA release, "Keymitt MicroBot Push" not always respond and 3 errors into the log

What version of Home Assistant Core has the issue?

2024.2.0b7

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Keymitt MicroBot Push

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/keymitt_ble

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: py.warnings
Source: components/keymitt_ble/switch.py:50
First occurred: 17:58:57 (3 occurrences)
Last logged: 18:04:50

/usr/local/lib/python3.12/site-packages/microbot/__init__.py:240: RuntimeWarning: coroutine 'MicroBotApiClient.is_connected' was never awaited if self.is_connected():

------------------------------------

Logger: microbot
Source: components/keymitt_ble/switch.py:55
First occurred: 18:00:02 (16 occurrences)
Last logged: 18:04:43

Failed to set token: Characteristic {char_specifier} was not found!
Failed to push: Characteristic {char_specifier} was not found!
Failed to set token: Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)
Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTNotifyResponse, BluetoothGATTErrorResponse: Unknown error (22)
Bluetooth GATT Error address=D6:DE:71:E3:3F:9C handle=23 error=-1 description=Not connected

------------------------------------

Logger: microbot
Source: components/keymitt_ble/switch.py:50
First occurred: 18:02:32 (5 occurrences)
Last logged: 18:04:43

'bool' object is not callable
Failed to push: Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)
Failed to set token: Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)
Failed to push: Characteristic {char_specifier} was not found!

Additional information

No response

jflefebvre06 avatar Feb 05 '24 17:02 jflefebvre06

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

Code owner commands

Code owners of keymitt_ble 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 keymitt_ble 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)


keymitt_ble documentation keymitt_ble source (message by IssueLinks)

home-assistant[bot] avatar Feb 05 '24 17:02 home-assistant[bot]

Should be fixed by

https://github.com/home-assistant/core/pull/109644 and https://github.com/home-assistant/core/pull/109628

spycle avatar Feb 05 '24 22:02 spycle

@spycle if you encounter a bug you fix during beta period please ask to add it to the next milestone. I have added your fixes for now hopefully they won't have merge conflicts as beta was just shipped 3 hours ago.

thecode avatar Feb 05 '24 22:02 thecode

Hello @spycle I have integrated into my HA, now I have no error into log but "switch.microbot_push" have no effect. Only works few seconds if I press de keymit button before keymitt_ble.zip

jflefebvre06 avatar Feb 06 '24 07:02 jflefebvre06

I have this warning

Cette erreur provient d'une intégration personnalisée

Logger: py.warnings Source: custom_components/keymitt_ble/switch.py:50 Integration: Keymitt MicroBot Push First occurred: 08:41:27 (6 occurrences) Last logged: 08:52:25

/usr/local/lib/python3.12/site-packages/microbot/__init__.py:241: RuntimeWarning: coroutine 'MicroBotApiClient.is_connected' was never awaited if self.is_connected():
/usr/local/lib/python3.12/site-packages/microbot/__init__.py:207: FutureWarning: is_connected has been changed to a property. Calling it as an async method will be removed in a future version self._client.is_connected(),

jflefebvre06 avatar Feb 06 '24 07:02 jflefebvre06

I'll have a look later but have you removed and re added the integration?

spycle avatar Feb 06 '24 18:02 spycle

No I have not removed or re added the integration

jflefebvre06 avatar Feb 07 '24 06:02 jflefebvre06

Can you try please?

spycle avatar Feb 07 '24 08:02 spycle

  1. As your code have been merged to 2024.2.0b9, I have removed code from custom_component
  2. I have removed integration, restart ha and wait.
  3. Button not auto discovered after 20minutes.
  4. Wake it pressing button, auto discovered immediately.
  5. Add button
  6. Switch works 2 minutes and became unavailable

Logger: microbot Source: components/keymitt_ble/switch.py:55 First occurred: 10:14:15 (10 occurrences) Last logged: 10:17:14

Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTNotifyResponse, BluetoothGATTErrorResponse: Unknown error (22)
Failed to set token: Characteristic {char_specifier} was not found!
Failed to push: Characteristic {char_specifier} was not found!
'bool' object is not callable
Logger: py.warnings
Source: components/keymitt_ble/switch.py:55
First occurred: 10:19:46 (2 occurrences)
Last logged: 10:21:12

/usr/local/lib/python3.12/site-packages/microbot/__init__.py:241: RuntimeWarning: coroutine 'MicroBotApiClient.is_connected' was never awaited if self.is_connected():

Logger: microbot Source: components/keymitt_ble/switch.py:50 First occurred: 10:14:15 (4 occurrences) Last logged: 10:14:15

Failed to set token: Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)
Failed to push: Characteristic {char_specifier} was not found!
Failed to push: Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)

Logger: microbot Source: components/keymitt_ble/switch.py:55 First occurred: 10:14:15 (25 occurrences) Last logged: 10:21:12

Peripheral D6:DE:71:E3:3F:9C changed connection status while waiting for BluetoothGATTNotifyResponse, BluetoothGATTErrorResponse: Unknown error (22)
Failed to set token: Characteristic {char_specifier} was not found!
Failed to push: Characteristic {char_specifier} was not found!
'bool' object is not callable
Failed to connect:
Logger: py.warnings
Source: components/keymitt_ble/switch.py:50
First occurred: 10:14:15 (1 occurrences)
Last logged: 10:14:15

/usr/local/lib/python3.12/site-packages/microbot/__init__.py:241: RuntimeWarning: coroutine 'MicroBotApiClient.is_connected' was never awaited if self.is_connected():

jflefebvre06 avatar Feb 07 '24 09:02 jflefebvre06

The only way I found to make it works is to add to esphome this snipped of code to maintain the connection

ble_client:
  - mac_address: ${microbot_mac_address}
    id: microbot_client
    on_connect: 
      then:
        - logger.log: "Connected to MicroBot"
    on_disconnect: 
      then:
        - logger.log: "Disconnected from MicroBot"

but this solution consume a lot of battery

jflefebvre06 avatar Feb 07 '24 09:02 jflefebvre06

Ok I'm not using esphome so this might be tricky to diagnose. I do have brief periods where it appears unavailable for a few seconds, but then it comes back. About every 10 minutes. I guess that's the problem.

The 241: RuntimeWarning error I've fixed in pyMicrobot 0.0.11. I'll create a pull for that tomorrow but I see you've been trying it as a custom component so you could just point your manifest to this and give it a go? Actually this could be the more likely culprit as esphome is probably not disconnecting properly...

spycle avatar Feb 08 '24 00:02 spycle

@home-assistant reopen

spycle avatar Feb 08 '24 00:02 spycle

I have tried custom component when your code was not merged, now I have removed it. If I remove esphome, keymit integration never connect (integration failed)

jflefebvre06 avatar Feb 08 '24 15:02 jflefebvre06

The fix for at least one of the errors in your log has been released in 2024.2.1. I suspect it may solve the rest and therefore your connectivity issues. Let me know how it goes

spycle avatar Feb 09 '24 20:02 spycle

Hello, the 2024.2.1 not resolve my issue, Keymit desconnect after few minutes and does not work until I wake it pressing the physical button

jflefebvre06 avatar Feb 12 '24 13:02 jflefebvre06

#110502 made it into 2024.2.2 but unfortunately it's no help without #110506. Just waiting on that to be approved. I have it working locally

spycle avatar Feb 17 '24 03:02 spycle

sorry still waiting for https://github.com/home-assistant/core/pull/110506 to be reviewed.

I actually bought myself an esphome to make sure it was all working this time, and it's working perfectly. Just need someone to have a bit of time and inclination to approve it

spycle avatar Feb 24 '24 13:02 spycle

@jflefebvre06 if you still have the integration installed then you may find that 2024.2.4 fixes it.

I don't know how it will behave without https://github.com/home-assistant/core/pull/110506 which is yet to be reviewed. Config flow is definitely broken without it.

spycle avatar Feb 26 '24 23:02 spycle

Hello, 2024.2.4 does not solve the problem. If I remove my esphome device wich maintain bluetooth connection, keymit device not respond few minutes after HA restart

jflefebvre06 avatar Feb 28 '24 07:02 jflefebvre06

Can you try to install the HA beta 2024.3.0b from today and see if there's still an issue?

TheJulianJES avatar Feb 28 '24 23:02 TheJulianJES

Can you try to install the HA beta 2024.2.3b0 from today and see if there's still an issue?

2024.3.0b0

spycle avatar Feb 29 '24 09:02 spycle

Hello, 2024.2.4 does not solve the problem. If I remove my esphome device wich maintain bluetooth connection, keymit device not respond few minutes after HA restart

@jflefebvre06 apologies, it turned out that the required dependency bump wasn't released in 2024.2.4. It is in the beta >2024.3.0b0 however. Can you confirm if it works for you?

spycle avatar Feb 29 '24 23:02 spycle

I am running on 2024.3.0, still the same problem, anavailable after 3minutes, wake if I puh the physical button

jflefebvre06 avatar Mar 13 '24 11:03 jflefebvre06

Any errors in the logs?

spycle avatar Mar 14 '24 22:03 spycle

Nothing

jflefebvre06 avatar Mar 20 '24 08:03 jflefebvre06

All I can suggest is removing and re-adding the integration and experimenting with proximity of the esphome.

I can't reproduce your issue on my system with esphome.

spycle avatar Mar 28 '24 07:03 spycle

Hello, since 2024.24 integration works, thanks a lot

jflefebvre06 avatar Apr 02 '24 15:04 jflefebvre06