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 Vera last user and low battery attributes #27043

Merged
merged 9 commits into from Oct 2, 2019

Conversation

@colohan
Copy link
Contributor

commented Sep 29, 2019

Description:

Adds three attributes to locks on Vera hubs:

  • last_user_id: set to the ID of the user who used their PIN to unlocked the lock in the last poll cycle.
  • last_user_name: set to the text name of the same user.
  • low_battery: set to 1 if a low battery alert was issued in the last poll cycle, 0 otherwise.

This allows users to create automations which trigger when a particular PIN code is used to unlock a door. I've tested it, and it works great on my Home Assistant setup. To function it requires a new version of pyvera which includes this pull request: pavoni/pyvera#119 (but if a user doesn't have that new code yet they just won't get the new functionality, it won't break anything).

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: template
    sensors:
      bike_room_door_unlocked_by_valid_pin:
        friendly_name: "Was the bike room door just unlocked by a valid PIN?"
        value_template: >-
          {% if state_attr('lock.front_door_lock', 'last_user_id') != "unknown" and ((state_attr('lock.front_door_lock', 'last_user_id') | int) > 0) %}
            true
          {% else %}
            false
          {% endif %}

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • [n/a] Tests have been added to verify that the new code works.
homeassistant/components/vera/lock.py Outdated Show resolved Hide resolved
homeassistant/components/vera/lock.py Outdated Show resolved Hide resolved
homeassistant/components/vera/lock.py Outdated Show resolved Hide resolved
homeassistant/components/vera/lock.py Outdated Show resolved Hide resolved
Dev automation moved this from Needs review to Review in progress Sep 29, 2019
@MartinHjelmare MartinHjelmare changed the title Vera attributes for who entered PIN on lock, and low battery warning. Add Vera last user and low battery attributes Sep 29, 2019
@colohan

This comment has been minimized.

Copy link
Contributor Author

commented Oct 1, 2019

@MartinHjelmare

This comment has been minimized.

Copy link
Member

commented Oct 1, 2019

No need to squash. We squash when we merge.

@colohan

This comment has been minimized.

Copy link
Contributor Author

commented Oct 1, 2019

FYI -- a new version of pyvera has been released, and this PR appears to work. Please let me know if there is anything else you'd like me to do (other than hold on to my horses and wait for a merge). Thanks!

Copy link
Member

left a comment

Looks good!

Dev automation moved this from Review in progress to Reviewer approved Oct 2, 2019
@MartinHjelmare MartinHjelmare merged commit ce2e803 into home-assistant:dev Oct 2, 2019
11 checks passed
11 checks passed
CI Build #20191001.66 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python36) Tests PyTest Python36 succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch Coverage not affected when comparing 571ab5a...e63b7a0
Details
codecov/project 94.32% (target 90%)
Details
Dev automation moved this from Reviewer approved to Done Oct 2, 2019
@lock lock bot locked and limited conversation to collaborators Oct 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
3 participants
You can’t perform that action at this time.