def main(): parser = ArgumentParser( description="Control a Panasonic VIERA TV") parser.add_argument("tv_hostname", help="IP or Hostname of TV to control") parser.add_argument("qth_path_prefix", help="Qth path prefix.") parser.add_argument("--update-interval", "-i", default=1.0, type=float, help="Update interval for power state in seconds. " "(default %(default)s).") parser.add_argument("--host", "-H", default=None, help="Qth server hostname.") parser.add_argument("--port", "-P", default=None, type=int, help="Qth server port.") parser.add_argument("--keepalive", "-K", default=10, type=int, help="MQTT Keepalive interval (seconds).") parser.add_argument("--version", "-V", action="version", version="%(prog)s {}".format(__version__)) args = parser.parse_args() client = qth.Client( "qth_panasonic_viera", "Panasonic VIERA TV control.", loop=loop, host=args.host, port=args.port, keepalive=args.keepalive, ) tv = panasonic_viera.RemoteControl(args.tv_hostname) loop.run_until_complete(async_main(client, tv, args.qth_path_prefix, args.update_interval)) loop.run_forever()
def main(): """ Handle command line execution. """ parser = argparse.ArgumentParser(prog='panasonic_viera', description='Remote control a Panasonic Viera TV.') parser.add_argument('host', metavar='host', type=str, help='Address of the Panasonic Viera TV') parser.add_argument('command', metavar='command', type=str, nargs='?', default="", help='Command issued to Panasonic Viera TV') parser.add_argument('arg', metavar='arg', type=str, nargs='?', default="", help='Argument to the command') parser.add_argument('--port', metavar='port', type=int, default=panasonic_viera.DEFAULT_PORT, help='Port of the Panasonic Viera TV. Defaults to {}.'.format(panasonic_viera.DEFAULT_PORT)) parser.add_argument('--verbose', dest='verbose', action='store_const', const=True, default=False, help='debug output') args = parser.parse_args() if args.verbose: logging.basicConfig(level=logging.DEBUG) remote_control = RemoteControl(panasonic_viera.RemoteControl(args.host, args.port)) runner = CommandRunner() runner.command('get_device_info', remote_control.get_device_info) runner.command('open_webpage', remote_control.open_webpage) runner.command('launch_app', remote_control.launch_app) runner.command('get_apps', remote_control.get_apps) runner.command('get_vector_info', remote_control.get_vector_info) runner.command('get_input_mode', remote_control.get_input_mode) runner.command('set_input', remote_control.set_input) runner.command('get_volume', remote_control.get_volume) runner.command('set_volume', remote_control.set_volume) runner.command('get_mute', remote_control.get_mute) runner.command('set_mute', remote_control.set_mute) runner.command('turn_off', remote_control.turn_off) runner.command('volume_up', remote_control.volume_up) runner.command('volume_down', remote_control.volume_down) runner.command('mute_volume', remote_control.mute_volume) runner.command('turn_off', remote_control.turn_off) runner.command('turn_on', remote_control.turn_on) runner.command('send_key', remote_control.send_key) runner.command('send_keycode', remote_control.send_keycode) runner.command('exit', sys.exit) if args.command != "": return runner.run(args.command + " " + args.arg) else: return Console(runner).run()
def listen(): logger.info("Time to get the IPs for the different devices") ipscan() counter = 0 try: rc = panasonic_viera.RemoteControl(iplist["bedtv"]) except: logger.warning("Error initializing TV remote:\n{}".format(traceback.format_exc())) logger.info("Starting listener") while True: try: if counter > 0: if check_play() == False: counter -= 1 play_random() except: print(traceback.format_exc(1)) try: for dweep in dweepy.listen_for_dweets_from('sgsmcpi', 60): logger.info("Dweep received:\n{}".format(dweep)) for key in dweep["content"].keys(): logger.info("Processing key {}".format(key)) if key == 'volume_up': volume_up() elif key == "volume_down": volume_down() elif key == "volume_down": volume_down() elif key == "play": counter = 8 play_random() elif key == "stop_play": counter = 0 kill_mp3() elif key == "wake_pc": logger.info("Running wake_pc") wake_pc(maclist['spc']) elif key == "minoli_pc": wake_pc(maclist['Minolispc']) elif key == "bedtime": shield_on() elif key == "goodnight": tv_off() elif key == "wah": wake_pc(maclist['worklaptop']) except: print(traceback.format_exc(1))
def main(): """ Handle command line execution. """ parser = argparse.ArgumentParser( prog='panasonic_viera', description='Remote control a Panasonic Viera TV.') parser.add_argument('host', metavar='host', type=str, help='Address of the Panasonic Viera TV') parser.add_argument( 'port', metavar='port', type=int, nargs='?', default=panasonic_viera.DEFAULT_PORT, help='Port of the Panasonic Viera TV. Defaults to {}.'.format( panasonic_viera.DEFAULT_PORT)) parser.add_argument('--verbose', dest='verbose', action='store_const', const=True, default=False, help='debug output') args = parser.parse_args() if args.verbose: logging.basicConfig(level=logging.DEBUG) remote_control = RemoteControl( panasonic_viera.RemoteControl(args.host, args.port)) runner = CommandRunner() runner.command('open_webpage', remote_control.open_webpage) runner.command('get_volume', remote_control.get_volume) runner.command('set_volume', remote_control.set_volume) runner.command('get_mute', remote_control.get_mute) runner.command('set_mute', remote_control.set_mute) runner.command('turn_off', remote_control.turn_off) runner.command('volume_up', remote_control.volume_up) runner.command('volume_down', remote_control.volume_down) runner.command('mute_volume', remote_control.mute_volume) runner.command('turn_off', remote_control.turn_off) runner.command('turn_on', remote_control.turn_on) runner.command('send_key', remote_control.send_key) return Console(runner).run()
import panasonic_viera rc = panasonic_viera.RemoteControl("TV_IP") # Make the TV display a pairing pin code rc.request_pin_code() # Interactively ask the user for the pin code pin = input("Enter the displayed pin code: ") # Authorize the pin code with the TV rc.authorize_pin_code(pincode=pin) # Display credentials (application ID and encryption key) print(rc.app_id) print(rc.enc_key)
import panasonic_viera rc = panasonic_viera.RemoteControl("192.168.1.5", app_id="AVjZdqRjoRxCXg==", encryption_key="23Lw9k7hjaIhx9xsgRLkSg==") print(rc.get_apps())
def connect_tv(): global rc rc = panasonic_viera.RemoteControl("TV_IP", app_id="APP_ID", encryption_key="ENC_KEY")
from packaging.version import Version except ImportError: try: from distutils.version import StrictVersion as Version except ImportError: pass if not Version: logs.append( dict( level='WARNING', message= 'La bibliothèque packaging.version n\'est pas disponible. Certaines fonctionalités risque de ne pas être disponibles' )) # MAIN rc = panasonic_viera.RemoteControl( args.host if hasattr(args, 'host') else None) if hasattr(args, 'timeout') and args.timeout is not None and hasattr( rc, 'setTimeout'): rc.setTimeout(args.timeout) try: if args.action == 'sendkey': rc.sendKey(args.command) result['output'] = 'ok' elif args.action == 'render': if args.command == 'getVolume': result['output'] = rc.getVolume() if args.command == 'getMute': result['output'] = rc.getMute() elif args.action == 'set': if args.command == 'setVolume':
def init_remote(): rc = panasonic_viera.RemoteControl(iplist["bedtv"])