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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow parsing to happen in PassiveBluetoothProcessorCoordinator #76384
Conversation
Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @Ernst79, mind taking a look at this pull request as it has been labeled with an integration ( |
@@ -52,7 +52,9 @@ class PassiveBluetoothDataUpdate(Generic[_T]): | |||
) | |||
|
|||
|
|||
class PassiveBluetoothProcessorCoordinator(BasePassiveBluetoothCoordinator): | |||
class PassiveBluetoothProcessorCoordinator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you subclass the coordinator and overload async_handle_bluetooth_event instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think this behaviour makes sense as the default, which is why I didn't do it in a subclass. If you disagree I am happy to do it in a subclass instead. But i'd be submitting an ActiveBluetoothProcessorCoordinator
seperately for xiaomi, and I think this behaviour especially makes sense for any passive sensor that has binary sensor and sensor payloads in the same broadcast, and any passive sensor that has dynamic platforms. (So we'd have quite a few coordinator flavours).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to change it, but we need to label it a breaking change since its shipped this way in 2022.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok my bad - didn't think of API stability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if i revert c8e0421 it won't be a breaking change.
c8e0421
to
7ad474c
Compare
TODO: Decide whether to revert 7c48dd5. If we do, this isn't a breaking change. Though we should probably slap a deprecation warning on it? |
Its new enough that I would remove it now. Easier to do it take the pain now then when 50 integrations are using this |
We will need a breaking change section to tell devs what to do, probably actually better as a blog post on developers.home-assistant.io |
馃憤 - will pick that up in the morning. long day and i don't think i can write anything coherent right now 馃槅 I've added a rambling Breaking section in the meantime. |
First draft of blog post: home-assistant/developers.home-assistant#1427 |
7ad474c
to
efd21c2
Compare
Last commit fixed missing test coverage, testing failure and recovery of the new method. Will now start reworking the ActiveDataProcessor from my other PR to work with this instead. |
All working as expected. Its definitely makes it a lot more flexible, and less code in the integration as well 馃憤 |
Breaking change
This changes the
PassiveBluetoothProcessorCoordinator
andPassiveBluetoothDataProcessor
bluetooth API's introduced in 2022.8.PassiveBluetoothProcessorCoordinator
now takes a mandatoryupdate_method
callback that receives bluetooth advertisements (in the form ofBluetoothServiceInfoBleak
) and returns the data that should be handed off to any subscribedPassiveBluetoothDataProcessor
.PassiveBluetoothDataProcessor
still takes anupdate_method
, but instead of aBluetoothServiceInfoBleak
, it now takes receives the data fromPassiveBluetoothProcessorCoordinator
'supdate_method
This change is to help integrations where:
Proposed change
As per discussion in #76342, slight refactor so that the bluetooth coordinator can drive the parsers. This is useful:
If i rebase #76342 on top of this then I can implement an
ActiveBluetoothProcessorCoordinator
that polls characteristics at the coordinator and makes the data available to multiple platforms the same way passsive data is handled (DataProcessor.async_update) (in the PR as it is now, I have to do this in the DataProcessor which probhibits sharing collected data between platforms).Crucially, each platform is still responsible for its own entities - the coordinator does not know about Home Assistant entities.
There is a default update_method for the coordinator - that just passes through the BluetotohServiceInfo, so other integrations carry on working as they are for now. I intend for that to be temporary, unless people think its useful.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: