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

Fix SleepIQ setting FootWarmer timer #108433

Merged

Conversation

jmwaldrip
Copy link
Contributor

@jmwaldrip jmwaldrip commented Jan 20, 2024

Proposed change

Note: This is dependent on #108431 being merged.

A small change to the number entity for the SleepIQ Bed Foot Warmer Timer.

Currently the Foot Warmer timer number entity will not update the SleepIQ API, it is just used internally by HA when using the select.

This change will allow a user to change the timer on the fly and it will update the API with their current selected mode and the new timer value.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @mfugate1, @kbickar, mind taking a look at this pull request as it has been labeled with an integration (sleepiq) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of sleepiq can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign sleepiq Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@MartinHjelmare MartinHjelmare changed the title SleepIQ Integration - Fix for setting FootWarmer timer via HA UI Fix SleepIQ setting FootWarmer timer Jan 20, 2024
@kbickar
Copy link
Contributor

kbickar commented Jan 20, 2024

Just a note that this will make a duplicate API call when the mode and time are set

@jmwaldrip
Copy link
Contributor Author

That's a good call out!

Do you have any ideas on how we could avoid that? Maybe there is a way I can detect the call is coming from a select, or if the time is the same as the current time it could no op out?

@kbickar
Copy link
Contributor

kbickar commented Jan 21, 2024

There isn't really any way to fix that. The user can choose to set the time first or the mode first. Since they're different entities, there's nothing requiring them to do them in any order or to do both

@jmwaldrip
Copy link
Contributor Author

If I change it to set the value of timer if off. And if it's on I will make the api call to set the the timer to the new value with the current temp. Would that be a good compromise?

Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Please rebase to take in the dependency bump.

(Also, I saw some issues about the footwarmer, are they fixed with this PR? If so, you can add them as well)

@home-assistant home-assistant bot marked this pull request as draft January 22, 2024 14:30
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@kbickar
Copy link
Contributor

kbickar commented Jan 22, 2024

If I change it to set the value of timer if off. And if it's on I will make the api call to set the the timer to the new value with the current temp. Would that be a good compromise?

There's a single API call that takes the temperature setting and the time so it doesn't really matter what order you set them in. If the time is set to 0 it defaults to 2 minutes

@jmwaldrip
Copy link
Contributor Author

Sorry, I am honestly new to rebasing with git. I think I did it correctly. Please let me know if I did it wrong. Thank you!

@jmwaldrip jmwaldrip marked this pull request as ready for review January 22, 2024 16:48
@joostlek joostlek added this to the 2024.1.6 milestone Jan 22, 2024
@jmwaldrip
Copy link
Contributor Author

The bug fixes for the foot warmers mentioned in the previous PR #108431 were fixed by the library bump. It was an internal bug that didn't refresh data properly. This should be the only change needed here.

Once this gets checked in I am going to start a new PR that adds new features for Core Climate support for the Sleep IQ integration.

@jmwaldrip jmwaldrip force-pushed the asyncsleepiq-footwarmer-timer-fix branch from f42efec to c6f8864 Compare January 22, 2024 20:14
@joostlek joostlek merged commit d75dd09 into home-assistant:dev Jan 22, 2024
23 checks passed
catsmanac pushed a commit to catsmanac/ha-core-dev that referenced this pull request Jan 23, 2024
* Fixing foot warmer timer bug

* Fixing bug where temperature wasnt assigned to number entity causing tests to fail
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants