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

Integration fails to keep a connection with the grill. #61

Open
4 tasks done
Flameancer opened this issue Jul 4, 2024 · 9 comments
Open
4 tasks done

Integration fails to keep a connection with the grill. #61

Flameancer opened this issue Jul 4, 2024 · 9 comments

Comments

@Flameancer
Copy link

System Health details

System Information

version core-2024.7.0
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.33-haos
arch x86_64
timezone America/New_York
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 5000
Installed Version 1.34.0
Stage running
Available Repositories 1392
Downloaded Repositories 4
HACS Data ok
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 12.4
update_channel stable
supervisor_version supervisor-2024.06.2
agent_version 1.6.0
docker_version 26.1.4
disk_total 30.8 GB
disk_used 6.7 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization vmware
board ova
supervisor_api ok
version_api ok
installed_addons Advanced SSH & Web Terminal (18.0.0), Studio Code Server (5.15.0), Matter Server (6.2.1)
Dashboards
dashboards 2
resources 0
views 1
mode storage
Recorder
oldest_recorder_run June 24, 2024 at 2:02 PM
current_recorder_run July 4, 2024 at 3:00 AM
estimated_db_size 105.36 MiB
database_engine sqlite
database_version 3.45.3

Checklist

  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Describe the issue

Hello I have a PB1100PSC2, this integration can see my grill and add it to HA, but all of the sensors are unavailable. I am running HA through a VM on Windows via VMware. I have tried using the onboard BLE devices with the passthrough and I have even setup a BLE proxy. While HA can at first see the grill, it cannot seems to keep the connection. Meanwhile my phone that is sitting in the same location can connect to the grill via BLE without issues.

Reproduction steps

  1. Add the grill to the Pitboss Integration
  2. Attempt to view any sensors while the grill is turned on and running.

Debug logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 578, in bluetooth_device_connect
    await connect_future
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 297, in connect
    await self._client.bluetooth_device_connect(
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 598, in bluetooth_device_connect
    raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to 6E:79:0F:49:E8:26 after 20.0s, disconnect timed out: False,  after 20.0s

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/__init__.py", line 363, in establish_connection
    await client.connect(
  File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 310, in connect
    connected = await super().connect(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 615, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 79, in _async_wrap_bluetooth_operation
    raise asyncio.TimeoutError(str(err)) from err
TimeoutError: Timeout waiting for connect response while connecting to 6E:79:0F:49:E8:26 after 20.0s, disconnect timed out: False,  after 20.0s

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/pitboss/coordinator.py", line 62, in reset_device
    await self.conn.reset_device(device)
  File "/usr/local/lib/python3.12/site-packages/pytboss/ble.py", line 127, in reset_device
    await self.connect()
  File "/usr/local/lib/python3.12/site-packages/pytboss/ble.py", line 89, in connect
    self._ble_client = await bleak_retry_connector.establish_connection(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/__init__.py", line 387, in establish_connection
    _raise_if_needed(name, device.address, exc)
  File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/__init__.py", line 327, in _raise_if_needed
    raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError: PBL-98CDAC586188 - 6E:79:0F:49:E8:26: Failed to connect after 4 attempt(s): Timeout waiting for connect response while connecting to 6E:79:0F:49:E8:26 after 20.0s, disconnect timed out: False,  after 20.0s

Diagnostics dump

No response

@dknowles2
Copy link
Owner

Yeah, this is a common problem. There's some strange interactions between the esphome ble stack and the controllers on the grills that I haven't quite nailed down.

You can try tweaking the esphome settings as suggested here: home-assistant/core#79930 (comment)

In my experience, the retries eventually work, but they do leave a lot of log spam. I don't think I've tried tweaking the esphome settings myself, but I may do that before the next time I fire up my smoker.

@nickwilsonr
Copy link

I'm having a similar problem, with the exception that I'm not using an ESP32. Admittedly there's some distance between where my smoker is located and where my NAS (which is running the HA VM & has the BT receiver plugged into it). However, it detected my grill no problem during the configuration phase.

@Flameancer
Copy link
Author

So I actually made a config change to ESP home and completely reinstalled the pitboss integration and same thing. The devices menu after a few minutes upon reboot sees the pitboss grill and adds it successfully but when viewing the entities they are all unavailable.

Logger: homeassistant
Source: custom_components/pitboss/coordinator.py:62
integration: PitBoss (documentation, issues)
First occurred: 12:09:06 PM (9 occurrences)
Last logged: 2:18:28 PM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 578, in bluetooth_device_connect
await connect_future
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 297, in connect
await self._client.bluetooth_device_connect(
File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 598, in bluetooth_device_connect
raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for connect response while connecting to 53:5D:1C:B4:8B:8F after 20.0s, disconnect timed out: False, after 20.0s

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/init.py", line 363, in establish_connection
await client.connect(
File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 310, in connect
connected = await super().connect(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak/init.py", line 615, in connect
return await self._backend.connect(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 79, in _async_wrap_bluetooth_operation
raise asyncio.TimeoutError(str(err)) from err
TimeoutError: Timeout waiting for connect response while connecting to 53:5D:1C:B4:8B:8F after 20.0s, disconnect timed out: False, after 20.0s

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/config/custom_components/pitboss/coordinator.py", line 62, in reset_device
await self.conn.reset_device(device)
File "/usr/local/lib/python3.12/site-packages/pytboss/ble.py", line 127, in reset_device
await self.connect()
File "/usr/local/lib/python3.12/site-packages/pytboss/ble.py", line 89, in connect
self._ble_client = await bleak_retry_connector.establish_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/init.py", line 387, in establish_connection
_raise_if_needed(name, device.address, exc)
File "/usr/local/lib/python3.12/site-packages/bleak_retry_connector/init.py", line 327, in _raise_if_needed
raise BleakNotFoundError(msg) from exc
bleak_retry_connector.BleakNotFoundError: PBL-98CDAC586188 - 53:5D:1C:B4:8B:8F: Failed to connect after 4 attempt(s): Timeout waiting for connect response while connecting to 53:5D:1C:B4:8B:8F after 20.0s, disconnect timed out: False, after 20.0s

Output from ESP:
INFO ESPHome 2024.6.6
INFO Reading configuration /config/esphome/esp32-bluetooth-proxy-675ed8.yaml...
INFO Starting log output from 172.16.1.236 using esphome API
INFO Successfully connected to esp32-bluetooth-proxy-675ed8 @ 172.16.1.236 in 0.010s
INFO Successful handshake with esp32-bluetooth-proxy-675ed8 @ 172.16.1.236 in 0.088s
[14:27:51][I][app:100]: ESPHome version 2024.6.6 compiled on Jul 4 2024, 11:40:11
[14:27:51][I][app:102]: Project esphome.bluetooth-proxy version 1.0
[14:27:51][C][wifi:599]: WiFi:
[14:27:51][C][wifi:427]: Local MAC: 10:06:1C:67:5E:D8
[14:27:51][C][wifi:432]: SSID: [redacted]
[14:27:51][C][wifi:435]: IP Address: 172.16.1.236
[14:27:51][C][wifi:439]: BSSID: [redacted]
[14:27:51][C][wifi:440]: Hostname: 'esp32-bluetooth-proxy-675ed8'
[14:27:51][C][wifi:442]: Signal strength: -68 dB ▂▄▆█
[14:27:51][C][wifi:446]: Channel: 1
[14:27:51][C][wifi:447]: Subnet: 255.255.255.0
[14:27:51][C][wifi:448]: Gateway: 172.16.1.1
[14:27:51][C][wifi:449]: DNS1: 172.16.1.20
[14:27:51][C][wifi:450]: DNS2: 1.1.1.1
[14:27:51][C][logger:185]: Logger:
[14:27:51][C][logger:186]: Level: DEBUG
[14:27:51][C][logger:188]: Log Baud Rate: 115200
[14:27:51][C][logger:189]: Hardware UART: UART0
[14:27:51][C][bluetooth_proxy:088]: Bluetooth Proxy:
[14:27:51][C][bluetooth_proxy:089]: Active: YES
[14:27:51][C][safe_mode.button:024]: Safe Mode Button 'Safe Mode Boot'
[14:27:51][C][safe_mode.button:024]: Icon: 'mdi:restart-alert'
[14:27:51][C][esp32_ble:383]: ESP32 BLE:
[14:27:51][C][esp32_ble:385]: MAC address: 10:06:1C:67:5E:DA
[14:27:51][C][esp32_ble:386]: IO Capability: none
[14:27:51][C][esp32_ble_tracker:653]: BLE Tracker:
[14:27:51][C][esp32_ble_tracker:654]: Scan Duration: 300 s
[14:27:51][C][esp32_ble_tracker:655]: Scan Interval: 2000.0 ms
[14:27:51][C][esp32_ble_tracker:656]: Scan Window: 1100.0 ms
[14:27:51][C][esp32_ble_tracker:657]: Scan Type: ACTIVE
[14:27:51][C][esp32_ble_tracker:658]: Continuous Scanning: True
[14:27:51][C][mdns:115]: mDNS:
[14:27:51][C][mdns:116]: Hostname: esp32-bluetooth-proxy-675ed8
[14:27:51][C][esphome.ota:073]: Over-The-Air updates:
[14:27:51][C][esphome.ota:074]: Address: esp32-bluetooth-proxy-675ed8.local:3232
[14:27:51][C][esphome.ota:075]: Version: 2
[14:27:51][C][safe_mode:018]: Safe Mode:
[14:27:51][C][safe_mode:020]: Boot considered successful after 60 seconds
[14:27:51][C][safe_mode:021]: Invoke after 10 boot attempts
[14:27:51][C][safe_mode:023]: Remain in safe mode for 300 seconds
[14:27:51][C][api:139]: API Server:
[14:27:51][C][api:140]: Address: esp32-bluetooth-proxy-675ed8.local:6053
[14:27:51][C][api:142]: Using noise encryption: YES
[14:27:51][C][improv_serial:032]: Improv Serial:

@trentsmart
Copy link

Any updates on this, I'm having the same issues. Got everything connected but all sensors are unavailable.

@TTLucian
Copy link

TTLucian commented Oct 3, 2024

Since I've flashed my ble proxies with the arduino framework, the grill connects and works fine. This integration crashes and reboots esp32 boards ble proxies flashed with the esp-idf framework.

@dknowles2
Copy link
Owner

I wish there were something more I could do here. The grill/smoker bluetooth protocol requires an active connection from HA, which is way different from how most HA bluetooth integrations work. Typically bluetooth integrations in HA assume you can read data passively through BLE advertisements, but there aren't any advertisements exported by the grills.

It's not a great protocol implemented by the PitBoss developers, IMHO: it works by spitting out a strangely encoded message on the debug logging GATT service provided by Mongoose OS. On the plus-side, that GATT service supports bluetooth subscriptions, so you can subscribe to real-time updates. But the down-side is that you can't just passively watch advertisement data and have to stay connected to the grill.

@Flameancer
Copy link
Author

Thanks for the insight. I keep checking on this to see if there is a solution and just looks like poor ble coding from pitboss. The actual app also uses WiFi. Is there a limitation in creating an implementation that uses WiFi instead.

@dknowles2
Copy link
Owner

The WiFi protocol uses AWS IoT Device Shadow which sends MQTT notifications to Amazon servers. IIRC the topics only allow one subscriber at a time, so if you open the PitBoss app at the same time it will disconnect any other connections.

It may be possible to override the MQTT server it's sending notifications to and have it instead send to a local one (i.e. one run by a HA AddOn) but then your PitBoss app will for sure stop working, and I'm not sure what else might break by doing that.

@peanutlasko
Copy link

@dknowles2 i wouldnt mind this honestly, I have other apps where I can't login using the native app (Roomba, petkit feeder, etc). If I can get it running in HA and stop using pitboss app, I think that would be fine since my goal is to have all my stuff in a singular place.

Just my 2 cents though

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

No branches or pull requests

6 participants