I finally got around to trying this using the Global Property Manager Plugin. Some success. Some failure.
I have created a Global Property for 4 of my many devices to test this option.
- Screen Shot 2022-01-03 at 8.37.12 PM.png (45.73 KiB) Viewed 863 times
I have read Jay's post on the GPM Plugin. I have created a test using his code:
- Code: Select all
# First, get the device
myDevice = indigo.devices[1740614719]
# Next, get the props - we use the ID for the server for this particular set of properties
theProps = myDevice.globalProps["com.indigodomo.indigoserver"]
# Finally, access the value of the property. Use the get method here so that you can later test for None in case the property doesn't exist on the device
myPropertyValue = theProps.get("emailBattery", None)
# print value to log
theLogStr = str(myPropertyValue)
indigo.server.log(theLogStr, isError=True)
This works fine. "True" is output to the log. Device 1740614719 is the device in the screenshot.
Then I try it again for another device where I have NOT created any global properties. The script compiles ok, but when I run it it fails and the log entry is:
- Code: Select all
Script Error embedded script: 'key com.indigodomo.indigoserver not found in dict'
Script Error Exception Traceback (most recent call shown last):
embedded script, line 5, at top level
KeyError: 'key com.indigodomo.indigoserver not found in dict'
It seems it fails when no global property exists for a device. My plan was to iterate through all devices.
Suggestions?
I may end up doing as Dave suggested ("You could hard code the list of device ID's into your script") since managing that list is no more onerous, and indeed likely less onerous, than creating a global property for each of the many dozens of devices I want to include in the email. I noted in the GPM post that there appears to be no way to easily create the same property for many or all devices. It has to be done over and over again for each device.
Cheers
John