Specific Device Check with Python
Posted: Thu Nov 07, 2019 5:34 pm
I'm trying to figure out a script to check specific devices. These are all devices that make up the perimeter of my home: z-wave door locks, insteon garage doors, DSC doors/windows.
What I have now is working... but IMO it's a pretty messing looking script (the first if is like 3 feet long). The end result is a one line message:
A) "House is Secure"
or
B) "House is not secure. Check (list of unlocked/open devices)".
Has anyone else done something like this or have a better way to do the same thing?
What I have now is working... but IMO it's a pretty messing looking script (the first if is like 3 feet long). The end result is a one line message:
A) "House is Secure"
or
B) "House is not secure. Check (list of unlocked/open devices)".
Has anyone else done something like this or have a better way to do the same thing?
- Code: Select all
theMessage = "House is not secure. Check "
if indigo.devices[649246778].onState == True and indigo.devices[1996124477].states['binaryInput1'] is True and indigo.devices[628198642].states['binaryInput1'] is True and indigo.devices[542492456].states['state.open'] is False and indigo.devices[629336732].states['state.open'] is False and indigo.devices[195317907].states['state.open'] is False and indigo.devices[1036911557].states['state.open'] is False and indigo.devices[752595934].states['state.open'] is False and indigo.devices[1798016138].states['state.open'] is False and indigo.devices[1862120226].states['state.open'] is False and indigo.devices[1969267507].states['state.open'] is False:
theMessage = "House is Secure"
if indigo.devices[649246778].onState == False:
theMessage = theMessage + "front door lock, "
if indigo.devices[628198642].states['binaryInput1'] is False:
theMessage = theMessage + "Right Garage Door, "
if indigo.devices[1996124477].states['binaryInput1'] is False:
theMessage = theMessage + "Left Garage Door, "
if indigo.devices[542492456].states['state.open'] is True:
theMessage = theMessage + "Front Door, "
if indigo.devices[629336732].states['state.open'] is True:
theMessage = theMessage + "Laundry Door, "
if indigo.devices[195317907].states['state.open'] is True:
theMessage = theMessage + "Side Door, "
if indigo.devices[1036911557].states['state.open'] is True:
theMessage = theMessage + "Back Door, "
if indigo.devices[752595934].states['state.open'] is True:
theMessage = theMessage + "Kitchen Windows, "
if indigo.devices[1798016138].states['state.open'] is True:
theMessage = theMessage + "Master Bedroom Windows, "
if indigo.devices[1862120226].states['state.open'] is True:
theMessage = theMessage + "Nursery Windows, "
if indigo.devices[1969267507].states['state.open'] is True:
theMessage = theMessage + "Front Windows, "
indigo.server.log(theMessage)