Change virtual switch depending on state of JSON
Posted: Wednesday 20 October 2021 21:06
Hi!
I have made a simple python script that will return "LOCKED" or "UNLOCKED" on my door using Verisure's API (a swedish security company). How do I implement it in domoticz so that the virtual switch changes state depending on the JSON value? My script looks like this:
Get status:
Change lock status:
Thanks beforehand!
Best regards Max
I have made a simple python script that will return "LOCKED" or "UNLOCKED" on my door using Verisure's API (a swedish security company). How do I implement it in domoticz so that the virtual switch changes state depending on the JSON value? My script looks like this:
Get status:
Code: Select all
import verisure
session = verisure.Session('xxxx', 'xxxx')
session.login()
overview = session.get_overview()
session.logout()
for i in overview['doorLockStatusList']:
print(i['lockedState'])
Code: Select all
import verisure
session = verisure.Session('xxxx', 'xxxx')
session.login()
overview = session.get_overview()
for i in overview['doorLockStatusList']:
lockState = i['lockedState']
if lockState == "LOCKED":
session.set_lock_state("xxxxxx", "xxxx xxxx", "unlock")
print(i['lockedState'])
if lockState == "UNLOCKED":
session.set_lock_state("xxxxxx", "xxxx xxxx", "lock")
print(i['lockedState'])
session.logout()
Best regards Max