Eddystone Beacon Temperature Sensor#6789
Conversation
|
@citruz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @robbiet480 to be potential reviewers. |
pvizeli
left a comment
There was a problem hiding this comment.
Please export the monitor class into external pipy packages. This have do device specific code.
|
@pvizeli Are you sure that's necessary for 120 lines of code (without the comments)? To me, this seems like too little functionality to move it to its own pipy package. Also, I haven't created a pipy package before so that would be quite an effort for me. |
|
As far as I know there exists no eddystone tlm implementation publicly available (at least not in python, for urls there's this https://github.com/google/eddystone/tree/master/eddystone-url/implementations/PyBeacon), so having a python package implementing the eddystone parsing would help others too! As for monitoring itself, I think there needs to be a discussion at some point on how the bluetooth devices should be used inside homeassistant in general, as different bluetooth devices are starting to pile up and them trying to access the bluetooth adapter at the same time will cause race conditions.. As the eddystone beacons are just some extra data contained in the advertisement messages, this component and bluetooth le tracker should in principle be using the data returned by a single scan round. edit: to add, packaging modules is quite straight-forward, see https://packaging.python.org/distributing/ . edit2: it'd also be nice to extract other information available in the TLM frames, esp. battery information can be useful https://github.com/google/eddystone/blob/master/eddystone-tlm/tlm-plain.md . |
|
Alright, I will work on separating the functionality then. Having a dedicated beacon advertisement parser in fact seems like a good idea. Thanks for the suggestions. |
|
|
||
| if len(devices) > 0: | ||
| mon = Monitor(hass, devices, bt_device_id) | ||
| def monitor_stop(_service_or_event): |
There was a problem hiding this comment.
expected 1 blank line before a nested definition, found 0
| devices = [] | ||
|
|
||
|
|
||
| for dev_name, properties in beacons.items(): |
| https://github.com/anpetrov/skybeacon | ||
| """ | ||
| import logging | ||
| import threading |
| }) | ||
|
|
||
| # pylint: disable=unused-argument | ||
| def setup_platform(hass, config, add_devices, discovery_info=None): |
|
@pvizeli I have created a PyPI package and updated my PR. Please review the changes and merge the PR if you're happy with them :) |
|
Looks good (as does the lib, hello fellow construct user!), just wondering how the scanning part is implemented in the backend, will the scanning block all other bluetooth activities? There are quite a few problems related to handling of BT/BLE devices in general, originating (most likely) from blocking the device access / trying to issue too many concurrent connects on BLE devices (#4442, #3885). Would enabling this worsen the situation? If not, maybe the same scanning backend could also be used for bt_le_tracker too? Maybe that would also fix #4186 ? |
|
@rytilahti I don't know much about the internals of bluez, but I was able to run two scanners in parallel using the library. So it looks like the other activities are not blocked by the scanning. Beacons require (and allow) no "connection", the scanner only reads the data from the ble advertisement. Therefore, too many concurrent connections won't be problem. Regarding bt_le_tracker: The library only scans for beacons, not BLE devices in general. Hence it cannot be used as a replacement. |
pvizeli
left a comment
There was a problem hiding this comment.
Some small minor changes:
- Move constant into your platform from
const.py - Add property for polling into you entity and set it to false
- After you change some value on entity, call
schedule_update_ha_state() - Start thread also on
EVENT_HOMEASSISTANT_START
|
@citruz ok, nice to hear about it working with two parallel scans. I think this all depends on the chipset. I know that the data is there in advertisements, was just curious what will happen when other scanners start working at the same time. At least in my case I can't use hcitool's scanle when there are open connections (caused by other ble connected devices). About bt_le_tracker, I just mentioned it here because it shares similar needs (requiring access to adv data) while being just more lightweight with no need for parsing. The problem with the current (bt_le_tracker) solution seems to be that it keeps blocking for 10s scanning periods, a problem which could be solved by using your scanner backend for that too. |
|
@pvizeli Done. |
|
@citruz that would be a nice and a very welcomed addition I suppose! Not relevant for the task at hand, so I'll stop discussing it from here on. |
|
Good work ⚡️ |
Description:
Read temperature information from Eddystone beacons.
Eddystone beacons can be configured to broadcast telemetry data which also includes the temperature measured by the device (assuming that the device has a temperature sensor). This platform will scan for Bluetooth LE advertisements using pybluez and extract the relevant information.
Pull request in home-assistant.github.io with documentation: home-assistant/home-assistant.io#2334
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.