This resolves Issue #284, which pointed out that one of the formats for creating template switches used in the examples no longer works.
Consider this snippet:
run_seconds:
0: 60
1: 60
2: 60
3: 60
4: 60
5: 60
If this is called as part of opensprinkler.run from Developer tools > Services, the keys are converted to strings, which is what the code expects. However, if it is part of a template switch, they arrive as integers, which dict.get() interprets as a lookup failure and returns None. Ultimately, the run durations are set to 0.
This PR attempts to find both int and str keys. If you know of a better way to cover both cases than to use the default parameter of dict.get(), please speak up.
This resolves Issue #284, which pointed out that one of the formats for creating template switches used in the examples no longer works.
Consider this snippet:
If this is called as part of
opensprinkler.run
fromDeveloper tools > Services
, the keys are converted to strings, which is what the code expects. However, if it is part of a template switch, they arrive as integers, whichdict.get()
interprets as a lookup failure and returnsNone
. Ultimately, the run durations are set to 0.This PR attempts to find both int and str keys. If you know of a better way to cover both cases than to use the
default
parameter ofdict.get()
, please speak up.