home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.56k stars 30.74k forks source link

Snooz integration is unable to set up devices #99231

Closed jay-kub closed 1 year ago

jay-kub commented 1 year ago

The problem

When adding a device the integration instantly moves from Submit to Created configuration for Snooz DFEA, without allowing any time to process the configuration or even allowing the Snooz device to be put into pairing mode. Any commands sent a Snooz device returns the following error:

homeassistant.exceptions.HomeAssistantError: Command TurnOn failed with status UNEXPECTED_ERROR after 0:00:00.521068 2023-08-28 12:20:46.901 ERROR (MainThread) [root] A message handler raised an exception: "Can't trigger event device_disconnected from state DISCONNECTED!".

To troubleshoot I moved one of the devices right next to the bluetooth beacon, but received the same results. I also installed a fresh HAOS build onto different device, then configured all of my Snooz devices correctly which were able to successfully receive all commands.

I then did a full system restore onto the new HAOS device. This required me to set up the Snooz integration once again, at which point I began seeing the same error messages.

What version of Home Assistant Core has the issue?

core-2023.8.4

What was the last working version of Home Assistant Core?

core-2023.7.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Snooz

Link to integration documentation on our website

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

Diagnostics information

home-assistant_snooz_2023-08-28T19-12-29.745Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

ile "/usr/src/homeassistant/homeassistant/components/snooz/fan.py", line 132, in async_turn_on
await self._async_execute_command(turn_on(percentage))
File "/usr/src/homeassistant/homeassistant/components/snooz/fan.py", line 162, in _async_execute_command
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Command TurnOn failed with status UNEXPECTED_ERROR after 0:00:00.521068
2023-08-28 12:20:46.901 ERROR (MainThread) [root] A message handler raised an exception: "Can't trigger event device_disconnected from state DISCONNECTED!".

Additional information

No response

home-assistant[bot] commented 1 year ago

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

Code owner commands Code owners of `snooz` 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 snooz` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


snooz documentation snooz source (message by IssueLinks)

AustinBrunkhorst commented 1 year ago

Thanks @francesc0s. I was able to find an issue using the logs you provided. These changes were merged in #99368. Can you report back if the issue persists?

If the issue does persist, it would be helpful to get debug logs to understand what's going on with the connection process.

Debug logs for snooz

logger:
  default: info
  logs:
    homeassistant.components.snooz: debug
    pysnooz: debug
jay-kub commented 1 year ago

Thank you so much for your help with this, Austin! Looking forward to installing 2023.9.0 and reporting back.

jay-kub commented 1 year ago

Hey @AustinBrunkhorst. The issue has persisted in 2023.9.0. When I clicked "Disable Debugging Logs" on the Snooz integration these logs automatically downloaded, so I'm hoping that's what you're looking for. Please let me know if there's anything else I can do to help and I'll jump right on it.

I tested this on a Snooz device that was ~ 1 meter from the bluetooth controller, so range should not impacted the results.

home-assistant_snooz_2023-09-06T20-30-52.472Z.log

AustinBrunkhorst commented 1 year ago

@francesc0s thank you for these logs - they seem to indicate that the device doesn't have an expected Bluetooth characteristic that's used to send the device commands. Can you share the diagnostics from your bluetooth config entry?

image
jay-kub commented 1 year ago

@AustinBrunkhorst here's the corresponding Snooz object from the Bluetooth config diagnostics. Is that what you need or do you need the whole file? I was a bit hesitant to share the whole diagnostic as I'm not sure if that would leave me vulnerable for some reason. There's quite a lot of info in there.

        {
          "name": "Snooz-183E",
          "address": "40:F5:20:48:18:3E",
          "rssi": -53,
          "manufacturer_data": {
            "65535": {
              "__type": "<class 'bytes'>",
              "repr": "b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
            }
          },
          "service_data": {},
          "service_uuids": [],
          "source": "00:1A:7D:DA:71:07",
          "advertisement": [
            "Snooz-183E",
            {
              "65535": {
                "__type": "<class 'bytes'>",
                "repr": "b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
              }
            },
            {},
            [],
            null,
            -53,
            [
              "/org/bluez/hci0/dev_40_F5_20_48_18_3E",
              {
                "Address": "40:F5:20:48:18:3E",
                "AddressType": "public",
                "Name": "Snooz-183E",
                "Alias": "Snooz-183E",
                "Paired": false,
                "Bonded": false,
                "Trusted": false,
                "Blocked": false,
                "LegacyPairing": false,
                "Connected": false,
                "UUIDs": [],
                "Adapter": "/org/bluez/hci0",
                "ManufacturerData": {
                  "65535": {
                    "__type": "<class 'bytearray'>",
                    "repr": "bytearray(b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')"
                  }
                },
                "ServicesResolved": false,
                "AdvertisingFlags": {
                  "__type": "<class 'bytearray'>",
                  "repr": "bytearray(b'\\x04')"
                },
                "RSSI": -53
              }
            ]
          ],
          "device": {
            "__type": "<class 'bleak.backends.device.BLEDevice'>",
            "repr": "BLEDevice(40:F5:20:48:18:3E, Snooz-183E)"
          },
          "connectable": true,
          "time": 833785.46213142
        }
AustinBrunkhorst commented 1 year ago

Just the objects related to the failing device will work. The entry you provided is helpful, but I'm looking for the characteristics discovered on the device, which should be object keys prefixed with /org/bluez/hci0/dev_40_F5_20_48_18_3E* in data.dbus.

For example, here's the entries from a working device (/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1):

"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.Device1": {
    "Address": "90:FD:9F:FA:A8:F1",
    "AddressType": "public",
    "Name": "Snooz-A8F1",
    "Alias": "Snooz-A8F1",
    "Paired": false,
    "Trusted": false,
    "Blocked": false,
    "LegacyPairing": false,
    "Connected": false,
    "UUIDs": [
      "00001800-0000-1000-8000-00805f9b34fb",
      "0000180a-0000-1000-8000-00805f9b34fb",
      "729f0608-496a-47fe-a124-3a62aaa3fbc0"
    ],
    "Adapter": "/org/bluez/hci0",
    "ManufacturerData": {
      "65535": {
        "__type": "<class 'bytearray'>",
        "repr": "bytearray(b'\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')"
      }
    },
    "ServicesResolved": false
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattService1": {
    "UUID": "729f0608-496a-47fe-a124-3a62aaa3fbc0",
    "Device": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1",
    "Primary": true,
    "Includes": []
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017/char001d": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "f0499b1b-33ab-4df8-a6f2-2484a2ad1451",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    },
    "Notifying": false,
    "Flags": [
      "read",
      "notify"
    ],
    "NotifyAcquired": false
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017/char001d/desc001f": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattDescriptor1": {
    "UUID": "00002902-0000-1000-8000-00805f9b34fb",
    "Characteristic": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017/char001d",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    }
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017/char001a": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "80c37f00-cc16-11e4-8830-0800200c9a66",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'd\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x08\\x00\\x01\\x00|\\x8a\\x06\\x00\\x00\\x00\\x00\\x00')"
    },
    "Notifying": false,
    "Flags": [
      "read",
      "notify"
    ],
    "NotifyAcquired": false
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017/char001a/desc001c": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattDescriptor1": {
    "UUID": "00002902-0000-1000-8000-00805f9b34fb",
    "Characteristic": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017/char001a",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    }
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017/char0018": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "90759319-1668-44da-9ef3-492d593bd1e5",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0017",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    },
    "Flags": [
      "write"
    ]
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattService1": {
    "UUID": "0000180a-0000-1000-8000-00805f9b34fb",
    "Device": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1",
    "Primary": true,
    "Includes": []
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0014": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "00002a26-0000-1000-8000-00805f9b34fb",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'3')"
    },
    "Flags": [
      "read"
    ]
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0014/desc0016": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattDescriptor1": {
    "UUID": "00002901-0000-1000-8000-00805f9b34fb",
    "Characteristic": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0014",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    }
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0011": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "00002a27-0000-1000-8000-00805f9b34fb",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'2')"
    },
    "Flags": [
      "read"
    ]
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0011/desc0013": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattDescriptor1": {
    "UUID": "00002901-0000-1000-8000-00805f9b34fb",
    "Characteristic": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0011",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    }
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char000e": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "00002a25-0000-1000-8000-00805f9b34fb",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    },
    "Flags": [
      "read"
    ]
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char000e/desc0010": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattDescriptor1": {
    "UUID": "00002901-0000-1000-8000-00805f9b34fb",
    "Characteristic": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char000e",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    }
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char000b": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "00002a24-0000-1000-8000-00805f9b34fb",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'V2')"
    },
    "Flags": [
      "read"
    ]
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char000b/desc000d": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattDescriptor1": {
    "UUID": "00002901-0000-1000-8000-00805f9b34fb",
    "Characteristic": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char000b",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    }
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0008": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattCharacteristic1": {
    "UUID": "00002a29-0000-1000-8000-00805f9b34fb",
    "Service": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'Snooz')"
    },
    "Flags": [
      "read"
    ]
  },
  "org.freedesktop.DBus.Properties": {}
},
"/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0008/desc000a": {
  "org.freedesktop.DBus.Introspectable": {},
  "org.bluez.GattDescriptor1": {
    "UUID": "00002901-0000-1000-8000-00805f9b34fb",
    "Characteristic": "/org/bluez/hci0/dev_90_FD_9F_FA_A8_F1/service0007/char0008",
    "Value": {
      "__type": "<class 'bytearray'>",
      "repr": "bytearray(b'')"
    }
  },
  "org.freedesktop.DBus.Properties": {}
}
jay-kub commented 1 year ago

Here's what I could find with a matching MAC. Please let me know if there's anything else I can provide. I really appreciate your help with this!

            {
              "name": "Snooz-183E",
              "address": "40:F5:20:48:18:3E",
              "rssi": -53,
              "advertisement_data": [
                "Snooz-183E",
                {
                  "65535": {
                    "__type": "<class 'bytes'>",
                    "repr": "b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
                  }
                },
                {},
                [],
                null,
                -53,
                [
                  "/org/bluez/hci0/dev_40_F5_20_48_18_3E",
                  {
                    "Address": "40:F5:20:48:18:3E",
                    "AddressType": "public",
                    "Name": "Snooz-183E",
                    "Alias": "Snooz-183E",
                    "Paired": false,
                    "Bonded": false,
                    "Trusted": false,
                    "Blocked": false,
                    "LegacyPairing": false,
                    "Connected": false,
                    "UUIDs": [],
                    "Adapter": "/org/bluez/hci0",
                    "ManufacturerData": {
                      "65535": {
                        "__type": "<class 'bytearray'>",
                        "repr": "bytearray(b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')"
                      }
                    },
                    "ServicesResolved": false,
                    "AdvertisingFlags": {
                      "__type": "<class 'bytearray'>",
                      "repr": "bytearray(b'\\x04')"
                    },
                    "RSSI": -53
                  }
                ]
              ],
              "details": {
                "path": "/org/bluez/hci0/dev_40_F5_20_48_18_3E",
                "props": {
                  "Address": "40:F5:20:48:18:3E",
                  "AddressType": "public",
                  "Name": "Snooz-183E",
                  "Alias": "Snooz-183E",
                  "Paired": false,
                  "Bonded": false,
                  "Trusted": false,
                  "Blocked": false,
                  "LegacyPairing": false,
                  "Connected": false,
                  "UUIDs": [],
                  "Adapter": "/org/bluez/hci0",
                  "ManufacturerData": {
                    "65535": {
                      "__type": "<class 'bytearray'>",
                      "repr": "bytearray(b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')"
                    }
                  },
                  "ServicesResolved": false,
                  "AdvertisingFlags": {
                    "__type": "<class 'bytearray'>",
                    "repr": "bytearray(b'\\x04')"
                  },
                  "RSSI": -53
                }
              }
            },
        {
          "name": "Snooz-183E",
          "address": "40:F5:20:48:18:3E",
          "rssi": -53,
          "manufacturer_data": {
            "65535": {
              "__type": "<class 'bytes'>",
              "repr": "b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
            }
          },
          "service_data": {},
          "service_uuids": [],
          "source": "00:1A:7D:DA:71:07",
          "advertisement": [
            "Snooz-183E",
            {
              "65535": {
                "__type": "<class 'bytes'>",
                "repr": "b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
              }
            },
            {},
            [],
            null,
            -53,
            [
              "/org/bluez/hci0/dev_40_F5_20_48_18_3E",
              {
                "Address": "40:F5:20:48:18:3E",
                "AddressType": "public",
                "Name": "Snooz-183E",
                "Alias": "Snooz-183E",
                "Paired": false,
                "Bonded": false,
                "Trusted": false,
                "Blocked": false,
                "LegacyPairing": false,
                "Connected": false,
                "UUIDs": [],
                "Adapter": "/org/bluez/hci0",
                "ManufacturerData": {
                  "65535": {
                    "__type": "<class 'bytearray'>",
                    "repr": "bytearray(b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')"
                  }
                },
                "ServicesResolved": false,
                "AdvertisingFlags": {
                  "__type": "<class 'bytearray'>",
                  "repr": "bytearray(b'\\x04')"
                },
                "RSSI": -53
              }
            ]
          ],
          "device": {
            "__type": "<class 'bleak.backends.device.BLEDevice'>",
            "repr": "BLEDevice(40:F5:20:48:18:3E, Snooz-183E)"
          },
          "connectable": true,
          "time": 833785.46213142
        },
        {
          "name": "Snooz-183E",
          "address": "40:F5:20:48:18:3E",
          "rssi": -53,
          "manufacturer_data": {
            "65535": {
              "__type": "<class 'bytes'>",
              "repr": "b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
            }
          },
          "service_data": {},
          "service_uuids": [],
          "source": "00:1A:7D:DA:71:07",
          "advertisement": [
            "Snooz-183E",
            {
              "65535": {
                "__type": "<class 'bytes'>",
                "repr": "b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
              }
            },
            {},
            [],
            null,
            -53,
            [
              "/org/bluez/hci0/dev_40_F5_20_48_18_3E",
              {
                "Address": "40:F5:20:48:18:3E",
                "AddressType": "public",
                "Name": "Snooz-183E",
                "Alias": "Snooz-183E",
                "Paired": false,
                "Bonded": false,
                "Trusted": false,
                "Blocked": false,
                "LegacyPairing": false,
                "Connected": false,
                "UUIDs": [],
                "Adapter": "/org/bluez/hci0",
                "ManufacturerData": {
                  "65535": {
                    "__type": "<class 'bytearray'>",
                    "repr": "bytearray(b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')"
                  }
                },
                "ServicesResolved": false,
                "AdvertisingFlags": {
                  "__type": "<class 'bytearray'>",
                  "repr": "bytearray(b'\\x04')"
                },
                "RSSI": -53
              }
            ]
          ],
          "device": {
            "__type": "<class 'bleak.backends.device.BLEDevice'>",
            "repr": "BLEDevice(40:F5:20:48:18:3E, Snooz-183E)"
          },
          "connectable": true,
          "time": 833785.46213142
        },
      "/org/bluez/hci0/dev_40_F5_20_48_18_3E": {
        "org.freedesktop.DBus.Introspectable": {},
        "org.bluez.Device1": {
          "Address": "40:F5:20:48:18:3E",
          "AddressType": "public",
          "Name": "Snooz-183E",
          "Alias": "Snooz-183E",
          "Paired": false,
          "Bonded": false,
          "Trusted": false,
          "Blocked": false,
          "LegacyPairing": false,
          "RSSI": -53,
          "Connected": false,
          "UUIDs": [],
          "Adapter": "/org/bluez/hci0",
          "ManufacturerData": {
            "65535": {
              "__type": "<class 'bytearray'>",
              "repr": "bytearray(b'\\x0c\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')"
            }
          },
          "ServicesResolved": false,
          "AdvertisingFlags": {
            "__type": "<class 'bytearray'>",
            "repr": "bytearray(b'\\x04')"
          }
        },
        "org.freedesktop.DBus.Properties": {}
      },
AustinBrunkhorst commented 1 year ago

I'm only seeing advertisement info from this, which is strange. The next thing we can try is a mobile app like LightBlue (Android, iOS).

Are you able to share the services at the bottom of the screen while connected to the device? Here's what the connected screen looks like for the working device example from earlier: image

AustinBrunkhorst commented 1 year ago

No worries on the bluetooth output - it's a good call to redact unnecessary info; I can confirm what you provided is all that's included about that device. Feel free to remove the file from your post since it's not necessary at this point of troubleshooting.

Thank you for the screenshots. This is exactly what I'm looking for, however I don't think these are Snooz devices. The device's name in the app should start with Snooz-. It would be most valuable to connect to Snooz-183E since that's the device from the debug logs you provided. If the device doesn't show up in the list, try unplugging for 5 seconds and plugging back in. You'll also need to be close to the device with your phone.

jay-kub commented 1 year ago

Sorry about that. This should be the correct one.

Screenshot_20230906-172251 Screenshot_20230906-172247

AustinBrunkhorst commented 1 year ago

Excellent, thanks for providing all of these things. Everything looks normal based on the screenshots, so I suspect this to be issue with the application layer of the bluetooth controller i.e. Bleak cache related? Let me reach out to some of the HA bluetooth experts and see if they can provide insight.

AustinBrunkhorst commented 1 year ago

I've identified the issue and I'm hoping to release a fix by the end of the week. I'll update this thread when that release is available.

jay-kub commented 1 year ago

You're the man! Have a great week my friend.

On Wed, Sep 6, 2023, 6:19 PM Austin Brunkhorst @.***> wrote:

I've identified the issue and I'm hoping to release a fix by the end of the week. I'll update this thread when that release is available.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/99231#issuecomment-1709288303, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3S7UNTTCY7KO4MCC35FXV3XZEHI5ANCNFSM6AAAAAA4B3NAK4 . You are receiving this because you were mentioned.Message ID: @.***>

jay-kub commented 1 year ago

Hey @AustinBrunkhorst. I saw you were able to update the pysnooz repo and are diligently working on getting it merged with HA-core, thanks so much for that.

I'm curious, do you know if there's a way I can manually integrate the newest version of pysnooz into HA? I recently followed a tutorial to fix the MyQ integration where I pulled the pymyq folder from a github repo and put it straight into my HA config folder, and it just worked seamlessly. Is it possible I could do the same with pysnooz?

AustinBrunkhorst commented 1 year ago

I'm curious, do you know if there's a way I can manually integrate the newest version of pysnooz into HA?

Yes, unzip this in config/custom_components/snooz to use the pysnooz version that introduces a fix for your issue. You'll want to remove this folder once you update Home Assistant otherwise you'll be stuck with the version in the custom_components folder.

There's also this version which will eventually be merged into core. It could be some time at this rate, as there's around 3-4 PRs worth of changes to get reviewed. This version adds:

jay-kub commented 1 year ago

I unzipped that folder, renamed it to 'snooz', added it to my custom_components folder, and restarted HA. Then I clicked Add Integration and found Snooz, and confirmed it has the Custom integration icon next to it.

After clicking on Snooz it gave me a processing animation for ~30 seconds and then said "No devices found on the network", which I believe means it cannot find my bluetooth receiver. All retries received the same error instantly. I tried changing my bluetooth settings to passive and then back to not-passive, restarting the VM, deleting the snooz folder and re-copying it, but I still get the same error.

I can't get far enough into the setup to enable debug logging for Snooz, and adding it to the config file did not produce any relevant logs either as far as I can tell. Same goes for the Bluetooth integration debug logs.

Any idea how I can troubleshoot this?

AustinBrunkhorst commented 1 year ago

Make sure pysnooz is included in the debug loggers:

logger:
  logs:
    homeassistant.components.snooz: debug
    pysnooz: debug

Can you share the logs output from pysnooz? There's a few logs for parsing advertisements and starting connections that may be useful for seeing where things go wrong.

jay-kub commented 1 year ago

I add that code to the config.yaml file, is that right? From there do I go to Settings > System> Logs > Download Full Log? I have the HA CORE option selected in the dropdown, but I don't see anything Snooz or Bluetooth related in that log.

AustinBrunkhorst commented 1 year ago

but I don't see anything Snooz or Bluetooth related in that log.

Are you referring to the UI list or the file that is downloaded when you click Download Full Log? There should at least be a log like this when a connection is started:

2023-09-21 16:35:20.149 DEBUG (MainThread) [pysnooz.device] [Snooz 2806] Start connection

jay-kub commented 1 year ago

When I download the full log the only relative thing I can see is the bluetooth component starting.

AustinBrunkhorst commented 1 year ago
  1. Make sure you're using the version with the new entities
  2. Overwrite /config/custom_components/snooz/config_flow.py with this.
  3. Restart home assistant
  4. Try to setup the snooz integration. It should log reasons for rejecting an advertisement (this will include non-Snooz devices as well) - I'm looking for any error logs that mention the device you're trying to setup. That would be "Snooz XXXX" or "XXXX" where "XXXX" is the last 4 characters in the device's MAC address.
jay-kub commented 1 year ago

Ok looks like the logging is working better now, but I don't see the 183E device that is sitting a couple feet from the bluetooth receiver.

2023-09-21 20:17:32.854 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration snooz which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-09-21 20:18:51.017 ERROR (MainThread) [custom_components.snooz] Advertisement was none (N041T): {}
2023-09-21 20:18:51.027 ERROR (MainThread) [custom_components.snooz] Advertisement was none (N044A): {}
2023-09-21 20:18:51.047 ERROR (MainThread) [custom_components.snooz] Advertisement length was invalid (98E78225FF4630AEE9): 13
2023-09-21 20:18:51.064 ERROR (MainThread) [custom_components.snooz] Advertisement was none (N0AQN): {}
2023-09-21 20:18:51.065 ERROR (MainThread) [custom_components.snooz] Advertisement length was invalid ([TV] Samsung Q80 Series (65)): 24
2023-09-21 20:18:51.069 ERROR (MainThread) [custom_components.snooz] Advertisement was none (N0B2R): {}
2023-09-21 20:18:51.077 ERROR (MainThread) [custom_components.snooz] Advertisement length was invalid (SCHLAGE000B4B23): 17
2023-09-21 20:18:51.084 ERROR (MainThread) [custom_components.snooz] Advertisement length was invalid (846B218CC2D038A8E9): 13
2023-09-21 20:18:51.087 ERROR (MainThread) [custom_components.snooz] Advertisement length was invalid (13-4B-A3-86-91-2F): 27
2023-09-21 20:18:51.087 ERROR (MainThread) [custom_components.snooz] Advertisement length was invalid (28-BF-6A-64-9A-7D): 27
2023-09-21 20:18:51.088 ERROR (MainThread) [custom_components.snooz] Advertisement was none (N0FUX): {}
2023-09-21 20:18:51.115 ERROR (MainThread) [custom_components.snooz] Advertisement length was invalid (Galaxy Watch5 Pro (MWET)): 11
2023-09-21 20:18:51.119 ERROR (MainThread) [custom_components.snooz] Advertisement was none (N03XL): {}

I hope you get a good laugh about the randomly assigned name of one of my Sonos devices. 5 letters and starts with N.

AustinBrunkhorst commented 1 year ago

Try disabling any other integration that uses bluetooth. Unplug the Snooz device for at least 5 seconds then plug back in. In my experiences, sometimes the Snooz takes a bit for whatever reason to become discoverable. Also make sure the mobile app (including LightBlue that I had you use previously) is not connected.

jay-kub commented 1 year ago

I believe this is the only integration using bluetooth. Sonos, Samsung and Schlage all use web APIs. I, turned off my phone's bluetooth, grabbed a second Snooz and moved it next to the receiver, and ran the configuration multiple times with the Snooz devices in pairing mode as well as not in pairing mode. I don't see any changes to the logs. It seems like the Snooz devices are somehow being removed from the array of bluetooth devices returned.

AustinBrunkhorst commented 1 year ago

Very strange. Thanks for sticking with me on troubleshooting. To sanity check, can you remove the custom component folder and see if you're still reproducing the original issue?

jay-kub commented 1 year ago

Thanks for sticking with me too my friend. I removed the custom components folder, restarted, and got the same result. I then removed the bluetooth integration, restarted my VM, re-configured the bluetooth integration, and got the same result.

I also grabbed an AtomS3 Lite ESP32S3 and reflashed it to work as a bluetooth proxy, and disconnected the bluetooth dongle I have been previously using. Again I could not find the Snooz devices. The logs were the same, finding nearly all other bluetooth devices in my home but none of the Snooz devcies, which are < 1 meter from the proxy.

At this point I wonder if there's an issue with the bluetooth drivers in my HAOS install. When I initially added bluetooth and snooz to HA it was an all day hackathon, and perhaps I screwed something up in the process. Do you know of a way to reset the bluetooth drivers in HA without doing a clean install? Perhaps at this point a clean install may be the quickest resolution, although that seems like quite the mountain to climb.

jay-kub commented 1 year ago

I spun up a new Home Assistant VM on the same host and bluetooth receiver I've been using from the beginning, and the Snooz devices were found immediately and configured on the first go.

I wonder if clearing all cached Snooz data from HA would be a good place to start? I imagine clearing out the _pycache_ directory clears out the Snooz integration cache, but do you know how I could clear it out of the HA-core cache? Would that be as simple as going to _.storage/bluetooth.remotescanners and deleting all the objects tied to the Snoozs? Or is that data stored elsewhere?

jay-kub commented 1 year ago

Hey @AustinBrunkhorst. I just upgraded both the supervisor and HA-core to 2023.10.0 and the issue persists. Any ideas how I can move forward here? Seeing as this appears to be more of an issue with HA and bluetooth, do you think I should I open a new ticket listing the bluetooth integration causing the issue?

AustinBrunkhorst commented 1 year ago

I'm sorry to hear the issue persists. I can help continue with troubleshooting, but I won't be available for open-source work for a few weeks at least.

To get help with this sooner, you could create a separate issue listing the bluetooth integration like you mentioned. Specifically, it sounds like your bluetooth controller is having issues picking up advertisements from your Snooz devices. It would be helpful for whoever looks into the issue if you can verify that you are able to setup any other integration that uses an active bluetooth connection. This would give us a better understanding of if these issues are unique to the Snooz devices/integration or not.

jay-kub commented 1 year ago

I decided to do a clean install of HAOS to resolve the problem, so I'm going to mark this one closed. @AustinBrunkhorst I can't thank you enough for everything you've done to try to help me resolve this issue, and for developing such a great integration. Be well my friend!