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

Add missing MQTT lock.open #60022

Merged
merged 11 commits into from Nov 25, 2021
Merged

Add missing MQTT lock.open #60022

merged 11 commits into from Nov 25, 2021

Conversation

Hypnos3
Copy link
Contributor

@Hypnos3 Hypnos3 commented Nov 20, 2021

Proposed change

Add support for lock.open to MQTT lock.

Base component documentation: https://developers.home-assistant.io/docs/core/entity/lock#open

Feature request: https://community.home-assistant.io/t/mqtt-lock-open/232823

next try of implementing: #48008

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.

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:

@probot-home-assistant
Copy link

Hey there @emontnemery, mind taking a look at this pull request as it has been labeled with an integration (mqtt) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@project-bot project-bot bot added this to Needs review in Dev Nov 20, 2021
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up, this is indeed a welcome addition!

I think you've covered most of the remarks here: #48008 (comment), but the lock base component still has no STATE_OPEN so:

  • I don't think there's a point in defining a "CONF_STATE_OPEN" configuration option as we can't represent that state in Home Assistant anyway; the lock is either locked or unlocked
  • The tests are trying to import STATE_OPEN from homeassistant.components.lock which doesn't exist

homeassistant/components/mqtt/lock.py Outdated Show resolved Hide resolved
homeassistant/components/mqtt/lock.py Outdated Show resolved Hide resolved
homeassistant/components/mqtt/lock.py Outdated Show resolved Hide resolved
tests/components/mqtt/test_lock.py Outdated Show resolved Hide resolved
homeassistant/components/mqtt/lock.py Outdated Show resolved Hide resolved
Hypnos3 and others added 4 commits November 24, 2021 00:11
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
@Hypnos3
Copy link
Contributor Author

Hypnos3 commented Nov 23, 2021

It is true that the lock itself can only be locked or unlocked.
The door on which the lock is located can, however, be locked, closed or open.
I have an additional contact on my doors that shows me whether it is open.
That depends on whether you look at it from the perspective of the door or the lock.

Since Home Assistant unfortunately can't represent the open state for locks I'm ok by taking it out. I think it already helps most users if, in addition to lock and unlock the opening command can be sent.

@emontnemery
Copy link
Contributor

@Hypnos3 I'm not saying that it's correct or not correct to have an "open" state for LockEntity, I'm just saying that there currently is no such thing so it's not useful to add it to MQTT lock.

You can open an architecture discussion proposing to add an "open" state.
There's already a discussion doing the opposite, proposing to add a "locked" state to covers: home-assistant/architecture#545

Another way would be model a lockable door as a device with a LockEntity and either a CoverEntity or a BinarySensorEntity.

Copy link
Contributor

@emontnemery emontnemery 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, but some lint issues needed fixing

homeassistant/components/mqtt/lock.py Outdated Show resolved Hide resolved
homeassistant/components/mqtt/lock.py Outdated Show resolved Hide resolved
homeassistant/components/mqtt/lock.py Outdated Show resolved Hide resolved
tests/components/mqtt/test_lock.py Show resolved Hide resolved
tests/components/mqtt/test_lock.py Outdated Show resolved Hide resolved
tests/components/mqtt/test_lock.py Show resolved Hide resolved
@emontnemery
Copy link
Contributor

Please open a PR updating the documentation: https://www.home-assistant.io/integrations/lock.mqtt/

@emontnemery emontnemery marked this pull request as ready for review November 24, 2021 11:14
@Hypnos3
Copy link
Contributor Author

Hypnos3 commented Nov 25, 2021

documentation change pull request is this: home-assistant/home-assistant.io#20439

Dev automation moved this from Needs review to Reviewer approved Nov 25, 2021
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

Thanks, @Hypnos3 馃憤

@emontnemery emontnemery merged commit 57fd632 into home-assistant:dev Nov 25, 2021
Dev automation moved this from Reviewer approved to Done Nov 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants