I have been using the schedule method for a long time to set devices to refresh, daily check for new driver versions, etc... I think I have the basics of it down pretty well. However, I am trying to make use of the options map it allows for with my version checking to set the driver name and current version so I can have it in just one place in the code AND make that update check the exact same regardless (so it can eventually be in a library).
The wiki is a little light on the example, as there is none about the Map for the options. It apparently does not work or is not saved across the scheduler the same way. Can someone clue me in on how it should be used?
Here are a few code fragments I am using for testing examples:
- This one should run the CheckForUpdate every hour based on the Second and Minute values. That portion works great but the Map data does not appear to be passed. The "options" value is always null.
schedule( "${ Second } ${ Minute } * ? * *", "CheckForUpdate", [ 'Driver Name': "UnifiProtectAPI", 'Driver Version': "0.2.1" ] )
def CheckForUpdate( Map options = null ){
if( options != null ){
Logging( "Data = ${ options }", 3 )
ProcessState( "Driver Name", options.'Driver Name' )
ProcessState( "Driver Version", options.'Driver Version' )
}
...
- Here is one where I call CheckForUpdate directly (not as part of a schedule) that passes the options without issue.
CheckForUpdate( [ 'Driver Name': "UnifiProtectAPI", 'Driver Version': "0.2.0" ] )
- Putting the options Map into the handler portion provides an "expecting ')', found 'UnifiProtectAPI' @ line"... error when saving:
schedule( "${ Second } ${ Minute } * ? * *", "CheckForUpdate( [ 'Driver Name': "UnifiProtectAPI", 'Driver Version': "0.2.1" ] )" )
- Putting similar code in but escaping the quotes to be able to actually save it treats the whole thing as the hander name, which obviously does not exist and gets an error:
schedule( "${ Second } ${ Minute } * ? * *", "CheckForUpdate( [ 'Driver Name': \"UnifiProtectAPI\", 'Driver Version': \"0.2.1\" ] )" )