Skip to content

Support for Aqara door lock#14125

Closed
kerwin612 wants to merge 19 commits intohome-assistant:devfrom
kerwin612:dev
Closed

Support for Aqara door lock#14125
kerwin612 wants to merge 19 commits intohome-assistant:devfrom
kerwin612:dev

Conversation

@kerwin612
Copy link
Copy Markdown
Contributor

@kerwin612 kerwin612 commented Apr 28, 2018

Description:

  • Support new device model.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5329

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

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

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

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

return True


class XiaomiUnlockSubSensor(XiaomiBinarySensor):
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.

What's this and why it's called motion?


def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
if raw_data['cmd'] in ['heartbeat', 'read_ack', 'read_rsp']:
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.

Do you really want to skip the heartbeat? This was/is a workaround for motion sensors.

@syssi
Copy link
Copy Markdown
Member

syssi commented Apr 28, 2018

Could you provide some example responses of the lock?

@kerwin612
Copy link
Copy Markdown
Contributor Author

@syssi when error:{"cmd":"report","model":"lock.aq1","sid":"112316","data":"{\"verified_wrong\":"3"}" }
when fing:{"cmd":"report","model":"lock.aq1","sid":"112316","data":"{\"fing_verified\":"257"}" }
when card:{"cmd":"report","model":"lock.aq1","sid":"112316","data":"{\"card_verified\":"257"}" }
when pwd:{"cmd":"report","model":"lock.aq1","sid":"112316","data":"{\"psw_verified\":"257"}" }

verified_wrongvalue is count error.
fing_verified,card_verified,psw_verifiedvalue is uid.

@syssi
Copy link
Copy Markdown
Member

syssi commented Apr 28, 2018

Do you know/are there API calls for some user management?

@kerwin612
Copy link
Copy Markdown
Contributor Author

kerwin612 commented Apr 28, 2018

configuration like this:

# aqara
xiaomi_aqara:
  gateways:
    - mac: xxxxxxxxxxxxxx
      key: xxxxxxxxxxxxxxxxxx
  lockuids:
    - uid: 65536
    - uid: 65537
    - uid: 196608

The user ID contains the ID type. The integer value obtained by dividing the user ID by 65536 is the ID type. The ID type value is: 1 fingerprint, 2 password, 3 proximity card, 5 check-in password.
uid can find in mihome app,so , can be configured through the user ID list in the mihome app.

@syssi
Copy link
Copy Markdown
Member

syssi commented Apr 29, 2018

@ileler Could you tell me the product number of your acpartner.v3? It's KTBL11LM, correct?

@kerwin612
Copy link
Copy Markdown
Contributor Author

@syssi yes,you are right.

Copy link
Copy Markdown
Member

@syssi syssi left a comment

Choose a reason for hiding this comment

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

The implementation looks like a WIP. There are a lot of motion sensor docstrings and copied code with misleading log messages.

@kerwin612
Copy link
Copy Markdown
Contributor Author

kerwin612 commented Apr 29, 2018

@Danielhiversen @syssi I have already answered before, this is not a WIP.

It may be right to say that it is an imperfect implementation, but I guarantee it is a complete and available implementation. I have already given you a look at the response entity of the lock. Do you know if there is a good component type that matches this type of message? The door lock does not support writing messages. Only the unlock operation report message, so I only use the action sensor to achieve, I pro-test can complete the analysis of all reported messages, such as unsuccessful unlocking, fingerprint unlocking success, door card unlocking success, etc. The accurate analysis can provide a good basis for the playability of the door lock in ha.

Copy link
Copy Markdown
Member

@Danielhiversen Danielhiversen left a comment

Choose a reason for hiding this comment

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

Is it not possible to control the door lock? Only read the state of the lock?

@kerwin612
Copy link
Copy Markdown
Contributor Author

yes,The official will not open the written interface for security

@syssi
Copy link
Copy Markdown
Member

syssi commented May 3, 2018

@ileler What do you need to improve your implementation? I left some comments.

@kerwin612
Copy link
Copy Markdown
Contributor Author

@syssi No, no need. Take a look at our dialogue. Do you think there are other deficiencies in my implementation?

@Danielhiversen
Copy link
Copy Markdown
Member

Danielhiversen commented May 4, 2018

Please answer the comments from @syssi .
The code looks unfinished, and it looks like copy and paste of the motion sensor.
You also need to update the documentation.

@kerwin612
Copy link
Copy Markdown
Contributor Author

Yes, it may be necessary to supplement the documentation on the configuration section

if 'proto' not in device or int(device['proto'][0:1]) == 1:
data_key = 'status'
else:
data_key = 'motion_status'
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.

Why motion_status?

else:
data_key = 'motion_status'
XiaomiBinarySensor.__init__(self, device, 'UnlockSub Sensor',
xiaomi_hub, data_key, 'motion')
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.

Why motion?

@Danielhiversen
Copy link
Copy Markdown
Member

There should not be any "motion" in the lock sensor

@fabaff fabaff changed the title support aqara door lock Support for Aqara door lock May 10, 2018
@syssi
Copy link
Copy Markdown
Member

syssi commented May 12, 2018

I hope you agree with this solution: #14419

@syssi syssi closed this May 12, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 2018
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.

5 participants