I really appreciate the help and guidance.
Here are the results
- Code: Select all
for dev in indigo.devices:
try:
# Attempt to use dev.onState. If it doesn't exist, it will fall through to the except block
# This line will print the id, name, and onState value. it substitutes items in the format
# functions parameter list for the curly brackets
indigo.server.log(u"id: {}, name: {}, onState: {}".format(dev.id, dev.name, dev.onState))
# Do whatever else you want to do here for devices with an onState
if dev.onState == True:
indigo.server.log( "Found Device: " + dev.name + "Break loop")
break
except:
# We get here if there is no onState, or if any other exception is raised. I think
# you don't actually want to do anything, so we'll just pass, which means do nothing
indigo.server.log( "in the exception processing" )
pass
# indigo.server.log(u"id: {}, name: {}, onState: {}".format(dev.id, dev.name, dev.onState))
# Do whatever else you want to do here for devices with an onState
Code will run in the embedded script editor:
Aug 28, 2021 at 9:23:42 AM
Script id: 1384093992, name: 006 - Humidity, onState: None
Script id: 1873696535, name: 006 - Leak Sensor, onState: False
Script id: 316739640, name: 006 - Tamper, onState: False
Script id: 77470459, name: 006 - Temperature, onState: None
Script in the exception processing
Script id: 553374040, name: 008 - Button 1, onState: False
Script id: 47791506, name: 008 - Button 2, onState: False
Script id: 93060902, name: 008 - Button 3, onState: False
Script id: 1451990799, name: 008 - Security Siren, onState: False
Script id: 1209823218, name: 008 - Tamper Alert, onState: False
Script in the exception processing
Script in the exception processing
But when a real alarm is triggered, I get the following...
Aug 28, 2021 at 9:24:12 AM
Z-Wave Debug RCVD requestAlarmSensorStatus: 01 0F 00 04 00 06 09 71 05 00 00 00 FF 05 02 00 12
Z-Wave Debug . . requestAlarmSensorStatus: node 006, endpoint None, cmdClass 71, type 0, value 0, classSubKey 710000
Z-Wave Debug . . requestAlarmSensorStatus: typeExt 5, valueExt 2, classSubKeyExt 7100000502
Z-Wave Debug . . requestAlarmSensorStatus: defnStatusByte 255
Z-Wave received "006 - Leak Sensor" status update is on
Trigger Water Leak Sensor Activated
Trigger Water Leak Sensor Activated Siren
006 - Humidity 1384093992
Script None
006 - Leak Sensor 1873696535
Script True
006 - Tamper 316739640
Script False
006 - Temperature 77470459
Script None
007 - Z-Wave Repeater (ZW189) 1219598056
Script In the except section
Script Error embedded script: 'Device' object has no attribute 'onState'
Script Error Exception Traceback (most recent call shown last):
embedded script, line 17, at top level
AttributeError: 'Device' object has no attribute 'onState'