basnijholt / home-assistant-streamdeck-yaml

Control Home Assistant on Stream Deck with support on all operating systems and configuration via YAML
Apache License 2.0
242 stars 15 forks source link

Device needs to be unplugged and plugged back in after a crash #6

Open arborealfirecat opened 1 year ago

arborealfirecat commented 1 year ago

When the program crashes the Streamdeck needs to be unplugged and plugged back in on Linux.

The following stack trace is output on the crash, which I believe may be related:

python: os/threads_posix.h:58: usbi_mutex_destroy: Assertion `pthread_mutex_destroy(mutex) == 0' failed.
python: os/threads_posix.h:46: usbi_mutex_lock: Assertion `pthread_mutex_lock(mutex) == 0' failed.
basnijholt commented 1 year ago

Personally, I can just restart the program, and do not need to unplug anything.

I am also using systemd to automatically start the program: https://github.com/basnijholt/home-assistant-streamdeck-yaml/tree/main/systemd

arborealfirecat commented 1 year ago

I'll experiment some more over the next couple of days and see where I get to!

basnijholt commented 1 year ago

Hey, I wanted to let you know that I've recently released a new Home Assistant Supervisor add-on, which significantly simplifies the configuration process for the Stream Deck integration. It's designed to make your experience even more enjoyable and hassle-free. I invite you to check it out at https://github.com/basnijholt/home-assistant-streamdeck-yaml-addon and give it a try. Your feedback is always appreciated!

andi242 commented 1 year ago

as mentioned in the linked issue, I got the same behaviour when stopping/starting the addon in the supervisor installation. It seems that communication to the usb device is failing. Not sure what causes this, or if this can be fixed. Could be something like be that famous raspi-powerloss thing.

see log below

-----------------------------------------------------------
 Add-on: Home Assistant Stream Deck
 This add-on allows you to control your Home Assistant instance via a Stream Deck, making it easier than ever to manage your smart home devices and scenes 🏠. The add-on is highly customizable and configured using YAML files. It runs on the same machine as Home Assistant and supports Linux-based supervised Home Assistant installations. Check out the basnijholt/home-assistant-streamdeck-yaml GitHub repository (https://github.com/basnijholt/home-assistant-streamdeck-yaml) for more details. Also check out the add-on documentation (https://basnijholt.github.io/home-assistant-streamdeck-yaml-addon/) for add-on configuration details.
-----------------------------------------------------------
 Add-on version: 2023.4.15
 You are running the latest version of this add-on.
 System: Home Assistant OS 9.5  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2023.4.2
 Home Assistant Supervisor: 2023.04.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/home-assistant-streamdeck-yaml.sh
[23:35:33] INFO: 🚀 Initializing the config overwriting.
[23:35:33] INFO: 🔍 Using the host of the Supervisor as the Home Assistant host: supervisor/core with protocol ws
[23:35:33] INFO: 🔍 Using the API token of the Supervisor as the Home Assistant token
[23:35:33] INFO: 🔧 Using add-on configuration values instead of .env file
[23:35:33] INFO: 📂 Copying the Stream Deck YAML configuration file to the add-on: /config/streamdeck.yaml
[23:35:34] INFO: ✅ Finished the config overwriting.
cont-init: info: /etc/cont-init.d/home-assistant-streamdeck-yaml.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant-streamdeck-yaml (no readiness notification)
s6-rc: info: service legacy-services successfully started
[23:35:34] INFO: Starting home-assistant-streamdeck-yaml...
[23:35:35] Using version 2023.4.15 of the home_assistant_streamdeck_yaml.py:1665
           Home Assistant Stream Deck.
           Starting Stream Deck           home_assistant_streamdeck_yaml.py:1666
           integration with
           args.host='supervisor/core',
           args.config=PosixPath('/config
           /streamdeck.yaml'),
           args.protocol='ws'
Traceback (most recent call last):
  File "/usr/local/bin/home-assistant-streamdeck-yaml", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/app/home_assistant_streamdeck_yaml.py", line 1670, in main
    asyncio.run(
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/app/home_assistant_streamdeck_yaml.py", line 1608, in run
    deck = get_deck()
           ^^^^^^^^^^
  File "/app/home_assistant_streamdeck_yaml.py", line 1253, in get_deck
    deck.reset()
  File "/usr/local/lib/python3.11/site-packages/StreamDeck/Devices/StreamDeckOriginalV2.py", line 92, in reset
    self.device.write_feature(payload)
  File "/usr/local/lib/python3.11/site-packages/StreamDeck/Transport/LibUSBHIDAPI.py", line 430, in write_feature
    return self.hidapi.send_feature_report(self.device_handle, payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/StreamDeck/Transport/LibUSBHIDAPI.py", line 217, in send_feature_report
    raise TransportError("Failed to write feature report (%d)" % result)
StreamDeck.Transport.Transport.TransportError: Failed to write feature report (-1)