Skip to content

Add Tahoma lock support#31311

Merged
springstan merged 6 commits into
home-assistant:devfrom
vlebourl:tahoma_smartlock
Feb 1, 2020
Merged

Add Tahoma lock support#31311
springstan merged 6 commits into
home-assistant:devfrom
vlebourl:tahoma_smartlock

Conversation

@vlebourl
Copy link
Copy Markdown
Contributor

Proposed change

Add support for Somfy's smartlock through the tahoma integration. If the smartlock has been added to the tahoma box, it will be detected and added to Home Assistant.

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

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.
    no tests are done for tahoma in the current dev branch...

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@probot-home-assistant
Copy link
Copy Markdown

Hey there @philklei, mind taking a look at this pull request as its been labeled with a integration (tahoma) you are listed as a codeowner for? Thanks!

@MartinHjelmare MartinHjelmare changed the title Tahoma update: added lock support Add Tahoma lock support Jan 30, 2020
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/__init__.py Outdated
Copy link
Copy Markdown
Member

@springstan springstan left a comment

Choose a reason for hiding this comment

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

Sorry did not see some things that need to be addressed 😅

Comment thread homeassistant/components/tahoma/lock.py
Comment thread homeassistant/components/tahoma/lock.py
Comment thread homeassistant/components/tahoma/lock.py Outdated
Comment thread homeassistant/components/tahoma/lock.py Outdated
Copy link
Copy Markdown
Member

@springstan springstan left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for implementing my suggested changes ✌😉

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 31, 2020

Codecov Report

Merging #31311 into dev will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #31311      +/-   ##
==========================================
+ Coverage   94.61%   94.63%   +0.02%     
==========================================
  Files         741      745       +4     
  Lines       53816    54048     +232     
==========================================
+ Hits        50916    51148     +232     
  Misses       2900     2900              
Impacted Files Coverage Δ
homeassistant/components/unifi/config_flow.py 95.60% <0.00%> (-4.40%) ⬇️
homeassistant/components/axis/camera.py 96.77% <0.00%> (ø) ⬆️
homeassistant/components/axis/device.py 100.00% <0.00%> (ø) ⬆️
homeassistant/components/zwave/light.py 99.00% <0.00%> (ø) ⬆️
homeassistant/components/axis/config_flow.py 100.00% <0.00%> (ø) ⬆️
homeassistant/components/mqtt/abbreviations.py 100.00% <0.00%> (ø) ⬆️
homeassistant/components/emulated_hue/hue_api.py 90.51% <0.00%> (ø) ⬆️
homeassistant/components/mikrotik/config_flow.py 100.00% <0.00%> (ø)
homeassistant/components/vizio/media_player.py 100.00% <0.00%> (ø)
homeassistant/components/mikrotik/const.py 100.00% <0.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da14e29...1fb9fd0. Read the comment docs.

@springstan springstan merged commit 79495d9 into home-assistant:dev Feb 1, 2020
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please address the comments in a new PR.

if self._battery_level == "low":
_LOGGER.warning("Lock %s has low battery", self._name)
if self._battery_level == "verylow":
_LOGGER.error("Lock %s has very low battery", self._name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't log errors if the application is functioning normally. The low battery level is just a state at the device. It's not a problem with Home Assistant.

The user can make an automation that triggers an alert if the battery level attribute reaches a certain value.

_LOGGER.error("Lock %s has very low battery", self._name)
if (
self.tahoma_device.active_states.get("core:LockedUnlockedState")
== STATE_LOCKED
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't use the home assistant state constant to compare with the tahoma state API. These are two different APIs and either may change independently of the other.

Please define a separate string constant for the tahoma API to use here.


def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Tahoma lock."""
controller = hass.data[TAHOMA_DOMAIN]["controller"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a guard clause here that checks if discovery_info is None and return if so.

@springstan
Copy link
Copy Markdown
Member

Now I feel like I missed these important things 😅 but glad you looked over it @MartinHjelmare

@MartinHjelmare
Copy link
Copy Markdown
Member

Don't worry.

We're all learning here and that means we miss things and sometimes make mistakes etc. If we don't accept that we won't learn either.

You're reviewing great! Keep it up! 👍

@lock lock Bot locked and limited conversation to collaborators Feb 2, 2020
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