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

Ruuvitag sensors - Testers wanted #410

Closed
Ernst79 opened this issue Jun 16, 2021 · 19 comments
Closed

Ruuvitag sensors - Testers wanted #410

Ernst79 opened this issue Jun 16, 2021 · 19 comments
Labels
help wanted Extra attention is needed

Comments

@Ernst79
Copy link
Collaborator

Ernst79 commented Jun 16, 2021

In 3.3.1-beta, support for Ruuvitag sensors is added. I'm looking for someone who can test that it is all working

Especially the motion sensor might not work as expected. To explain, the sensor is now reporting motion detected when the motion counter has changed, if it doesn't change it will report motion clear. I'm not sure how fast the sensor will report motion clear, this all depends on the update interval.

So, if you have this sensor and want to do some testing, it would be appreciated.

@Ernst79 Ernst79 added the help wanted Extra attention is needed label Jun 18, 2021
@Kaibob2
Copy link

Kaibob2 commented Jun 18, 2021

Hi Ernst,
there seems to be a problem with the Influxdb addon which (apparently) appears after uprading the ble_monitor. I just wanted you to be aware of this. I'm affected, too. Influxdb stopped working when HA came back up after installing ble_monitor 3.3.3 (could also be 3.3.1-beta)
I have no idea if it's coincidence or a problem with your integration.
See home-assistant/core#51956

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 18, 2021

Thanks, I’ve responded in the other topic. I do not really understand how it can be related. It is related and fixed in 3.3.5.

@Kaibob2
Copy link

Kaibob2 commented Jun 18, 2021

Me neither, but my coding skills are much more limited than yours ;)

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 20, 2021

3.4.0-beta has been released with a new parser for Ruuvitag sensors, which should not have the Influxdb issue anymore.

Please let me know if this version is working, if one of you have this sensor.

@rkallensee
Copy link

rkallensee commented Jun 24, 2021

I updated to 3.4.1-beta and added my two Ruuvitag sensors (they are reporting with v5 format) but no devices/entities are being created in Home Assistant. The Ruuvitag sensors work fine (I am receiving data with the "RuuviTag Discovery" add-on) and I am using ble_monitor with some Xiaomi temperature sensors since quite some time, just the Ruuvitag sensors are not working with it yet.

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

@rkallensee Thanks for taking the time to test.

I hope you are willing to help. Could you enable debug logging at info level by putting this in your configuration.yaml.

logger:
  default: warn
  logs:
    custom_components.ble_monitor: info

and enable report_unknown: "Ruuvitag" (either in YAML or in the options menu of the BLE monitor integration). You will need to update to 3.4.2 first, to see Ruuvitag. After a restart, have a look in your HA logs by "load full Home Assistant Log". If nothing shows up, try again with report_unknown: "Other"

Another, perhaps easier, option is to make a hcidump with the following command.

sudo hcidump --raw hci > dump.txt

But this doesn't work on Home Assistant OS.

@rkallensee
Copy link

Here are two advertisements each from both of my sensors in the log:

2021-06-24 17:18:26 INFO (MainThread) [custom_components.ble_monitor] Attention! Option report_unknown is enabled for Ruuvitag sensors, be ready for a huge output...
2021-06-24 17:18:29 INFO (Thread-17) [custom_components.ble_monitor.ble_parser.ruuvitag] BLE ADV from UNKNOWN Ruuvitag DEVICE: RSSI: -86, MAC: EE:43:F4:8D:E9:55, ADV: 043e2b0201030155e98df443ee1f0201061bff9904050f368007c60cfdacfcc0ffe4a8760fcf62ee43f48de955aa
2021-06-24 17:18:35 INFO (Thread-17) [custom_components.ble_monitor.ble_parser.ruuvitag] BLE ADV from UNKNOWN Ruuvitag DEVICE: RSSI: -81, MAC: E9:BD:3B:4F:8D:0A, ADV: 043e2b020103010a8d4f3bbde91f0201061bff9904050e067848c5fffd6000e8fd3cac36985353e9bd3b4f8d0aaf
2021-06-24 17:19:10 INFO (Thread-17) [custom_components.ble_monitor.ble_parser.ruuvitag] BLE ADV from UNKNOWN Ruuvitag DEVICE: RSSI: -86, MAC: EE:43:F4:8D:E9:55, ADV: 043e2b0201030155e98df443ee1f0201061bff9904050f36802bc60afda8fcc4ffe8a7b60fcf82ee43f48de955aa
2021-06-24 17:19:27 INFO (Thread-17) [custom_components.ble_monitor.ble_parser.ruuvitag] BLE ADV from UNKNOWN Ruuvitag DEVICE: RSSI: -79, MAC: E9:BD:3B:4F:8D:0A, ADV: 043e2b020103010a8d4f3bbde91f0201061bff9904050e067881c601fd6000e8fd34acf698535be9bd3b4f8d0ab1

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

Thanks, the parser on my local PC works fine for this advertisement.

result {'mac': 'EE43F48DE955', 'type': 'Ruuvitag', 'rssi': -86, 'data': True, 'temperature': 19.47, 'humidity': 81.94, 'pressure': 1007.0, 'acceleration': 1023.8281105732544, 'acceleration x': -596, 'acceleration y': -832, 'acceleration z': -28, 'voltage': 2.947, 'tx power': 4, 'motion': 0, 'motion timer': 0, 'packet': 53090, 'firmware': 'Ruuvitag V5', 'battery': 94.7}

I will check if I made some other mistake somewhere.

No errors in the log?

@rkallensee
Copy link

No, only these lines, no errors.

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

These lines are ok, but they should not have gotten to the point "report_unknown".

Can you try to comment out (with a #) the following lines in /custom_components/ble_monitor/ble_parser/ruuvitag.py (from line 103). I think it fails on that part.

                # Check for duplicate messages
                try:
                    prev_packet = self.lpacket_ids[ruuvitag_mac]
                except KeyError:
                    # start with empty first packet
                    prev_packet = None
                if prev_packet == packet_id:
                    # only process new messages
                    return None
                self.lpacket_ids[ruuvitag_mac] = packet_id
                if prev_packet is None:
                    # ignore first message after a restart
                    return None

@rkallensee
Copy link

Commenting out these lines didn't change anything. Logging a bit in the parser, I found out that adstuct_type is 62, which I think doesn't match with any of the two outer conditions for the versions.

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

Where do you see adstruct_type is 62? In init.py (and in ruuvitag.py again) it is filtered based on 0xFF, and than of comp_id 0x0499 and then it looks forthe version 05. So it is looking for ff990405, which is in your advertisement.

@rkallensee
Copy link

I was logging the value of adstruct_type in ruuvitag.py (L20) after I noticed that it doesn't enter any of both conditions checking for version 3/5 or 2/4 right after.

if adstuct_type == 0x16:
    # ...
elif adstuct_type == 0xFF:
    # ...
else:
    # this is what happens
    result = None

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

Ah, thanks. You gave enough hints 😄

In the previous version I had the full data passed in, but I should have passed adstruct

On line 78 in __init__.py, change data to adstruct

                    return parse_ruuvitag(self, adstruct, mac, rssi)

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

3.4.3-beta is released, should fix the issue (also for V2/V4).

Please let me know if it all works after the update and thanks for the help.

@rkallensee
Copy link

The Ruuvitag devices now show up with their sensor entities, but now I see this error causing the integration to crash:

Traceback (most recent call last):
File "/config/custom_components/ble_monitor/sensor.py", line 189, in async_run
entity.collect(data, batt_attr)
File "/config/custom_components/ble_monitor/sensor.py", line 781, in collect
self._device_state_attributes["acceleration x"] = data["acceleration_x"]
KeyError: 'acceleration_x'

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

Remove the underscore _ in acceleration_x in sensor.py. Also for y and z. Line 781-783

Thanks again for testing, it is a bit hard to do it without having the actual sensor.

@rkallensee
Copy link

Works like a charm. Thank you so much for adding support for Ruuvitag sensors!

@Ernst79
Copy link
Collaborator Author

Ernst79 commented Jun 24, 2021

3.4.4 has been released as final.

@Ernst79 Ernst79 closed this as completed Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants