core: Snooz integration is unable to set up devices

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

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 1
  • Comments: 31 (14 by maintainers)

Most upvoted comments

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.

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!

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.

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.

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

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:

  • Light entity for button lights
  • Switch entity for night mode
  • Fan + Climate entity for Breez devices

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: @.***>

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": {}
      },

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

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