Fire process_sequence immediately if no further options
parent
18bfa01f0f
commit
e58b1b21ed
13
wallmote.py
13
wallmote.py
|
@ -35,6 +35,8 @@ class WallmotePlumbing(hass.Hass):
|
|||
def shortpress(self, key):
|
||||
self.currentSequence.append(key);
|
||||
self.reset_tot();
|
||||
# Don't wait for tot to expire if we've already hit the end of a branch
|
||||
if (self.check_action(self.currentSequence.copy())): self.process_sequence();
|
||||
|
||||
def reset_tot(self):
|
||||
if (hasattr(self,"tot")): self.tot.cancel();
|
||||
|
@ -48,6 +50,17 @@ class WallmotePlumbing(hass.Hass):
|
|||
self.log(sequence);
|
||||
self.run_action(sequence);
|
||||
|
||||
def check_action(self, sequence, tree=tree):
|
||||
if (len(sequence) > 0):
|
||||
# Deeper into the rabbit hole
|
||||
category = sequence.pop(0);
|
||||
if (category in tree): return self.check_action(sequence,tree[category]);
|
||||
else: return false;
|
||||
else:
|
||||
# We've the end of the sequence thus far, check if this is the end of a branch
|
||||
# If any of {1..4} exist as keys in tree there's more options
|
||||
return not any(i in tree for i in range(1,4));
|
||||
|
||||
def run_action(self, sequence, tree=tree):
|
||||
if (len(sequence) > 0):
|
||||
# Deeper into the rabbit hole
|
||||
|
|
Loading…
Reference in New Issue