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

feat: support ThermoPro TempSpike (TP96x) #19

Merged
merged 7 commits into from
Jan 18, 2024

Conversation

h3ss
Copy link
Contributor

@h3ss h3ss commented Jan 17, 2024

This is still a WIP, need to add support for multi-probe devices like TP962R.

Looking for feedback.

Thanks in advance!

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (temp_spike@8e51074). Click here to learn what that means.

❗ Current head a3d311c differs from pull request most recent head dc39bf2. Consider uploading reports for the commit dc39bf2 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##             temp_spike      #19   +/-   ##
=============================================
  Coverage              ?   85.71%           
=============================================
  Files                 ?        2           
  Lines                 ?       63           
  Branches              ?        8           
=============================================
  Hits                  ?       54           
  Misses                ?        4           
  Partials              ?        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@h3ss
Copy link
Contributor Author

h3ss commented Jan 17, 2024

@bdraco I think this may be close to complete, would you mind providing some feedback?

Comment on lines 31 to 34
"TP962R": {
0: "black",
1: "white",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep these as probe 0 and probe 1 since the vendor tends to add new devices with the same format and we can't be sure they will keep the color scheme in the future

Copy link
Contributor Author

@h3ss h3ss Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually already falling back to something like this on lines 85-92, I just use the color names when we know that the model has a specific mapping. The difference is for probe 0 I default to no affix at all.

Since we don't know if any new model has more than one probe, the alternative here would be to have "Probe 0" affixed even on single probe models. I think this is reasonable also, and would simplify the code. I started a review for that option above.

Comment on lines 75 to 76
MAX_BAT = 2880
MIN_BAT = 1600 # ??
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make constants above and make it clear the are for the TP96 series in the name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, will do

src/thermopro_ble/parser.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@h3ss h3ss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the review @bdraco! I completed some of your suggestions, and started a review on others to discuss some options and clarify some things.

src/thermopro_ble/parser.py Outdated Show resolved Hide resolved
Comment on lines 31 to 34
"TP962R": {
0: "black",
1: "white",
},
Copy link
Contributor Author

@h3ss h3ss Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually already falling back to something like this on lines 85-92, I just use the color names when we know that the model has a specific mapping. The difference is for probe 0 I default to no affix at all.

Since we don't know if any new model has more than one probe, the alternative here would be to have "Probe 0" affixed even on single probe models. I think this is reasonable also, and would simplify the code. I started a review for that option above.

src/thermopro_ble/parser.py Outdated Show resolved Hide resolved
Comment on lines 75 to 76
MAX_BAT = 2880
MIN_BAT = 1600 # ??
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, will do

@h3ss
Copy link
Contributor Author

h3ss commented Jan 18, 2024

@bdraco Latest commit contains all suggestions applied, how's it look?

Comment on lines +49 to +55
if model.startswith("TP96"):
# This series can have multiple probes, so we must assume probe 1
self.set_title(f"{name} Probe 1 {short_address(service_info.address)}")
self.set_device_name(f"{name} PROBE 1")
else:
self.set_title(f"{name} {short_address(service_info.address)}")
self.set_device_name(name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title / device name is for the whole device so we want to keep it as-is. I'll merge this PR and do a cleanup on the original PR

Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @h3ss

@bdraco bdraco changed the title Support ThermoPro TempSpike (TP96x) feat: support ThermoPro TempSpike (TP96x) Jan 18, 2024
@bdraco bdraco merged commit d9e9fd8 into Bluetooth-Devices:temp_spike Jan 18, 2024
6 of 7 checks passed
@h3ss h3ss deleted the temp_spike_h3ss branch January 19, 2024 02:18
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