core icon indicating copy to clipboard operation
core copied to clipboard

Ruuvi Gateway integration not working

Open Linqman opened this issue 2 years ago • 22 comments

The problem

After updating Home assistant to the newest version, my Ruuvitag Gateway was not immediately auto-discovered, but I was able to add it manually. However, no devices were found, and the logs said the integration couldn't connect. I deleted the integration and restarted HA, and now my ruuvi Gateway was auto-discovered, and I added it again without problems. It still doesn't report devices and the logs says "Bluetooth scanner has gone quiet for 90s, check logs on the scanner device for more information".

I have up until now been publishing the data from the gateway with MQTT, which I now disabled to test the new integration and to keep the logs smaller for testing.

What version of Home Assistant Core has the issue?

2023.2.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Ruuvi Gateway

Link to integration documentation on our website

https://www.home-assistant.io/integrations/ruuvi_gateway

Diagnostics information

home-assistant_ruuvi_gateway_2023-02-02T09-17-27.088Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

If I manually run the command "curl -H "Authorization: Bearer [correct bearer token]" http://192.168.XXX.XXX/history", I get proper history data from the Ruuvi gateway.

Linqman avatar Feb 02 '23 09:02 Linqman

Hey there @akx, mind taking a look at this issue as it has been labeled with an integration (ruuvi_gateway) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of ruuvi_gateway can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign ruuvi_gateway Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


ruuvi_gateway documentation ruuvi_gateway source (message by IssueLinks)

home-assistant[bot] avatar Feb 02 '23 09:02 home-assistant[bot]

I've got the exact same issue, so it's not a n=1

sj3fk3 avatar Feb 02 '23 11:02 sj3fk3

Same here, Home Assistant finds the Gateway but none of my Ruuvitags show up. I use MQTT to connect the Ruuvitags, tried disabling MQTT integration to no effect.

Ubuntu + HA Docker

Jonssii avatar Feb 02 '23 12:02 Jonssii

Same here.

Raspberry Pi + HomeAssistant

plepola avatar Feb 02 '23 13:02 plepola

Same here. Home Assistant auto-discovered the gateway, added the bearer token, but nothing happens after that.

Generic x86-64 on Intel NUC.

jarilehtinen avatar Feb 02 '23 18:02 jarilehtinen

Author of the integration here. Sorry for the trouble.

That's curious – it certainly worked fine when I implemented it, but now that I tried with the release version of HA 2023.2, it's not doing much at all.

Um, @bdraco, since you know more about the Bluetooth systems in HA, can you think of a change that could have caused this, or should I just dig deeper myself?

akx avatar Feb 04 '23 11:02 akx

Never mind, I think I found the bug.

As always, time comparisons are hard... ⏳

akx avatar Feb 04 '23 11:02 akx

Still seems to be broken, I verified that bearer token works in curl:

➜ automation curl -H "Authorization: Bearer " http:///history { "data": { "coordinates": "", "timestamp": "1675592599",

With Debug logging in HA; only entry in log regarding this integration is: 2023-02-05 12:19:54.602 DEBUG (MainThread) [homeassistant.components.ruuvi_gateway.bluetooth] Ruuvi Gateway ]: Connecting scanner

Misentry avatar Feb 05 '23 10:02 Misentry

I changed token, and left it unchanged in integration, some more logs:

httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http:///history' For more information check: https://httpstatuses.com/401

So it seems to connect with current token, but does not get/parse anything from /history?

Misentry avatar Feb 05 '23 10:02 Misentry

It works after 2023.2.2 update! For some reason, every time after booting, the Gateway is found as a new device and needs to be defined again.

plepola avatar Feb 05 '23 16:02 plepola

Are you sure it actually works? Because I have 2023.2.2, and still does not actually find any of the tags, and it's a sign that it does not work if it get's discovered again after every reboot

Misentry avatar Feb 05 '23 17:02 Misentry

Definitely works for me, just set up everything. Gateway not discovered again after rebooting.

Jonssii avatar Feb 05 '23 17:02 Jonssii

Then I wonder if it's conflict with Ruuvi BLE and/or Bluetooth BLE integration.

If you look for Ruuvitag in Devices view, what's the integration for them? I tried removing one, and it's get discoverd by Ruuvitag BLE intergration

Misentry avatar Feb 05 '23 17:02 Misentry

Are you sure it actually works? Because I have 2023.2.2, and still does not actually find any of the tags, and it's a sign that it does not work if it get's discovered again after every reboot

It is odd but true that Gateway does not find new devices, but sensors are found as separate BLE devices. I can't be sure if the connection is through the Gateway, but the sensors have been too far for a direct Bluetooth connection in the past. Now the signal seems to be stable.

plepola avatar Feb 05 '23 17:02 plepola

Definitely works for me, just set up everything. Gateway not discovered again after rebooting.

Are your sensors separated BLE devices or are they visible under Gateway integration?

plepola avatar Feb 05 '23 17:02 plepola

I wish integration documentation would state if RuuviTags are actually listed under devices of the same integration, or are they listed as Ruuvitag BLE?

Misentry avatar Feb 05 '23 17:02 Misentry

Are your sensors separated BLE devices or are they visible under Gateway integration?

They are separated BLE devices under ruuvitag BLE. And it is using the Gateway, if I disconnect the Gateway power supply they sensors stop updating. There is nothing listed under the Gateway integration.

Jonssii avatar Feb 05 '23 17:02 Jonssii

Actually when I disconnect Bluetooth adapter, they are still updated.

So it works, but is rather confusing with lag of debug log updates other than: : Connecting scanner and devices appearing under RuuviTag BLE.

I still have the problem with being discoverd after every boot, even if previosly configured one seems to work now.

Misentry avatar Feb 05 '23 17:02 Misentry

I still have the problem with being discoverd after every boot, even if previosly configured one seems to work now.

Same here. It is really annoying.

plepola avatar Feb 05 '23 17:02 plepola

Then I wonder if it's conflict with Ruuvi BLE and/or Bluetooth BLE integration.

I don't think that's the case – the Ruuvi Gateway integration essentially just works as a remote bluetooth adapter (like you can enable ESPhome or Shelly v2 devices to do), and relays Bluetooth advertisements for the rest of HA (e.g. the Ruuvi BLE integration, also authored by yours truly).

For some reason, every time after booting, the Gateway is found as a new device and needs to be defined again.

@bdraco Can you think of some obvious reason for this? (I'm thinking something about unique IDs..?) I'm assuming the Gateway's IP isn't changing every boot of @plepola's HA system or anything...

akx avatar Feb 06 '23 07:02 akx

The gateway integration is now partially working for me. HA discovered 3 RuuviTags, which are working with the gateway, however, I have 6 RuuviTags connected to it, so only half are discovered. I also have 4 Xiaomi temperature sensors connected to HA, and they now also seem to get data through the gateway, as they stopped updating when I disconnected the gateway.

For testing purposes, I removed a Custom BLE integration, but that did not seem to have any effect. I also disabled the Bluetooth integration for the onboard Bluetooth adapter.

I also have the Ruuvi Gateway autodiscovered each time I restart HA.

Linqman avatar Feb 06 '23 12:02 Linqman

@bdraco Can you think of some obvious reason for this? (I'm thinking something about unique IDs..?) I'm assuming the Gateway's IP isn't changing every boot of @plepola's HA system or anything...

Yes, the IP stays the same. It is locked in the router settings.

plepola avatar Feb 06 '23 14:02 plepola

@bdraco Can you think of some obvious reason for this? (I'm thinking something about unique IDs..?) I'm assuming the Gateway's IP isn't changing every boot of @plepola's HA system or anything...

You are using the mac as the unique id (this is a good thing) so it shouldn't matter if the ip changes.

It looks like its set correctly in both places.

https://github.com/home-assistant/core/blob/dev/homeassistant/components/ruuvi_gateway/config_flow.py#L86 https://github.com/home-assistant/core/blob/dev/homeassistant/components/ruuvi_gateway/config_flow.py#L48

@plepola Can you try setting it up again and than post the entries you see in .storage/core.config_entries. Maybe that will reveal what the issue is.

bdraco avatar Feb 06 '23 19:02 bdraco

@plepola Can you try setting it up again and than post the entries you see in .storage/core.config_entries. Maybe that will reveal what the issue is.

Here they are. There are no differences between them, only the entity_id differs. XXX are censored.

Before reinstall { "entry_id": "db3a48a935318cf13da4dce1327a9246", "version": 1, "domain": "ruuvi_gateway", "title": "Ruuvi Gateway A9:28", "data": { "token": "XXXXXX", "host": "192.XXX.XX.XXX" }, "options": {}, "pref_disable_new_entities": false, "pref_disable_polling": false, "source": "dhcp", "unique_id": "XX:XX:XX:XX:a9:28", "disabled_by": null }

After reinstall { "entry_id": "dbd4fadd49cc3180f6ea837525a67224", "version": 1, "domain": "ruuvi_gateway", "title": "Ruuvi Gateway A9:28", "data": { "token": "XXXXXX", "host": "192.XXX.XX.XXX" }, "options": {}, "pref_disable_new_entities": false, "pref_disable_polling": false, "source": "dhcp", "unique_id": "XX:XX:XX:XX:a9:28", "disabled_by": null } ] }

plepola avatar Feb 06 '23 20:02 plepola

Is the reason here: "pref_disable_new_entities": false,

plepola avatar Feb 06 '23 20:02 plepola

I'm missing something but both entries have a source of dhcp so it shouldn't have been possible to get past this line: https://github.com/home-assistant/core/blob/dev/homeassistant/components/ruuvi_gateway/config_flow.py#L87

bdraco avatar Feb 06 '23 20:02 bdraco

After the Home Assistant 2023.2.3 update bug is still alive. After booting, the Gateway is always found as a new device.

plepola avatar Feb 09 '23 10:02 plepola

My Gateway stopped appearing as a new device while I was still on the 2023.2.2 version. The thing I did that might have affected this is I removed my normal Bluetooth integration as well as my Bluetooth Low Energy Monitor integration, and then after a reboot I added them again. Now I no longer get the Gateway found as s new device on reboot.

Linqman avatar Feb 09 '23 10:02 Linqman

My Gateway stopped appearing as a new device while I was still on the 2023.2.2 version. The thing I did that might have affected this is I removed my normal Bluetooth integration as well as my Bluetooth Low Energy Monitor integration, and then after a reboot I added them again. Now I no longer get the Gateway found as s new device on reboot.

I tried to remove Bluetooth and iBeacon Tracker but it had no effect, the gateway still appears as a new device after booting.

Then I skipped the newly founded Gateway installation and hid it. After booting, no more new devices, and the old Gateway integration still works. It doesn't sound like a sophisticated solution in the long run, but it works for me.

plepola avatar Feb 09 '23 11:02 plepola

I'm running HA in Proxmox VM, so I don't have Bluetooth available at all. Installed VM to Proxmox with that installation script found from: https://community.home-assistant.io/t/installing-home-assistant-os-using-proxmox-7/201835

Installed yesterday RuuviGateway integration and it found 6 (!?!) of my 9 RuuviTAGS. Configured 2 of those and was amazed how well it worked. Gateway integration seemed to work flawlessly.

Today I was planning to configure rest of my TAGs and find out reason why 3 TAGs was missing. Now those 2 TAG show "unavailable" and other TAGs are not showing in Devicelist at all. It looks to me that these TAGs are BLE devices and because I don't have Bluetooth they don't show anything. Gateway integration seems completely mute.

What should I try next? Should I just wait integration gets fixed or do I need to uninstall something?

mrl0leak avatar Feb 10 '23 09:02 mrl0leak