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

Parser for Home Assistant #34

Closed
wants to merge 4 commits into from
Closed

Conversation

rajlaud
Copy link
Contributor

@rajlaud rajlaud commented Jun 27, 2023

Summary 📝

To integrate with Home Assistant core, they've asked that I move some of the logic from the HA component to the Python library. This PR does that by creating a new module called parser that handles incoming Bluetooth advertisements in a way that integrates cleanly with HA.

If you'd rather I spin this into a separate project I can do that too, but I thought it would be cleaner to have everything in one dependency.

I've tested locally with these changes, and once this is merged and a new version released, I can push my local changes to the PR for HA core (home-assistant/core#94994 (review))

Details

  1. The parser module has one class, VictronBluetoothDeviceData, which parses Bleak advertisements and updates itself with the sensor data from the advertisement. Each instance of VictronBluetoothDeviceData should be fed advertisements from exactly one Victron device (based on the MAC address) and the instance needs to be initiated with the encryption key of the device that is going to be sending updates. If the encryption key is set correctly everything else will be figured out automatically.

  2. There is a handy package from maintainers of the HA project called sensor-state-data to make it easy to automate ingesting sensor state updates like this. Unfortunately, we need to use a unit (amp-hours) not supported by the module and my PR to include amp-hours was rejected because they are not a common unit (Add current flow support Bluetooth-Devices/sensor-state-data#47). For that reason, we need a custom extension of sensor-state-data, which is contained in the custom-sensor-state.py file.

Checks

  • Tested Changes
  • Stakeholder Approval

@rajlaud rajlaud changed the title Parser for ha Parser for Home Assistant Jun 27, 2023
@rajlaud
Copy link
Contributor Author

rajlaud commented Aug 9, 2023

@keshavdv just curious if you are interested in incorporating this or if you'd prefer I spin it off into a separate project.

@keshavdv
Copy link
Owner

I think it might be best to put these in a dedicated repo!

@rajlaud rajlaud closed this Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants