python-verisure icon indicating copy to clipboard operation
python-verisure copied to clipboard

Read autolock status

Open jacobhallgren opened this issue 2 years ago • 14 comments

Would be nice like in the verisure app to see the state of the lock. If autolock is enabled or not.

jacobhallgren avatar May 21 '22 09:05 jacobhallgren

Hi,

You can see that using the overview command.

persandstrom avatar May 21 '22 19:05 persandstrom

Hi,

You can see that using the overview command.

Which field?

The "method" that says auto is just if it was locked by the autolock. Not if autolock is enabled.

jacobhallgren avatar May 21 '22 19:05 jacobhallgren

You are correct! I recently got a lock myself and i'm not very familiar with it yet.

I added a new command to the the m-api branch, '--door-lock-configuration'. This branch only has support for the devices I own so far...

Sadly I can't add new commands to the master branch due to that the app has changed to a new API

persandstrom avatar May 21 '22 21:05 persandstrom

You are correct! I recently got a lock myself and i'm not very familiar with it yet.

I added a new command to the the m-api branch, '--door-lock-configuration'. This branch only has support for the devices I own so far...

Sadly I can't add new commands to the master branch due to that the app has changed to a new API

Thank you will try that out. Another question do you know a good way to read events like firealarm and get that info in to home assistant? Is there someway to run this script from home assistant and get info like water leak, fire etc.?

jacobhallgren avatar May 21 '22 21:05 jacobhallgren

Possibly you could get the information from the event log, but I would not call that a good way, and it is not supported by home-assistant so you would need to use a shell command or similar.

I added a command for setting auto-lock enabled/disabled and event-log to the m-api branch as well.

persandstrom avatar May 21 '22 21:05 persandstrom

Possibly you could get the information from the event log, but I would not call that a good way, and it is not supported by home-assistant so you would need to use a shell command or similar.

In my experience a good way to provide Verisure status information of all kind is to run a Python script with the python-verisure module and publish/subscribe to a MQTT broker. This would give you a generic solution that most "modern" sw including HA and Node-RED supports. I do that since years, including support for commands to SmartPlugs, rock solid. Only disadvantage is that we still have to poll for information, the push support used in apps seems to be "hidden away" somehow?

krambriw avatar May 22 '22 05:05 krambriw

Possibly you could get the information from the event log, but I would not call that a good way, and it is not supported by home-assistant so you would need to use a shell command or similar.

In my experience a good way to provide Verisure status information of all kind is to run a Python script with the python-verisure module and publish/subscribe to a MQTT broker. This would give you a generic solution that most "modern" sw including HA and Node-RED supports. I do that since years, including support for commands to SmartPlugs, rock solid. Only disadvantage is that we still have to poll for information, the push support used in apps seems to be "hidden away" somehow?

This sound like a good solution. Can you explain a bit more in detail how I can achieve that. Share your setup or so? I'm also using node red. I short what I want to accomplish is turn on all lights when fire alarm is triggered. For getting instant alerts when something happens I create automations in verisure to turn on a smartplug, thats connects to a shelly 1. When Home assistant see the sensor on shelly 1 turn on I'm polling verisure for an update. If you this way opens a door it takes 1-2 seconds for HA to get the status.

@persandstrom Would it somehow be possible to get push alerts to this python module?

jacobhallgren avatar May 22 '22 09:05 jacobhallgren

@jacobhallgren not at the moment. And I'm not sure how to do it. I'll add an investigation of that to my to-do list.

persandstrom avatar May 22 '22 09:05 persandstrom

@jacobhallgren not at the moment. And I'm not sure how to do it. I'll add an investigation of that to my to-do list.

@persandstrom Thanks, really appreciate it. Would open up so many possibilities with instant alerts on event.

jacobhallgren avatar May 22 '22 19:05 jacobhallgren

@jacobhallgren I cant find a solution on how to capture push notifications. You could enable email notifications and trigger on those.

persandstrom avatar May 24 '22 05:05 persandstrom

@krambriw Can you share more in detail about your setup?

jacobhallgren avatar May 27 '22 16:05 jacobhallgren

I can make a write up and provide examples of what I did I run a python script, Node-RED and Mosquitto MQTT broker, all on a Raspberry Pi. Currently just supporting arm statuses and smart plugs but I see no reason why it cannot be extended if needed

You will have to install some additional stuff

  • install Mosquitto MQTT broker
  • install the python-verisure module
  • modify a file in python-verisure in the section for smart-plugs
  • create a copy of the script with your login credentials
  • using PIP to install some additional python libraries needed for the script
  • test the script via command prompt until it is running as expected
  • Install Node-RED and import a sample flow that will handle the start, monitoring and restarts if needed of your script

If you feel fully comfortable with all this, it all sounds familiar, I can continue here or we can take it offfline

krambriw avatar May 28 '22 05:05 krambriw

@krambriw Thank you for the details. Yes I feel comfortable with that. Please provide the script details. Do you also use this with Home Assistant?

jacobhallgren avatar May 31 '22 19:05 jacobhallgren

I do not use HA anymore, I did earlier with some Z-Wave devices but all is now replaced with Node-RED. The script supports MQTT so you should be able to use it along with HA as well

In the attached script you need to add your configuration details: Your verisure user name and password, your ip to your MQTT broker username = 'your_username' password = 'your_password' locale = 'sv_SE' mqtt_broker = '127.0.0.1'

The script is checking the armstatus every 3x pollinterval (30 seconds). You can change this with the param pollinterval = 10

I run the script with python3 like "python3 /home/pi/VerisureSystemInterface.py". You will have to install some python modules using pip3 to make it work. By trying to run it from the command prompt you will find out what modules you are missing, all required are listed in the start of the script:

import time import verisure import paho.mqtt.client as mqtt import os import subprocess import signal from sys import exit from threading import Thread, Event, Condition from setproctitle import setproctitle

First step is to make the script running in your system. Next I will explain and show you how to start, control and integrate it with Node-RED

Best regards, Walter

PS change the extension of the attached script from .txt to .py

VerisureSystemInterface.txt

krambriw avatar Jun 01 '22 06:06 krambriw