matt (support) wrote:A slightly optimized (but untested) version of your script that avoids needing 2 device iter() loops, and breaks out of the loop once it hits the recordRequested-th iteration.
Tested and it worked. I tried a bunch of stuff first, and eventually figured I need to build a list within brackets [] which was my first iter loop. I wish I had a saved version of every script I ran previously to see if anything was close. I tried stuff like, if dev [:3] and all kinds of wonky stuff.
As far as incorporating it into a plugin... my though is to follow the custom device example and create a "Now Showing" device. I was thinking that the firmware prop would be a good place to store the integer. So it would create the device as set the firmware to "0". Then an "Go Forward" or "Go Backward" action would +1 or -1 to that and then use the python scrip to save the state values of the recordRequeted device to the "Now Showing" device......
But I'm already stuck on creating the device....
- Code: Select all
def startup(self):
self.debugLog(u"startup called")
#### Create Now Showing Device for Control Pages ####
if "Now Showing" in indigo.devices:
self.aPersonDev = indigo.devices["Now Showing"]
else:
indigo.server.log(u"Creating Now Showing Device for Control Pages")
self.aPersonDev = indigo.device.create(indigo.kProtocol.Plugin, "Now Showing", "An template for control pages, do not delete" , deviceTypeID="aPerson")
# self.aPersonDev.updateStateImageOnServer(indigo.KStateImageSel.SensorTripped)
# self.aPersonDev.updateStateOnServer(key="homeState", value="Unsure")
# newProps["Firmware"] = 0 # This will be used as the record locatator digit.
def shutdown(self):
self.debugLog(u"shutdown called")
Which results in: Started plugin "My People 1.2.7"
My People Debug startup called
My People Creating Now Showing Device for Control Pages
My People Error Error in plugin execution startup:
Traceback (most recent call last):
File "plugin.py", line 30, in startup
ArgumentError: Python argument types in
DeviceCmds.create(DeviceCmds, kProtocol, str, str)
did not match C++ signature:
create(CDeviceBase::_DeviceCmds {lvalue}, TDevProto protocol, CCString name='', CCString description='', boost::python::api::object folder=None, boost::python::api::object address=None, CCString deviceTypeId='', CCString pluginId='', boost::python::api::object props=None, bool configured=True, boost::python::api::object groupWithDevice=None)