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

hcitool not working #314

Closed
marcinbauer85 opened this issue Oct 25, 2020 · 41 comments
Closed

hcitool not working #314

marcinbauer85 opened this issue Oct 25, 2020 · 41 comments
Labels

Comments

@marcinbauer85
Copy link

Describe the bug
Can't get any reading from BTC:
10/25/2020, 11:18:10 AM - error - BluetoothClassicService: Command failed: hcitool -i hci0 cc "88:63:DF:8A:1B:DC" && hcitool -i hci0 rssi "88:63:DF:8A:1B:DC"

To reproduce
Installed on latest HassOS 4.15, on a RPI 3B+

Relevant logs

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[11:23:18] INFO: Setting up Home Assistant configuration
[11:23:19] INFO: Starting room-assistant
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
10/25/2020, 11:23:26 AM - info - IntegrationsModule: Loading integrations: home-assistant, bluetooth-classic, bluetooth-low-energy
10/25/2020, 11:23:29 AM - info - NestFactory: Starting Nest application...
10/25/2020, 11:23:29 AM - info - InstanceLoader: AppModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: ConfigModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: NestEmitterModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: IntegrationsModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: HttpModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: DiscoveryModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: ClusterModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: TerminusModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: ScheduleModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: EntitiesModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: BluetoothLowEnergyModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: HomeAssistantModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: BluetoothClassicModule dependencies initialized
10/25/2020, 11:23:29 AM - info - InstanceLoader: StatusModule dependencies initialized
10/25/2020, 11:23:30 AM - info - RoutesResolver: EntitiesController {/entities}:
10/25/2020, 11:23:30 AM - info - RouterExplorer: Mapped {/entities, GET} route
10/25/2020, 11:23:30 AM - info - RoutesResolver: StatusController {/status}:
10/25/2020, 11:23:30 AM - info - RouterExplorer: Mapped {/status, GET} route
10/25/2020, 11:23:30 AM - warn - BluetoothLowEnergyService: The whitelist and blacklist are empty, no sensors will be created! Please add some of the discovered IDs below to your configuration.
10/25/2020, 11:23:33 AM - info - HomeAssistantService: Successfully connected to MQTT broker at mqtt://192.168.1.22:1883
10/25/2020, 11:23:33 AM - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/default.json, config/local.json
10/25/2020, 11:23:33 AM - info - ClusterService: Starting mDNS advertisements and discovery
10/25/2020, 11:23:33 AM - info - NestApplication: Nest application successfully started
10/25/2020, 11:23:39 AM - error - BluetoothClassicService: Command failed: hcitool -i hci0 cc "64:a2:f9:f1:b8:7b" && hcitool -i hci0 rssi "64:a2:f9:f1:b8:7b"
Invalid device: Network is down
10/25/2020, 11:23:45 AM - error - BluetoothClassicService: Command failed: hcitool -i hci0 cc "88:63:DF:8A:1B:DC" && hcitool -i hci0 rssi "88:63:DF:8A:1B:DC"
Invalid device: Network is down

Relevant configuration

  instanceName: Hassio
  integrations:
    - homeAssistant
    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://192.168.1.22:1883'
  mqttOptions:
    username: secret
    password: secret
bluetoothClassic:
  minRssi: -20
  addresses:
    - '64:a2:f9:f1:b8:7b'
    - '88:63:DF:8A:1B:DC'

Expected behavior
Get reading of the BTC RSSI

Environment

  • room-assistant version: 2.10.1
  • installation type: HassOS
  • hardware: RPI 3B+
  • OS: HassOS
@mKeRix
Copy link
Owner

mKeRix commented Oct 25, 2020

The logs mention the BluetoothLowEnergyService, although your configuration does not - is it possible that you had both bluetoothLowEnergy and bluetoothClassic enabled at the same time? This might cause issues in any version below (v2.11.0 - released today!). Would be awesome if you could double check this and also check if the issue persists after an update of the add-on.

@marcinbauer85
Copy link
Author

marcinbauer85 commented Oct 26, 2020

Yes sorry for that, my config had also - bluetoothLowEnergy. But this doesn't change anything, still have errors:
Config:

global:
  instanceName: Hassio
  integrations:
    - homeAssistant
    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://192.168.1.22:1883'
  mqttOptions:
    username: secret
    password: secret
bluetoothClassic:
  minRssi: -20
  addresses:
    - '64:a2:f9:f1:b8:7b'
    - '88:63:DF:8A:1B:DC'

Logs

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[09:05:02] INFO: Setting up Home Assistant configuration
[09:05:03] INFO: Starting room-assistant
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
10/26/2020, 9:05:10 AM - info - IntegrationsModule: Loading integrations: home-assistant, bluetooth-classic
10/26/2020, 9:05:12 AM - info - NestFactory: Starting Nest application...
10/26/2020, 9:05:13 AM - info - InstanceLoader: AppModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: ConfigModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: NestEmitterModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: IntegrationsModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: HttpModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: DiscoveryModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: ClusterModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: TerminusModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: BluetoothModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: ScheduleModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: EntitiesModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: HomeAssistantModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: BluetoothClassicModule dependencies initialized
10/26/2020, 9:05:13 AM - info - InstanceLoader: StatusModule dependencies initialized
10/26/2020, 9:05:14 AM - info - RoutesResolver: EntitiesController {/entities}:
10/26/2020, 9:05:14 AM - info - RouterExplorer: Mapped {/entities, GET} route
10/26/2020, 9:05:14 AM - info - RoutesResolver: StatusController {/status}:
10/26/2020, 9:05:14 AM - info - RouterExplorer: Mapped {/status, GET} route
10/26/2020, 9:05:16 AM - info - HomeAssistantService: Successfully connected to MQTT broker at mqtt://192.168.1.22:1883
10/26/2020, 9:05:16 AM - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/default.json, config/local.json
10/26/2020, 9:05:16 AM - info - ClusterService: Starting mDNS advertisements and discovery
10/26/2020, 9:05:16 AM - info - NestApplication: Nest application successfully started
10/26/2020, 9:05:22 AM - error - BluetoothService: Command failed: hcitool -i hci0 cc "64:a2:f9:f1:b8:7b" && hcitool -i hci0 rssi "64:a2:f9:f1:b8:7b"
Invalid device: Network is down
10/26/2020, 9:05:28 AM - error - BluetoothService: Command failed: hcitool -i hci0 cc "88:63:DF:8A:1B:DC" && hcitool -i hci0 rssi "88:63:DF:8A:1B:DC"
Invalid device: Network is down

@Veldkornet
Copy link

I'm having the same problem, after it initially working just fine

@gadric
Copy link

gadric commented Oct 26, 2020

Same issue here. The previous version did not have the problem.

@mKeRix
Copy link
Owner

mKeRix commented Oct 26, 2020

Do you all still see the issue after completely restarting your machine (e.g. Raspberry Pi)? If so, could you use the SSH add-on to type this into the terminal:

bluetoothctl
list
show <insert-adapter-from-previous-command>

@gadric
Copy link

gadric commented Oct 26, 2020

Yes I have this problem also after reboot. I did this a couple of times and although sometimes it works after reboot for 1 hours or so, it false again the adpater crashes.

The output of the command sequence:

[bluetooth]# show xx:yy:zz:aa:bb:cc
Controller xx:yy:zz:aa:bb:cc (public)
        Name: computername.domain
        Alias: computername.domain
        Class: 0x000c0104
        Powered: yes
        Discoverable: no
        Pairable: yes
        UUID: Headset AG                (00001112-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: Generic Attribute Profile (00001801-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: A/V Remote Control        (0000110e-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: Generic Access Profile    (00001800-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: PnP Information           (00001200-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: A/V Remote Control Target (0000110c-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: Audio Sink                (0000110b-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: Audio Source              (0000110a-xxxx-yyyy-zzzz-somerandomnumbers)
        UUID: Headset                   (00001108-xxxx-yyyy-zzzz-somerandomnumbers)
        Modalias: usb:v1D6Bx0246xxxx
        Discovering: no

This output was generated while it was working ...

@marcinbauer85
Copy link
Author

It started to work, altough I think Im missing configuration now. Confis same as above, version: latest

[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[19:13:31] INFO: Setting up Home Assistant configuration
[19:13:31] INFO: Starting room-assistant
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
10/26/2020, 7:13:38 PM - info - IntegrationsModule: Loading integrations: home-assistant, bluetooth-classic
10/26/2020, 7:13:41 PM - info - NestFactory: Starting Nest application...
10/26/2020, 7:13:41 PM - info - InstanceLoader: AppModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: ConfigModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: NestEmitterModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: IntegrationsModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: HttpModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: DiscoveryModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: ClusterModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: TerminusModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: BluetoothModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: ScheduleModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: EntitiesModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: HomeAssistantModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: BluetoothClassicModule dependencies initialized
10/26/2020, 7:13:41 PM - info - InstanceLoader: StatusModule dependencies initialized
10/26/2020, 7:13:42 PM - info - RoutesResolver: EntitiesController {/entities}:
10/26/2020, 7:13:42 PM - info - RouterExplorer: Mapped {/entities, GET} route
10/26/2020, 7:13:43 PM - info - RoutesResolver: StatusController {/status}:
10/26/2020, 7:13:43 PM - info - RouterExplorer: Mapped {/status, GET} route
10/26/2020, 7:13:45 PM - info - HomeAssistantService: Successfully connected to MQTT broker at mqtt://192.168.1.22:1883
10/26/2020, 7:13:45 PM - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/default.json, config/local.json
10/26/2020, 7:13:45 PM - info - ClusterService: Starting mDNS advertisements and discovery
10/26/2020, 7:13:45 PM - info - NestApplication: Nest application successfully started
10/26/2020, 7:13:52 PM - info - **HomeAssistantService: Device tracker requires manual setup in Home Assistant with topic: room-assistant/device_tracker/bluetooth-classic-64-a2-f9-f1-b8-7b-tracker/state**
10/26/2020, 7:13:58 PM - info - **HomeAssistantService: Device tracker requires manual setup in Home Assistant with topic: room-assistant/device_tracker/bluetooth-classic-88-63-df-8a-1b-dc-tracker/state**```

How to fix this?

@gadric
Copy link

gadric commented Oct 26, 2020

Maybe one thing to add:

this seems to be a problem with the Home Assistant Addon. I have two other instances running on RPi0 and RPi4 and both do not have this problem.

Only the addon version on my Home Assistant showing this problem.

@Veldkornet
Copy link

Veldkornet commented Oct 26, 2020

Mine works after rebooting the host indeed. Unfortunately I didn't output of the commands when it was not working, but I saw for example the name and alias were not listed, also it said powered: no
For me this is also on the HomeAssistant addon, on a RPi4 64-bit

@mKeRix
Copy link
Owner

mKeRix commented Oct 26, 2020

@gadric @Veldkornet Thanks! I'm not quite sure what would cause the adapter to crash, but maybe it would already be a good start if room-assistant would try to recover that situation. This stuff can get really complicated since it goes down to system level, but is also packaged away in a different runtime on Hass.io.

@marcinbauer85 That is just a hint that Home Assistant does not support auto discovery of device trackers and they need to be configured manually like shown here if you need them. So nothing to worry about!

@gadric
Copy link

gadric commented Oct 26, 2020

Hmm, yes .. I guess so.

However, I tried several things, after it crashed:

  • hcitool dev: shows no device
  • hciconfig hci0 reset: no help
  • hciconfig hci0 up: no help
  • rfkill unblock bluetooth: no help

The only thing worked was reboot.

What I find interesting is that this problem did not occured with the old version ...

Btw.: I am running my Home Assistant on an Intel NUC10.

@mKeRix
Copy link
Owner

mKeRix commented Oct 26, 2020

@gadric In that case scratch my original idea, if those command did not help I can't think of something else. Thanks for letting me know, saved me some time.

At the moment it feels like between v2.10.0 and v2.11.0 something in the system dependencies of the Docker image updated and now causes these issues. Will have to dig a bit deeper though.

@gadric
Copy link

gadric commented Oct 26, 2020

Sure, let me know if I can be of assistance ...

@mKeRix
Copy link
Owner

mKeRix commented Oct 26, 2020

Are you all running on HassOS 4.15? Looking at their repo there were some (seemingly minor) Bluetooth changes recently. I would be interested to see if this change is really caused by the add-on update or the OS update. Would be cool if someone could try to downgrade the OS to 4.13 with ha os update --version "4.13" via SSH and then see if this issue still persists.

I double checked the Bluetooth packages used by the add-on - those have not changed at all in-between the versions as far as I can see in the GitHub build log.

@gadric
Copy link

gadric commented Oct 26, 2020

So I have the error again:

Running your suggested 3 commands I got:

Controller aa:bb:cc:dd (public)
        Name: name
        Alias: name
        Class: 0x00000000
        Powered: no
        Discoverable: no
        Pairable: yes
        UUID: Headset AG                (00001112-0000-xxxx)
        UUID: Generic Attribute Profile (00001801-0000-xxxx)
        UUID: A/V Remote Control        (0000110e-0000-xxxx)
        UUID: Generic Access Profile    (00001800-0000-xxxx)
        UUID: PnP Information           (00001200-0000-xxxx)
        UUID: A/V Remote Control Target (0000110c-0000-xxxx)
        UUID: Audio Sink                (0000110b-0000-xxxx)
        UUID: Audio Source              (0000110a-0000-xxxx)
        UUID: Headset                   (00001108-0000-xxxx)
        Modalias: usb:v1D6Bpxxxxxxxx
        Discovering: no

@gadric
Copy link

gadric commented Oct 26, 2020

I am just testing something else ...

Does it make sense that PowerTOP or Auto Suspend features makes trouble? I have PowerTOP always activated and until now, not problems.

But after the last issues, I deactivated PowerTOP and rebooted. Until now, the bluetooth adapter seems to work ...

@mKeRix
Copy link
Owner

mKeRix commented Oct 26, 2020

I can't think of a reason why it would cause these issues, but at the same time I'm not really familiar with that tool. So no clue 🤷‍♂️

@gadric
Copy link

gadric commented Oct 27, 2020

Yes you are right. It crashed again

@Veldkornet
Copy link

Yes you are right. It crashed again

Same here 😭

@mKeRix
Copy link
Owner

mKeRix commented Oct 27, 2020

I don't think Home Assistant has functionality for downgrading an add-on yet, but you could do this manually in the mean time if you want. Download and copy exactly this folder into your /addons folder on your Home Assistant instance. The version in config.json should be 2.10.0. After going to the add-on store page in Home Assistant and hitting the three dots > Reload it should show up as a new add-on under "Local add-ons". If you stop the other room-assistant add-on, copy the config over the start this one it should work just like before but on the older version. It will pull the old image from DockerHub, so the conditions should be exactly the same.

If you end up doing this it would be awesome if you could give status updates if it works or doesn't work.

@gadric
Copy link

gadric commented Oct 27, 2020

@mKeRix funny thing:

today in the morning I have upgrade to 2.11.1 on all boxes. Until now it is working. However, currently there is only one Phone at home which room assistant is tracking. I am not sure if this has an impact.

Do you think this could be the source of the issue?

I can test to down upgrade the addon today evening when I got home.

@Veldkornet
Copy link

FYI, I noticed that when the Bluetooth crashes, if I restart my zwave add-on, it can't connect to the USB dongle either.

I've only been using the room-assistant add-on for the past day or so, and it wasn't happening before (the USB dongles being unavailable). So I'm thinking what ever is causing the Bluetooth to crash, crashes the others too. Why it crashes is of course the question... Seems like if it's not used though (the Bluetooth) everything stays running (that's an assumption since this issue is new to me).

@Veldkornet
Copy link

FYI, the bluetooth update in HassOS 4.15 was to upgrade RPi bluez-firmware to 1.2-4+rpt6.
I checked on my other Raspberries which are in the cluster, and they are all running the same version without problem.

@mKeRix
Copy link
Owner

mKeRix commented Oct 27, 2020

@gadric 2.11.1 generated a fresher image, so if there was something wrong in the build cache it's possible that this fixed it. The code change itself should mostly make a difference for setups that run BT Classic and BLE on the same adapter, that code doesn't really do anything that should crash the adapter regardless. If 2.11.1 fixed the issue for you then there is no need to downgrade I'd say. Keep us updated!

@Veldkornet Thanks for checking this. The USB issue is interesting... that's something I don't understand at all.

@gadric
Copy link

gadric commented Oct 27, 2020

I have been home for more than 1 hour and it still works. I will report tomorrow in the morning if it is still working. If yes, I guess then the update has fixed the problem.

@Veldkornet
Copy link

Still buggered for me, even after the last update.

@gadric
Copy link

gadric commented Oct 27, 2020

My Bluetooth device has not crashed until now. But I got the following error on my Home Assistant Add-On:

(node:187) UnhandledPromiseRejectionWarning: Error: Trying to lock adapter 0 even though it is already locked
    at BluetoothService.lockAdapter (/usr/lib/node_modules/room-assistant/dist/integrations/bluetooth/bluetooth.service.js:107:23)
    at BluetoothService.inquireClassicRssi (/usr/lib/node_modules/room-assistant/dist/integrations/bluetooth/bluetooth.service.js:41:20)
    at BluetoothClassicService.handleRssiRequest (/usr/lib/node_modules/room-assistant/dist/integrations/bluetooth-classic/bluetooth-classic.service.js:92:52)
    at ClusterService.emit (events.js:315:20)
    at ClusterService.processEvent (/usr/lib/node_modules/room-assistant/node_modules/democracy/lib/democracy.js:372:12)
    at ClusterService.processEvent (/usr/lib/node_modules/room-assistant/dist/cluster/cluster.service.js:121:15)
    at Socket.<anonymous> (/usr/lib/node_modules/room-assistant/node_modules/democracy/lib/democracy.js:73:14)
    at Socket.emit (events.js:315:20)
    at UDP.onMessage [as onmessage] (dgram.js:910:8)
(node:187) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:187) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@mKeRix
Copy link
Owner

mKeRix commented Oct 27, 2020

@gadric That error will be handled better in a future version, in this version it's just a stopgap to prevent multiple queries from being executed in parallel.

@Veldkornet
Copy link

FYI, I discovered that I can get it working again by issuing the following command in HassOS:

bluetoothctl power on

Quicker than rebooting anyway...

@gadric
Copy link

gadric commented Oct 28, 2020

@mKeRix: ok thank you

Room Asssitant 2.11.1 has been running through the whole night with 3 devides tracking. It has been not crashing anything. I guess this error is fixed

@Veldkornet: that is interesting. I know when my BT crashed i was not able to power it up with hcitool hci0 up

@gadric
Copy link

gadric commented Oct 28, 2020

OK, I think this set up is working for me at least. The add-on has been running since yesterday and also with the newest version is working without crashing. This works also with different devices arriving and leaving.

What I have done yesterday to make this work:

  1. Reboot
  2. Update to version 2.11.0
  3. Reboot
  4. Update all other devices in the cluster to version 2.11.0
  5. Reboot them all

Since then it is working without any issues.

My config:

global:
  cluster:
    autoDiscovery: false
    port: 6425
    peerAddresses:
      - '192.168.xx.xx:6425'
      - '192.168.xx.yy:6425'
  instanceName: somename
  integrations:
    - homeAssistant
    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtts://xxx.xxx.xxx.xxx:8883'
  mqttOptions:
    username: user
    password: pass
    rejectUnauthorized: false
bluetoothClassic:
  hciDeviceId: 0
  interval: 15
  scanTimeLimit: 10
  timeoutCycles: 5
  minRssi: -30
  addresses:
    - 'address1'
    - 'address2'
    - 'address3'

@ryanlocey
Copy link

i used the bluetoothctl power on in HassOS as described above and that fixed the issue for me

@embcla
Copy link

embcla commented Oct 31, 2020

I've got this issue on my very unorthodox system, so I'm assuming it's not the fault of either room-assistant or home-assistant.

What I did to fix this is I created a script '/usr/bin/check_bluetooth.sh' with this code in it

#!/bin/bash

echo "Checking health of bluetooth interface" | systemd-cat -t "BT Check Script"
thisran=0
while [ "$(hciconfig hci0 | grep -i 'running' &>/dev/null; echo $?)" != 0 ]
do
	echo "Found bluetooth interface down, attempting to re-enable" | systemd-cat -t "BT Check Script"
	hciconfig hci0 up
	sleep 1
	thisran=1
done
if [ $thisran -gt 0 ]; then
	echo "Bluetooth interface correctly re-enabled, terminating" | systemd-cat -t "BT Check Script"
else
	echo "Bluetooth interface running correctly, terminating" | systemd-cat -t "BT Check Script"
fi

then added this in crontab from user root and execute it every 5 minutes.
What is does is it checks the BT networking, if it's up then it just quits, if it's down it attempts to reset it.
Admittedly this is a weak fix: if anything goes wrong, this gets stuck in a loopy-loop forever so take it with a grain of salt.

@mKeRix worth thinking about doing something similar on your side if you get a network down?

@mKeRix
Copy link
Owner

mKeRix commented Oct 31, 2020

Something like this was actually one of my initial ideas, I just shelved it again since somewhere earlier in this thread someone tested the commands and reported back that they didn't work to fix this specific issue. Might still be worth it to integrate this for better error handling though.

@gadric
Copy link

gadric commented Nov 2, 2020

After installing the lastest version 2.11.3 this problem appears again. @mKeRix: could some of the compiling went wrong again?

Btw.: both hciconfig hci0 up and bluetoothctl power on does not work to start my BT adapter.

@mKeRix
Copy link
Owner

mKeRix commented Nov 2, 2020

The add-on build looks clean and ok to me. Maybe it could help if you could add information to home-assistant/operating-system#940 by posting the relevant dmesg info, as that would give them experts over there a more detailed look at things.

@gadric
Copy link

gadric commented Nov 2, 2020

I got this working again.

I have a guess, what is the problem: the start order of the docker containers may cause this problem. It seems that sometimes the add on container starts earlier than the Home Assistant, then it leads to crash after some time.

@mKeRix
Copy link
Owner

mKeRix commented Nov 2, 2020

@gadric Hm, the add-on configuration specifies it as an application, which according to the Home Assistant docs should mean that it always starts after Home Assistant.

@mKeRix
Copy link
Owner

mKeRix commented Nov 6, 2020

Since the linked issue in the Home Assistant OS repo was just closed as fixed I will close this issue here as well.

@mKeRix mKeRix closed this as completed Nov 6, 2020
@gadric
Copy link

gadric commented Nov 11, 2020

FYI: I think I have identified the problem. It seems that putting BT Adapter into sleep causes many problems. If I deactivate auto suspend, this problem seems to be gone.

@gmalbert
Copy link

I found that following the steps on this link resolved it for me. It appears there was an issue with a later version of bluez which was choking Bluetooth.

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

No branches or pull requests

7 participants