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

Add API endpoints to add remove tap temp sensors #409

Merged
merged 4 commits into from
May 13, 2020

Conversation

johnnyruz
Copy link
Contributor

This PR adds two new API endpoints to allow a user to add/remove a thermo sensor from a tap.

Connect: /api/taps/[tap_id]/connect-thermo (from x-urlencoded form "thermo": [thermo_id])
Disconnect: /api/taps/[tap_id]/disconnect-thermo

This will allows users to select the thermo sensor from the Android app similar to selecting the flow sensor and tap toggle. I have a PR on the Android side to add this selection to the tap settings.

Comment on lines 665 to 670
if old_thermo:
tap.temperature_sensor = None
tap.save()
if new_thermo:
tap.temperature_sensor = new_thermo
tap.save()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd think something like this would be cleaner:

if new_thermo:
  tap.temperature_sensor = new_thermo
else:
  tap.temperature_sensor = None
tap.save()

Unless the tap needs to be saved without a thermo before it can be saves with a thermo.

@patfreeman
Copy link
Contributor

Also needs black formatting.
See johnnyruz#20

@johnnyruz
Copy link
Contributor Author

Thanks @patfreeman, I’ll test the simplified code. I did something similar and ran into an issue with it not saving, but going to give this a try.

For the black formatting good catch, missed that in the developer guide.

@mik3y mik3y merged commit d02f559 into Kegbot:master May 13, 2020
@mik3y
Copy link
Member

mik3y commented May 13, 2020

thanks!

adding a link to the android change so github does its thing & linkifies it over there too: Kegbot/kegbot-android#120

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.

3 participants