esphome
esphome copied to clipboard
Added Device Address Functionality to BL0939 Component
What does this implement/fix?
The BL0939 IC is available in two packages SOP16 & SSOP20L. The SSOP20L has address selection functionality which was not implemented in the component. This feature enables the user to add up to 15 BL0939 components in a single loop.
Types of changes
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Other
Related issue or feature (if applicable): fixes esphome/esphome-docs#4158
Pull request in esphome-docs with documentation (if applicable):
Test Environment
- [x] ESP32
- [x] ESP32 IDF
- [ ] ESP8266
- [ ] RP2040
- [ ] BK72xx
- [ ] RTL87xx
Example entry for config.yaml:
# Example config.yaml
sensor:
- platform: bl0939
uart_id: uart_2
voltage:
name: 'BL0939 Voltage'
current_1:
name: 'BL0939 Current 1'
current_2:
name: 'BL0939 Current 2'
active_power_1:
name: 'BL0939 Active Power 1'
active_power_2:
name: 'BL0939 Active Power 2'
energy_1:
name: 'BL0939 Energy 1'
energy_2:
name: 'BL0939 Energy 2'
energy_total:
name: 'BL0939 Energy Total'
address: 0
Checklist:
- [x] The code change is tested and works locally.
- [x] Tests have been added to verify that the new code works (under
tests/folder).
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated in esphome-docs.
Hey there @ziceva, mind taking a look at this pull request as it has been labeled with an integration (bl0939) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
Codecov Report
Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
Project coverage is 17.41%. Comparing base (
289aedc) to head (2001d89).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| esphome/components/bl0939/sensor.py | 0.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## dev #7293 +/- ##
==========================================
- Coverage 17.41% 17.41% -0.01%
==========================================
Files 1173 1173
Lines 49067 49068 +1
Branches 5885 5885
==========================================
Hits 8545 8545
- Misses 39949 39950 +1
Partials 573 573
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
For BL0942 I called this just address.
See also the calibration, in https://github.com/esphome/esphome/pull/7299
Ok, I will update as address.
Thanks. You should be able to mostly cut and paste the commit which does the calibration too, although the constants are different for the BL0939 as noted in bl0939.h.
Hi @dwmw2, I have changed the address key as you requested. Since the line Frequency Constant has not been added (merged yet), How can I implement the calibration part, wouldn't that cause some issues?
Hi @dwmw2, I have changed the address key as you requested. Since the line Frequency Constant has not been added (merged yet), How can I implement the calibration part, wouldn't that cause some issues?
Hopefully that will be merged soon. But if not, perhaps we should add it in my PR too? The main reason I didn't touch BL0939 and BL0940 was because I couldn't test them.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes. Thank you for your contribution!