From d2aab86956540afc3edba12164768a78e3820c40 Mon Sep 17 00:00:00 2001 From: Shy Date: Thu, 30 Mar 2017 18:13:10 +0200 Subject: [PATCH] Some minor fixes --- c4ctrl.py | 15 ++++++++------- c4ctrl.vim | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/c4ctrl.py b/c4ctrl.py index fb0216f..d3eae0e 100755 --- a/c4ctrl.py +++ b/c4ctrl.py @@ -251,7 +251,7 @@ class C4Room: light.set_color(colorscheme.color_for(light.topic)) cmd.append({ - "topic" : Fluffy().ghost_of(light.topic), + "topic" : Fluffy().ghostly_topic(light.topic), "payload" : Fluffy().ghostly_payload(light.payload, mode_id) }) else: @@ -813,6 +813,7 @@ class Fluffy: """Fluffyd functions.""" modes = { + # Fluffy modes and their id's "fade" : 1, "wave" : 4, "pulse" : 8, @@ -820,7 +821,7 @@ class Fluffy: "flash" : 12 } - def ghost_of(self, topic): + def ghostly_topic(self, topic): # Return the ghost topic of topic return "ghosts" + topic[topic.find('/'):] @@ -828,9 +829,9 @@ class Fluffy: return payload + int(mode_id).to_bytes(1, "little") def mode_id(self, name): - if name.isdecimal(): - if int(name) in self.modes.values(): - return (int(name), False) + if name.isdecimal() and int(name) <= 255: + # Let's trust the user with this + return (int(name), False) else: if name.lower() in self.modes.keys(): return (self.modes[name.lower()], False) @@ -1047,7 +1048,7 @@ if __name__ == "__main__": help="apply local colorscheme PRESET to Fnordcenter") group_cl.add_argument( "-m", "--magic", type=str, default="fade", metavar="MODE", - help="EXPERIMENTAL: blend into preset (needs a running instance of fluffyd on the network). MODE is either \"fade\", \"wave\", \"emp[1]\", \"flash\" or \"none\".") + help="EXPERIMENTAL: blend into preset (needs a running instance of fluffyd on the network). MODE is either \"fade\", \"wave\", \"pulse\", \"emp\", \"flash\" or \"none\".") group_cl.add_argument( "-l", "--list-presets", action="store_true", help="list locally available presets") @@ -1056,7 +1057,7 @@ if __name__ == "__main__": help="store current state as preset NAME ('-' to write to stdout)") # Switch control group_sw = parser.add_argument_group(title="light switch control", - description="BINARY_CODE is a string of 0s or 1s for every light in the room. Accepts integers also. Will show some information and ask for input if missing.") + description="BINARY_CODE is a string of 0s or 1s for every light in the room. Accepts integers also. Will show some information and ask for input if omitted.") group_sw.add_argument( "-W", nargs='?', dest="w_switch", const="", metavar="BINARY_CODE", help="switch lights in Wohnzimmer on/off") diff --git a/c4ctrl.vim b/c4ctrl.vim index 6d0e9d9..2c5b7f8 100644 --- a/c4ctrl.vim +++ b/c4ctrl.vim @@ -1,6 +1,6 @@ " Vim plugin to use some functionality of c4ctrl from within Vim. " -" Last Change: 2017 Mar 28 +" Last Change: 2017 Mar 29 " Maintainer: Shy " License: This file is placed in the public domain. "