|
@@ -0,0 +1,51 @@
|
|
|
+import argparse
|
|
|
+import logging
|
|
|
+
|
|
|
+import intertechno_cc1101
|
|
|
+
|
|
|
+_LOGGER = logging.getLogger(__name__)
|
|
|
+
|
|
|
+
|
|
|
+def _main():
|
|
|
+ argparser = argparse.ArgumentParser(
|
|
|
+ description="Control Intertechno Outlets via CC1101 Transceivers"
|
|
|
+ )
|
|
|
+ argparser.add_argument(
|
|
|
+ "-a",
|
|
|
+ "--address",
|
|
|
+ type=int,
|
|
|
+ help="address of emulated remote control ({}-bit unsigned integer)".format(
|
|
|
+ # pylint: disable=protected-access; internal
|
|
|
+ intertechno_cc1101._ADDRESS_LENGTH_BITS
|
|
|
+ ),
|
|
|
+ required=True,
|
|
|
+ )
|
|
|
+ argparser.add_argument(
|
|
|
+ "-b",
|
|
|
+ "--button-index",
|
|
|
+ type=int,
|
|
|
+ help="index of button on emulated remote control"
|
|
|
+ " ({}-bit unsigned integer, default: %(default)d)".format(
|
|
|
+ # pylint: disable=protected-access; internal
|
|
|
+ intertechno_cc1101._BUTTON_INDEX_LENGTH_BITS
|
|
|
+ ),
|
|
|
+ default=0,
|
|
|
+ )
|
|
|
+ action_arg_group = argparser.add_mutually_exclusive_group(required=True)
|
|
|
+ action_arg_group.add_argument("-1", "--turn-on", action="store_true")
|
|
|
+ action_arg_group.add_argument("-0", "--turn-off", action="store_true")
|
|
|
+ argparser.add_argument("-d", "--debug", action="store_true")
|
|
|
+ args = argparser.parse_args()
|
|
|
+ logging.basicConfig(
|
|
|
+ level=logging.DEBUG if args.debug else logging.INFO,
|
|
|
+ format="%(asctime)s:%(levelname)s:%(name)s:%(funcName)s:%(message)s"
|
|
|
+ if args.debug
|
|
|
+ else "%(message)s",
|
|
|
+ datefmt="%Y-%m-%dT%H:%M:%S%z",
|
|
|
+ )
|
|
|
+ _LOGGER.debug("args=%r", args)
|
|
|
+ remote_control = intertechno_cc1101.RemoteControl(address=args.address)
|
|
|
+ if args.turn_on:
|
|
|
+ remote_control.turn_on(button_index=args.button_index)
|
|
|
+ else:
|
|
|
+ remote_control.turn_on(button_index=args.button_index)
|