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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create unique_id for sleepiq sensors #65227

Merged
merged 1 commit into from Feb 14, 2022

Conversation

jarodwilson
Copy link
Contributor

@jarodwilson jarodwilson commented Jan 30, 2022

This way, they can be moved to areas (like a bedroom) and have their names
customized. The basis is a bed ID returned by the sleepiq API, with sensors
for both the left and right sides of the bed, followed by a sensor type of
either 'is_in_bed' or 'sleep_number', which also map directly from the
sleepiq API.

Signed-off-by: Jarod Wilson jarod@redhat.com

Breaking change

Proposed change

Simply add a unique_id property to the sleepiq sensor init, so that the sensors can be moved to other areas and have their names customized.

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)
  • 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
  • The code has been formatted using Black (black --fast 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.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

To help with the load of incoming pull requests:

@homeassistant
Copy link
Contributor

Hi @jarodwilson,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@probot-home-assistant probot-home-assistant bot added integration: sleepiq small-pr PRs with less than 30 lines. labels Jan 30, 2022
@project-bot project-bot bot added this to Needs review in Dev Jan 30, 2022
@MartinHjelmare MartinHjelmare changed the title sleepiq: create unique_id for sensors Create unique_id for sleepiq sensors Jan 30, 2022
@jarodwilson
Copy link
Contributor Author

I find myself unable to run self-tests, due to inability to install required dependencies. It looks like there are plugins requiring both older and newer versions of async-timeout. From the error messages when trying to run tox:

...
    pyrmvtransport 0.3.3 depends on async-timeout>=4.0.0
...
    hole 0.7.0 depends on async-timeout<5 and >4
...
    plugwise 0.8.5 depends on async-timeout<4.0
    The user requested (constraint) async-timeout==4.0.2

Can't satisfy the dependencies of plugwise and everything that wants > 4.0.

Dev automation moved this from Needs review to Review in progress Jan 31, 2022
@frenck
Copy link
Member

frenck commented Jan 31, 2022

I find myself unable to run self-tests, due to inability to install required dependencies.

This is caused by using an incompatible pip version. Please make sure you are using the older (and pinned) pip version Home Assistant has listed in its constraints.

@jarodwilson
Copy link
Contributor Author

Whoops, I managed to skip over all the dev environment setup bits and use of virtualenv. Makes sense, thank you for the cluebat. Self-tests now attempting to run...

@jarodwilson
Copy link
Contributor Author

jarodwilson commented Feb 1, 2022

After struggling to get things entirely behaving on a native Linux install, I just did the docker container with vscode route, and:

---------- coverage: platform linux, python 3.9.10-final-0 -----------
Name                                                Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------------
homeassistant/components/sleepiq/__init__.py           59      0   100%
homeassistant/components/sleepiq/binary_sensor.py      33      1    97%   24
homeassistant/components/sleepiq/const.py               7      0   100%
homeassistant/components/sleepiq/sensor.py             35      1    97%   23
---------------------------------------------------------------------------------
TOTAL                                                 134      2    99%

======================================================================= slowest durations =======================================================================

(24 durations < 1s hidden.  Use -vv to show these durations.)

Results (5.55s):
       8 passed

[edit: post the testing from the modified branch, not the original, whoops]

@jarodwilson jarodwilson force-pushed the sleepiq-unique_id branch 3 times, most recently from 0a610cc to 445b182 Compare February 8, 2022 14:49
This way, they can be moved to areas (like a bedroom) and have their names
customized. The basis is a bed ID returned by the sleepiq API, with sensors
for both the left and right sides of the bed, followed by a sensor type of
either 'is_in_bed' or 'sleep_number', which also map directly from the
sleepiq API.

Signed-off-by: Jarod Wilson <jarodwilson@gmail.com>
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @jarodwilson 馃憤

Dev automation moved this from Review in progress to Reviewer approved Feb 14, 2022
@frenck frenck merged commit f81b6d6 into home-assistant:dev Feb 14, 2022
Dev automation moved this from Reviewer approved to Done Feb 14, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants