Decode integers to binary when controlling switches
This commit is contained in:
parent
72c3bfab91
commit
d54ae9354e
1 changed files with 10 additions and 5 deletions
|
@ -210,6 +210,11 @@ class C4Room:
|
|||
userinput = self._interactive_light_switch()
|
||||
|
||||
if len(userinput) != len(self.switches):
|
||||
if int(userinput) <= 15:
|
||||
# Try to interpret as integer
|
||||
binary = bin(int(userinput))[2:]
|
||||
userinput = str(len(self.switches)*'0')[:-len(binary)] + binary
|
||||
else:
|
||||
print("Error: wrong number of digits (expected {}, got {})!".format(
|
||||
len(self.switches), len(userinput)))
|
||||
return False
|
||||
|
@ -953,7 +958,7 @@ if __name__ == "__main__":
|
|||
help="apply local colorscheme PRESET to Fnordcenter")
|
||||
group_cl.add_argument(
|
||||
"-m", "--magic", action="store_true", default=False,
|
||||
help="EXPERIMENTAL: blend into preset (needs a running instance of fluffyd)")
|
||||
help="EXPERIMENTAL: blend into preset (needs a running instance of fluffyd on the network)")
|
||||
group_cl.add_argument(
|
||||
"-l", "--list-presets", action="store_true",
|
||||
help="list locally available presets")
|
||||
|
@ -971,7 +976,7 @@ if __name__ == "__main__":
|
|||
help="list remote presets for ROOM")
|
||||
# Switch control
|
||||
group_sw = parser.add_argument_group(title="light switch control",
|
||||
description="The optional DIGIT_CODE is a string of 0s or 1s for every light in the room. Works interactivly if missing.")
|
||||
description="The optional DIGIT_CODE is a string of 0s or 1s for every light in the room. Works interactively if missing.")
|
||||
group_sw.add_argument(
|
||||
"-W", nargs='?', dest="w_switch", const="", metavar="DIGIT_CODE",
|
||||
help="switch lights in Wohnzimmer on/off")
|
||||
|
|
Loading…
Reference in a new issue