dknowles2 / ha-pitboss

Home Assistant Custom Integration for PitBoss smokers and grills
MIT License
33 stars 4 forks source link

HA 2024.10.0 errors and crashes #63

Closed TTLucian closed 1 month ago

TTLucian commented 1 month ago

System Health details

?

Checklist

Describe the issue

As soon as I power up the grill HA 2024.10.0 errors and crashes. Yesterday it was working fine. Today, after upgrading HA to 2024.10.0, it errors and crashes home assistant in a loop. Had to hard reset the vm and unplug all the ble proxies in order to get HA to start. And then disable the PitBoss integration altogether!

Reproduction steps

1. 2. 3. ...

Debug logs

Logger: homeassistant.util.loop
Source: util/loop.py:136
First occurred: 21:30:36 (2 occurrences)
Last logged: 21:30:36

Detected blocking call to read_text with args (PosixPath('/usr/local/lib/python3.12/site-packages/pytboss/grills.json'),) inside the event loop by custom integration 'pitboss' at custom_components/pitboss/coordinator.py, line 41: self.grill_spec = get_grill(model) (offender: /usr/local/lib/python3.12/site-packages/pytboss/grills.py, line 295: grills_json = resources.files(__package__).joinpath("grills.json").read_text()), please create a bug report at https://github.com/dknowles2/ha-pitboss/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#read_text Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 461, in _async_setup_component await asyncio.gather( File "/usr/src/homeassistant/homeassistant/setup.py", line 463, in <genexpr> create_eager_task( File "/usr/src/homeassistant/homeassistant/util/async_.py", line 45, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 742, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/pitboss/__init__.py", line 36, in async_setup_entry coordinator = hass.data[DOMAIN][entry.entry_id] = PitBossDataUpdateCoordinator( File "/config/custom_components/pitboss/coordinator.py", line 41, in __init__ self.grill_spec = get_grill(model)
Detected blocking call to open with args (PosixPath('/usr/local/lib/python3.12/site-packages/pytboss/grills.json'),) inside the event loop by custom integration 'pitboss' at custom_components/pitboss/coordinator.py, line 41: self.grill_spec = get_grill(model) (offender: /usr/local/lib/python3.12/pathlib.py, line 1027: with self.open(mode='r', encoding=encoding, errors=errors) as f:), please create a bug report at https://github.com/dknowles2/ha-pitboss/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 461, in _async_setup_component await asyncio.gather( File "/usr/src/homeassistant/homeassistant/setup.py", line 463, in <genexpr> create_eager_task( File "/usr/src/homeassistant/homeassistant/util/async_.py", line 45, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 742, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/pitboss/__init__.py", line 36, in async_setup_entry coordinator = hass.data[DOMAIN][entry.entry_id] = PitBossDataUpdateCoordinator( File "/config/custom_components/pitboss/coordinator.py", line 41, in __init__ self.grill_spec = get_grill(model)

2024-10-03 21:32:55.424 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140193533244272] Lucian Tudora from 192.168.1.15 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0): Client unable to keep up with pending messages. Reached 4096 pending messages. The system's load is too high or an integration is misbehaving; Last message was: b'{"type":"event","event":{"c":{"sensor.grill_probe_4":{"+":{"lu":1727980375.424651,"c":"01J99TG3C0Z5YZMME94D77XG5Q","a":{"restored":true,"icon":"mdi:thermometer","friendly_name":"Probe 4","supported_features":0}}}}},"id":2}'
2024-10-03 21:32:55.425 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140192553800688] Lucian Tudora from 192.168.1.1 (Mozilla/5.0 (Linux; Android 14; RMX2202 Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/128.0.6613.146 Mobile Safari/537.36 Home Assistant/2024.9.4-13806 (Android 14; RMX2202)): Client unable to keep up with pending messages. Reached 4096 pending messages. The system's load is too high or an integration is misbehaving; Last message was: b'{"type":"event","event":{"c":{"sensor.grill_probe_4":{"+":{"lu":1727980375.424651,"c":"01J99TG3C0Z5YZMME94D77XG5Q","a":{"restored":true,"icon":"mdi:thermometer","friendly_name":"Probe 4","supported_features":0}}}}},"id":3}'

2024-10-03 21:49:47.275 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140599896196864] Lucian Tudora from 192.168.1.1 (Mozilla/5.0 (Linux; Android 14; RMX2202 Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/128.0.6613.146 Mobile Safari/537.36 Home Assistant/2024.9.4-13806 (Android 14; RMX2202)): Client unable to keep up with pending messages. Reached 4096 pending messages. The system's load is too high or an integration is misbehaving; Last message was: b'{"type":"event","event":{"c":{"sensor.grill_probe_2":{"+":{"lu":1727981387.275635,"c":"01J99VEZGBFX9FJN5YK2GVEH97","a":{"restored":true,"icon":"mdi:thermometer","friendly_name":"Probe 2","supported_features":0}}}}},"id":3}'
2024-10-03 21:49:47.278 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140600903658384] Lucian Tudora from 192.168.1.15 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0): Client unable to keep up with pending messages. Reached 4096 pending messages. The system's load is too high or an integration is misbehaving; Last message was: b'{"type":"event","event":{"c":{"switch.grill_module_power":{"+":{"lu":1727981387.2787175,"c":"01J99VEZGET1BWK81TM5VR3AVW","a":{"restored":true,"friendly_name":"Module power","supported_features":0}},"-":{"a":["icon","assumed_state"]}}}},"id":2}'
2024-10-03 21:49:47.280 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140600211836784] Lucian Tudora from 192.168.1.1 (Mozilla/5.0 (Linux; Android 14; RMX2202 Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/128.0.6613.146 Mobile Safari/537.36 Home Assistant/2024.9.4-13806 (Android 14; RMX2202)): Client unable to keep up with pending messages. Reached 4096 pending messages. The system's load is too high or an integration is misbehaving; Last message was: b'{"type":"event","event":{"c":{"switch.grill_module_power":{"+":{"lu":1727981387.2787175,"c":"01J99VEZGET1BWK81TM5VR3AVW","a":{"restored":true,"friendly_name":"Module power","supported_features":0}},"-":{"a":["icon","assumed_state"]}}}},"id":3}'

Diagnostics dump

No response

JShoota commented 1 month ago

Same here. I couldn't actually complete the upgrade until I disabled this integration. I'm happy to post logs or test.

rsabol77 commented 1 month ago

If I update my proxy wirelessly I loose mine every time. If I update plugged in it’s good to go.

DRuggeri commented 1 month ago

Same situation here. I'm installed via container and HASS goes into an infinite loop on startup with:

2024-10-04 06:00:47.066 INFO (MainThread) [homeassistant.components.sensor] Setting up pitboss.sensor
2024-10-04 06:00:47.066 INFO (MainThread) [homeassistant.components.switch] Setting up pitboss.switch
2024-10-04 06:00:47.117 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up pitboss.binary_sensor
2024-10-04 06:00:47.119 INFO (MainThread) [homeassistant.components.climate] Setting up pitboss.climate

Because it never completes, HASS itself never comes up (I guess it must complete setup of all entities before it continues to start the UI/broker/etc)

DRuggeri commented 1 month ago

FYI: This continues to happen with the 2024.10.1 update

I grabbed some more information. After startup, the integration seemed to load up fine. About 7.5 seconds later, the same grill with a different address is found. It attempts to set up the sensors/etc, but then goes into the infinite loop.

I was looking through the code. I don't know enough about BLE and connections w/ BLE, but it seems strange that the same grill would appear again with a different address. I have a spare ESP32 sitting around so I set it up to log BLE advertisements. So far it seems to be pretty stable in detecting the same "PBL-64B70811A7F0"... but at different addresses. So I guess it's normal that the BLE address will change, but in the log output below it seemed to be some kind of a trigger for the infinite loop

2024-10-05 16:39:40.105 INFO (MainThread) [custom_components.pitboss] Found PitBoss smoker: PBL-64B70811A7F0 @ 76:51:8D:0C:32:D2
2024-10-05 16:39:40.112 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to read_text with args (PosixPath('/usr/local/lib/python3.12/site-packages/pytboss/grills.json'),) inside the event loop by custom integration 'pitboss' at custom_components/pitboss/config_flow.py, line 58: models = [g.name for g in grills.get_grills(control_board=control_board)] (offender: /usr/local/lib/python3.12/site-packages/pytboss/grills.py, line 295: grills_json = resources.files(__package__).joinpath("grills.json").read_text()), please create a bug report at https://github.com/dknowles2/ha-pitboss/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#read_text
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 112, in sem_task
    return await task
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1287, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1322, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 520, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
  File "/config/custom_components/pitboss/config_flow.py", line 36, in async_step_bluetooth
    return await self.async_step_user()
  File "/config/custom_components/pitboss/config_flow.py", line 58, in async_step_user
    models = [g.name for g in grills.get_grills(control_board=control_board)]

2024-10-05 16:39:40.117 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args (PosixPath('/usr/local/lib/python3.12/site-packages/pytboss/grills.json'),) inside the event loop by custom integration 'pitboss' at custom_components/pitboss/config_flow.py, line 58: models = [g.name for g in grills.get_grills(control_board=control_board)] (offender: /usr/local/lib/python3.12/pathlib.py, line 1027: with self.open(mode='r', encoding=encoding, errors=errors) as f:), please create a bug report at https://github.com/dknowles2/ha-pitboss/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 112, in sem_task
    return await task
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1287, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1322, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 520, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
  File "/config/custom_components/pitboss/config_flow.py", line 36, in async_step_bluetooth
    return await self.async_step_user()
  File "/config/custom_components/pitboss/config_flow.py", line 58, in async_step_user
    models = [g.name for g in grills.get_grills(control_board=control_board)]
2024-10-05 16:41:28.456 INFO (MainThread) [homeassistant.setup] Setting up pitboss
2024-10-05 16:41:28.498 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up pitboss.binary_sensor
2024-10-05 16:41:28.500 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_probe_1_error
2024-10-05 16:41:28.517 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_probe_2_error
2024-10-05 16:41:28.528 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_probe_3_error
2024-10-05 16:41:28.543 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_startup_error
2024-10-05 16:41:28.549 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_high_temperature_error
2024-10-05 16:41:28.554 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_fan_error
2024-10-05 16:41:28.560 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_igniter_error
2024-10-05 16:41:28.564 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_auger_error
2024-10-05 16:41:28.576 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_no_pellets
2024-10-05 16:41:28.580 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.pitboss entity: binary_sensor.pbl_64b70811a7f0_auger
2024-10-05 16:41:28.584 INFO (MainThread) [homeassistant.components.climate] Setting up pitboss.climate
2024-10-05 16:41:28.587 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new climate.pitboss entity: climate.pbl_64b70811a7f0_grill_temperature
2024-10-05 16:41:28.596 INFO (MainThread) [homeassistant.components.light] Setting up pitboss.light
2024-10-05 16:41:28.597 INFO (MainThread) [homeassistant.components.sensor] Setting up pitboss.sensor
2024-10-05 16:41:28.598 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.pitboss entity: sensor.pbl_64b70811a7f0_probe_1
2024-10-05 16:41:28.630 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.pitboss entity: sensor.pbl_64b70811a7f0_probe_2
2024-10-05 16:41:28.644 INFO (MainThread) [homeassistant.components.switch] Setting up pitboss.switch
2024-10-05 16:41:28.645 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new switch.pitboss entity: switch.pbl_64b70811a7f0_module_power
2024-10-05 16:41:28.652 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new switch.pitboss entity: switch.pbl_64b70811a7f0_prime
2024-10-05 16:42:35.221 INFO (MainThread) [custom_components.pitboss] Found PitBoss smoker: PBL-64B70811A7F0 @ 43:1A:7B:4A:8B:D6
2024-10-05 16:42:35.433 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up pitboss.binary_sensor
2024-10-05 16:42:35.496 INFO (MainThread) [homeassistant.components.climate] Setting up pitboss.climate
2024-10-05 16:42:35.497 INFO (MainThread) [homeassistant.components.light] Setting up pitboss.light
2024-10-05 16:42:35.497 INFO (MainThread) [homeassistant.components.sensor] Setting up pitboss.sensor
2024-10-05 16:42:35.498 INFO (MainThread) [homeassistant.components.switch] Setting up pitboss.switch
<repeats the last four lines forever>
DRuggeri commented 1 month ago

FWIW: The only bluetooth related change advertised in the 2024.10.0 chagelog was this one: https://github.com/home-assistant/core/pull/126555

Maybe related if the pitboss is changing its advertising address?

osokthedevil commented 1 month ago

024-10-06 19:44:31.591 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args (PosixPath('/usr/local/lib/python3.12/site-packages/pytboss/grills.json'),) inside the event loop by custom integration 'pitboss' at custom_components/pitboss/coordinator.py, line 41: self.grill_spec = get_grill(model) (offender: /usr/local/lib/python3.12/pathlib.py, line 1027: with self.open(mode='r', encoding=encoding, errors=errors) as f:), please create a bug report at https://github.com/dknowles2/ha-pitboss/issues

jacobwtyler commented 1 month ago

Same issue here. Caused my HA to crash after a few minutes due to memory leak. Disabled integration and fixed the issue.

osokthedevil commented 1 month ago

I guess I'll disable it for the time being until he updates the integration so it doesn't crash. Maybe my 2024.10.1 update will take without crashing.

osokthedevil commented 1 month ago

update, after disabling it, update took etc. stable so please fix @dknowles2 please fix the integration thank. Ill buy you a coffee of 10 of them! you have my word.

dknowles2 commented 1 month ago

Sorry, I've been busy with other stuff. I'll try and take a closer look tonight. Of note: the warning about the blocking call almost certainly unrelated.

osokthedevil commented 1 month ago

Thanks

osokthedevil commented 1 month ago

Also setup by me a coffee account/link so we can buy ypu a coffee

DRuggeri commented 1 month ago

Thanks, @dknowles2 - I think we have the same grill (according to docs), but if you're unable to reproduce or need a tester, just shout.

dknowles2 commented 1 month ago

I pushed a new 2024.10.0 version which I think will fix the problem (as well as the warning about the blocking call on the event loop).

Please re-open if it doesn't fix things: when working on a fix, a typo in my repro code inadvertently cleared whatever was triggering the infinite loop and let it complete the upgrade to HA 2024.10. I'm fairly confident that #65 fixes the bug, but my local development instance can't reproduce the bug anymore. 😵‍💫

osokthedevil commented 1 month ago

Thanks you

TTLucian commented 1 month ago

Heey! It's alive again! Thanks so much! 😅 Screenshot_2024-10-09-04-51-26-07_c3a231c25ed346e59462e84656a70e50