Verisure smartlock - configure pincode

Hello,

Is it possible to add the pincode to the configuration of the verisure yale door lock? Or add it in the code itself?
I know I can add it using automation, but I would like the locks to work directly using the sliders and aslo from the hadashboard:

sliders

When pressing the liders I get this in the log:

2018-02-20 10:02:06 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall lock.unlock: entity_id=['lock.main_door']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/lock/__init__.py", line 101, in async_handle_lock_service
    yield from entity.async_unlock(code=code)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/lock/verisure.py", line 99, in unlock
    self.set_lock_state(kwargs[ATTR_CODE], STATE_UNLOCKED)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/lock/verisure.py", line 113, in set_lock_state
    lock_state)['doorLockStateChangeTransactionId']
  File "/srv/homeassistant/lib/python3.5/site-packages/verisure/session.py", line 285, in set_lock_state
    _validate_response(response)
  File "/srv/homeassistant/lib/python3.5/site-packages/verisure/session.py", line 15, in _validate_response
    raise ResponseError(response.status_code, response.text)
verisure.session.ResponseError: Invalid response, status code: 400 - Data: {"errorGroup":"BAD_REQUEST","errorCode":"VAL_00008","errorMessage":"Invalid or non-existing value for code"}

Hi @kjetilsn. I had the same question/problem. I solved it by following a hint from GitHub issue:
https://github.com/home-assistant/home-assistant/pull/1136#issuecomment-228355922

I ended up with creating the following switch configuration:

switch:
  platform: template
  switches:
    yale_lock:
      friendly_name: 'My door'
      value_template: "{{ is_state('lock.ytterdr', 'locked') }}"
      turn_on:
        service: lock.lock
        data:
          entity_id: lock.ytterdr
          code: !secret verisure_lock_code
      turn_off:
        service: lock.unlock
        data:
          entity_id: lock.ytterdr
          code: !secret verisure_lock_code

You will need to replace lock.ytterdr with the ID of your entity and add your PIN code for verisure_lock_code in the secrets.yaml file.

Thank you grEvenX, I’ll give it try!

did you get the yale lock to work?

It did work fine, however I now get state “on” and “off” instead of “locked” and “unlocked” using the template switch. But it is useful in the HA interface on my phone when locking and unlocking. Kept the original lock entity for my hadashboard though.

I am relatively new to home automation.
Can you see what I’ve done wrong?

yaml

Did you get errors in your log?
Did you not see new entity called switch.yale_lock?

2018-04-10 19:33:10 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall lock.lock: entity_id=[‘lock.inngangsdr’], code=1334> !!!(this code in wrong)!!!
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/core.py”, line 1002, in _event_to_service_call
await service_handler.func(service_call)
File “/usr/lib/python3.6/site-packages/homeassistant/components/lock/init.py”, line 114, in async_handle_lock_service
yield from entity.async_lock(code=code)
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(self.args, self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/lock/verisure.py”, line 105, in lock
self.set_lock_state(kwargs[ATTR_CODE], STATE_LOCKED)
File “/usr/lib/python3.6/site-packages/homeassistant/components/lock/verisure.py”, line 113, in set_lock_state
lock_state)[‘doorLockStateChangeTransactionId’]
File “/usr/lib/python3.6/site-packages/verisure/session.py”, line 285, in set_lock_state
_validate_response(response)
File “/usr/lib/python3.6/site-packages/verisure/session.py”, line 15, in _validate_response
raise ResponseError(response.status_code, response.text)
verisure.session.ResponseError: Invalid response, status code: 401 - Data: {“errorGroup”:“UNAUTHORIZED”,“errorCode”:“AUT_00008”,“errorMessage”:“User has been blacklisted due to subsequent failed attempts”}
2018-04-10 19:34:43 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall lock.lock: code=
***, entity_id=[‘lock.inngangsdr’]> !!!(this code is correct)!!!
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/core.py”, line 1002, in _event_to_service_call
await service_handler.func(service_call)
File “/usr/lib/python3.6/site-packages/homeassistant/components/lock/init.py”, line 114, in async_handle_lock_service
yield from entity.async_lock(code=code)
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/lock/verisure.py”, line 105, in lock
self.set_lock_state(kwargs[ATTR_CODE], STATE_LOCKED)
File “/usr/lib/python3.6/site-packages/homeassistant/components/lock/verisure.py”, line 113, in set_lock_state
lock_state)[‘doorLockStateChangeTransactionId’]
File “/usr/lib/python3.6/site-packages/verisure/session.py”, line 285, in set_lock_state
_validate_response(response)
File “/usr/lib/python3.6/site-packages/verisure/session.py”, line 15, in _validate_response
raise ResponseError(response.status_code, response.text)
verisure.session.ResponseError: Invalid response, status code: 401 - Data: {“errorGroup”:“UNAUTHORIZED”,“errorCode”:“AUT_00008”,“errorMessage”:“User has been blacklisted due to subsequent failed attempts”}

but now i have been blacklisted so have to wait 15 minutes :smile:

The switch has appeared in the home assistant

bryter

Do anyone of you know why my lock isn’t opening the dialog for pincode? I’m using the Verisure component.

My lock requires 6 digits but whenever I press “Lock” / “Unlock” it just says the command is sent and the dialog for pincode is never opened.