Verisure lock status

Hi,

I am trying to automatically disarm my Verisure alarm in the morning. However I do not get it to work.

My automation is:

  • alias: Stäng av nattlarm
    trigger:
    platform: time
    at: 06:30
    condition:
    condition: state
    entity_id: alarm_control_panel.XXXX_alarm
    state: armed_home
    action:
    • service: alarm_control_panel.alarm_disarm
      entity_id: alarm_control_panel.XXXX_alarm
    • service: persistent_notification.create
      data:
      message: “Jag har försökt larma av”
      title: “Larmtest”

I do get the notification, but the alarm is not turned off.

The error message is:
2018-09-05 06:30:00 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py”, line 224, in _handle_service_platform_call
await getattr(entity, func)(**data)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/alarm_control_panel/verisure.py”, line 87, in alarm_disarm
set_arm_state(‘DISARMED’, code)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/alarm_control_panel/verisure.py”, line 31, in set_arm_state
transaction_id = hub.session.set_arm_state(code, state)[
File “/usr/local/lib/python3.6/site-packages/verisure/session.py”, line 172, in set_arm_state
_validate_response(response)
File “/usr/local/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: 400 - Data: {“errorGroup”:“BAD_REQUEST”,“errorCode”:“VAL_00008”,“errorMessage”:“Invalid or non-existing value for code”}

Can anybody see what I have done wrong?

Det går utmärkt att svara på svenska.

I’m answering in english, since it may be beneficial to non-swedish speakers to learn the answer.
The reason why it’s not working is, as stated in the error message, that you are not supplying the code to the alarm system in your automation.

Thank. It is now solved. I thought that it was not necessary having given the code in the setup. But I now realize that it is needed. Interesting enough it is not needed in Homekit.

Hi all,

How do you solve the automations as the verisure needs the lock code (6-digits) to lock/unlock the door? As I understand I need to save the lock code somwhere…

I used the following format to lock my unlocked doors as I leave the house (automations.yaml):

- id: 'a71'
 alias: 71 - Leaving Home Evening
  trigger: 
    platform: state
    entity_id:
      - group.all_devices
    from: 'home'
    to: 'not_home'
  condition:
    condition: and
    conditions:
      - condition: sun
        after: sunset
      - condition: sun
        before: sunrise
  action:
    - service: scene.turn_on
      entity_id: scene.night
    - service: lock.lock
      data:
        code: !secret house_door_lock_code
        entity_id: group.all_locks

And the in the file secrets.yaml I put my code especially for the user “house”:

house_door_lock_code: 123456

Works like a charm.

Edit: Sorry about the editing of the post, haven’t figured out the formatting yet

Not sure if this is the right place or if I should start a new thread, so tell me to move on if that’s better :-o

I am trying to figure out if there is any way to distinguish between if the lock has been open through a code from the outside, or via the lever on the inside. The reason is that I want to use it as an input to my Bayesian sensor to determine if someone is home or not. I have seen the “changed by” info displayed on my look, so by using open with code or no code I can identify when someone is comming or going.

Any help greatly appreciated.

//Runar

As I can see, No. In the verisure app you see (in swedish) “Låst med stjärnknapp” or “Låst med vred”.
These two attribitus would be nice to use. Problem is, these are not picked up by HA.
This might have something to do with updating the component och some update to the API.
If this attribute is in HA, you’ll have a solution.

/Patrik

screen_lock
If I unlock and leave my door open - this is what I get from HA. As you can see - the state change is picked up. If I enter dev-state, the atribute changed by is visible all of a sudden. Maybe we have something to play with! :smiley: What do you think? :smiley:
{
“changed_by”: “Städfirman”,
“code_format”: “#############”,
“friendly_name”: "Entré "
}

Funny though… i can’t see the “changed by” in my HA.
If it’s there you can use it.

Me neither - unless I leave the door open for a while. I get it when I partially close the door. (I run auto-lock and do not want to mess with that) For the short instanses when just opening and closing, I can not see anything. I tried an animation yesterday, but it did not work, so I might have to go with the solution by @teachingbirds here: https://community.home-assistant.io/t/changed-by-on-verisure-lock-with-auto-lock/59272

1 Like

Hi. I recon this is an old thread, but I’m considering buying a Yale Doorman V2 Verisure lock module and a mBox mini. My intend is to be able to trigger stuff in HA based on locking and unlocking status from the door. And remotely lock/unlock.

Is it possible to integrate Doorman V2 into HA, lock/unlock and se status?

Thanks.

Kind regards,
Esben

Also interested in the lock status reliability. Want to get an instant (within 10 sec) state change when unlocking the door to automatically disarm alarm functionality using node red and Home Assistant. Is this possible? Ping @persandstrom

Many thanks!

No, the verisure status has to be polled and the default polling interval is 60 seconds. This interval seems to be acceptable by verisure. I know that a few has found workarounds, configure verisure to send an email on state change and capture that. Don’t know the probability that that is received within 10seconds though.

Thanks for the answer!
Does anyone know how the workaround is configured?

Somewhat related to the topic.
I have been searching but not found it, so I ask here.

Have anyone been able to read the event history from the lock (Yale Doorman)? In the Verisure app I see who unlocked the door and when they did it. Can I get that info to Home Assistant?

Coming from domoticz to hass.
In domoticz i modified your script and added session. That way I allways had a logged in session to verisure and pulled data of the alarm every 1 second. If the session died it logged in again. That way vsure won’t be sad and see so many logins.

Do you think you can do the the same for the homeassistant plugin? Would be great for turning off/on lights based on alarm state.

def current_date_time(self):
now = datetime.datetime.now()
return now.strftime("%Y-%m-%d %H:%M:%S")

def create_session_and_login(self):
    self.log("create_session_and_login()")
    try:
        session = verisure.Session("XXX", "XXXX")
        session.login()
        return session
    except:
        catch_sleep_retry(True)

def catch_sleep_retry(shouldSleep = False):
global isSleeping
traceback.print_exc()

if shouldSleep == True and isSleeping == False:
    isSleeping = True
    time.sleep(60)

if isSleeping == True:
    isSleeping = False
    setInterval(1)

def set_alarm_state(self, state):
try:
self.log(“set_alarm_state(State: %s)” % state)
pincode = “XXXXXXX”
url = "%s/json.htm?type=command&param=setsecstatus&secstatus=%s&sec$
json.load(self.execute(url))
self.previous_states[“alarm”] = state
# self.thread_timer_alive = False
except:
catch_sleep_retry()`

Hi Jacha,

Sessions are already managed by the plug-in. Right now it polls every minute, and that seems to be acceptable by verisure. If you want to let it poll faster you will have to change the interval in the component. I don’t recommend this though, since verisure has warned people that do request too often.

/Per

Ok where/what file to edit?

https://github.com/home-assistant/home-assistant/blob/2e079029999ac8fb1b25376aafdf4838e4929c71/homeassistant/components/verisure/init.py

You must set MIN_SCAN_INTERVAL, SCAN_INTERVAL can be set in config