async def main():
    client = await SimpleSubscriber.create('localhost', 9001)

    prompt = 'Enter feed and topic (e.g. LSE SBRY)\n'
    console_task = asyncio.create_task(ainput(prompt))
    pending = {
        asyncio.create_task(client.start()),
        console_task
    }

    while pending:

        done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)

        for task in done:
            if task == console_task:
                line = console_task.result()
                if not line:
                    client.stop()
                else:
                    feed, topic = line.split(' ')
                    print(f'Subscribing to feed "{feed}" and topic "{topic}"')
                    await client.add_subscription(feed, topic)
                    console_task = asyncio.create_task(ainput(prompt))
                    pending.add(console_task)
Beispiel #2
0
async def main_async():
    client = await Client.connect('localhost', 30011, JsonSerializer())
    start_task = asyncio.create_task(client.start())
    read_task = asyncio.create_task(client.read())
    console_task = asyncio.create_task(aioconsole.ainput('Enter +/- feed and topic (e.g. + LSE SBRY)\n'))

    while True:

        done, pending = await asyncio.wait(
            [start_task, read_task, console_task],
            return_when=asyncio.FIRST_COMPLETED
        )

        for task in done:
            if task == console_task:
                line = console_task.result()
                if line:
                    try:
                        add_remove, feed, topic = line.split(' ')
                        print(
                            f'{"Subscribing" if add_remove == "+" else "Unsubscribing"} to feed \"{feed}\" and topic \"{topic}\"')
                        if add_remove == '+':
                            await client.add_subscription(feed, topic)
                        else:
                            await client.remove_subscription(feed, topic)
                    except:
                        print(f'Invalid line: \"{line}\"')
                console_task = asyncio.create_task(aioconsole.ainput('Enter +/- feed and topic (e.g. LSE SBRY)\n'))
            elif task == read_task:
                msg = read_task.result()
                print(msg)
                read_task = asyncio.create_task(client.read())
async def main():
    await aprint('Example publisher')
    feed = await ainput('Feed: ')
    topic = await ainput('Topic: ')

    client = await CallbackClient.create('localhost', 9001)

    console_task = asyncio.create_task(ainput('Message: '))
    client_task = asyncio.create_task(client.start())
    pending = {
        client_task,
        console_task
    }

    while pending:

        done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)

        for task in done:
            if task == client_task:
                break
            elif task == console_task:
                message = console_task.result()
                if not message:
                    client.stop()
                else:
                    print(f'Publishing to feed "{feed}" and topic "{topic}" the message "{message}"')
                    data_packets = [DataPacket({ 42 }, message.encode('utf8'))]
                    await client.publish(feed, topic, True, data_packets)
                    console_task = asyncio.create_task(ainput('Message: '))
                    pending.add(console_task)
Beispiel #4
0
    async def get_cmd(self):

        signal.alarm(1)
        try:
            ainput(prompt='cmd >>')
        except InputTimeoutError:
            print('timeout')

        signal.alarm(0)
Beispiel #5
0
async def main(device: str):
    serial_port = aioserial.AioSerial(port=device, baudrate=115200)

    print("Talking with your device")
    meas = await get_measurement(serial_port)
    print(meas)
    if not meas:
        return
    print(
        "OK - Please rotate thru the range of brightnesses to determine the limits. Press enter when done"
    )
    brightness_extrema = RunningExtrema()
    input_task = asyncio.create_task(aioconsole.ainput())
    while True:
        meas = await get_measurement_or_enter(input_task, serial_port)
        if not meas:
            # they hit enter
            break
        if brightness_extrema.process(meas.brightness):
            print(brightness_extrema.min_val, brightness_extrema.max_val)
            if brightness_extrema.min_val == 0:
                print("Got a brightness of zero, not OK. Is your sensor connected right?")
                return

    print("OK, limits found.")
    if brightness_extrema.get_range() < 200:
        print(
            "Range not large enough: improve sensitivity of sensor or connection to display"
        )
        return

    print("OK, recording to disk, enter to stop.")
    with open(FILENAME, "w") as fp:
        # header row
        fp.write("us,drx,dry,drz,brightness\n")
        base_meas = await get_measurement(serial_port)
        if not base_meas:
            raise RuntimeError("Could not get our baseline timestamp")
        zero_time = base_meas.us
        # the task watching for the enter press
        input_task = asyncio.create_task(aioconsole.ainput())
        while True:
            meas = await get_measurement_or_enter(input_task, serial_port)
            if not meas:
                # they hit enter
                break

            # Offset the timestamp for ease of use.
            meas.us -= zero_time
            fp.write(meas.get_csv_line())
    print(f"All done! Go move/rename {FILENAME} and analyze it!")
Beispiel #6
0
async def show_washerdryer_menu(backend_selector, auth, said):
    def print_menu():
        print("\n")
        print(30 * "-", "MENU", 30 * "-")
        print("u. Update status from server")
        print("p. Print status")
        print("v. Print raw status")
        print("c. Custom command")
        print("q. Exit")
        print(67 * "-")

    def print_status(wd: WasherDryer):
        print("online: " + str(wd.get_online()))
        print("state: " + str(wd.get_machine_state()))
        print("sensing: " + str(wd.get_cycle_status_sensing()))
        print("filling: " + str(wd.get_cycle_status_filling()))
        print("soaking: " + str(wd.get_cycle_status_soaking()))
        print("washing: " + str(wd.get_cycle_status_washing()))
        print("rinsing: " + str(wd.get_cycle_status_rinsing()))
        print("spinning: " + str(wd.get_cycle_status_spinning()))

    def attr_upd():
        print("Attributes updated")

    wd = WasherDryer(backend_selector, auth, said, attr_upd)
    await wd.connect()

    loop = True
    while loop:
        print_menu()
        choice = await aioconsole.ainput("Enter your choice: ")

        if choice == "p":
            print_status(wd)
        elif choice == "u":
            await wd.fetch_data()
            print_status(wd)
        elif choice == "v":
            print(wd._data_dict)
        elif choice == "c":
            cmd = aioconsole.ainput("Command: ")
            val = aioconsole.ainput("Value: ")
            await wd.send_attributes({cmd: val})
        elif choice == "q":
            await wd.disconnect()
            auth.cancel_auto_renewal()
            print("Bye")
            loop = False
        else:
            print("Wrong option selection. Enter any key to try again..")
Beispiel #7
0
async def run(controller_state: ControllerState):
    stick = controller_state.l_stick_state
    stick.set_center()
    centerH = stick.get_h()
    centerV = stick.get_v()

    user_input = asyncio.ensure_future(
        ainput(prompt='Running plugin... Press <enter> to stop.'))

    async def press_a():
        await button_push(controller_state, 'a')
        await asyncio.sleep(0.3)

    speed = 0x100
    move_path = ((-1, 0), (0, -1), (1, 0), (0, 1))

    while not user_input.done():
        for direction in move_path:
            # move
            stick.set_h(centerH + (speed * direction[0]))
            stick.set_v(centerV + (speed * direction[1]))
            await asyncio.sleep(5)
            stick.set_center()

            # press a
            await press_a()

            if user_input.done():
                break
            else:
                continue

    await user_input
async def make_fish_food(controller_state: ControllerState):
    """
    Example controller script.
    Navigates to the "Test Controller Buttons" menu and presses all buttons.
    """
    if controller_state.get_controller() != Controller.PRO_CONTROLLER:
        raise ValueError('This script only works with the Pro Controller!')

    # waits until controller is fully connected
    await controller_state.connect()

    await ainput(prompt='press <enter> to start.')

    user_input = asyncio.ensure_future(
        ainput(prompt='Making fish foods... Press <enter> to stop.'))

    # push all buttons consecutively until user input
    while not user_input.done():
        await button_push(controller_state, 'a')
        await asyncio.sleep(0.3)
        if user_input.done():
            break

    # await future to trigger exceptions in case something went wrong
    await user_input
async def buy(controller_state: ControllerState):
    if controller_state.get_controller() != Controller.PRO_CONTROLLER:
        raise ValueError('This script only works with the Pro Controller!')
    await controller_state.connect()
    await ainput(
        prompt=
        '动森购买器 Make sure the  Animal crossing in shop and press <enter> to continue.'
    )
    user_input = asyncio.ensure_future(
        ainput(prompt='Buying gifts... Press <enter> to stop.'))
    while not user_input.done():
        await button_push(controller_state, 'a')
        await button_push(controller_state, 'b')
        await asyncio.sleep(0.4)
        await button_push(controller_state, 'a')
        await button_push(controller_state, 'b')
        await asyncio.sleep(0.4)
        await button_push(controller_state, 'down')
        await button_push(controller_state, 'a')
        await button_push(controller_state, 'b')
        await asyncio.sleep(1.5)
        await button_push(controller_state, 'a')
        await button_push(controller_state, 'b')
        await asyncio.sleep(0.4)
        await button_push(controller_state, 'a')
        await button_push(controller_state, 'b')
        await asyncio.sleep(0.4)
    await user_input
Beispiel #10
0
    def send_to_server(self, writer):
        try:
            while True:
                original_message = yield from aioconsole.ainput('>> ')
                if original_message != None:
                    console_message = original_message.strip()
                    if console_message == '':
                        continue
                    elif console_message[:16] == '@server set_name':
                        username = console_message[17:len(console_message) - 1]
                        if " " in username:
                            print(
                                "[error] Username should not have any spaces")
                        elif username == "client" or username == "Client" or username == "server" or username == "Server":
                            print(" [error] Username cannot be " + username)
                        else:
                            self.name = username
                            print("Client username is " + self.name)
                            writer.write(console_message.encode())
                    elif console_message == 'close()':
                        raise ClosingException()
                        writer.write(console_message.encode())
                    else:
                        writer.write(console_message.encode())

        except ClosingException:
            print('Got close() from user.')
        finally:
            if not writer.transport.is_closing():
                writer.close()
Beispiel #11
0
async def ainput_line(prompt=''):
    try:
        line = ainput(prompt=prompt)
    except KeyboardInterrupt:
        return False
    except Exception:
        return False

    return line
Beispiel #12
0
async def run(controller_state: ControllerState):
    user_input = asyncio.ensure_future(
        ainput(prompt='Running plugin... Press <enter> to stop.'))

    async def press_a():
        await button_push(controller_state, 'a', sec=1)
        await asyncio.sleep(0.1)

    while not user_input.done():
        await press_a()

    await user_input
async def mash_button(controller_state, button, interval):
    # wait until controller is fully connected
    await controller_state.connect()
    ensure_valid_button(controller_state, button)

    user_input = asyncio.ensure_future(
        ainput(prompt=f'Pressing the {button} button every {interval} seconds... Press <enter> to stop.')
    )
    # push a button repeatedly until user input
    while not user_input.done():
        await button_push(controller_state, button)
        await asyncio.sleep(float(interval))

    # await future to trigger exceptions in case something went wrong
    await user_input
Beispiel #14
0
 def send_to_server(self,writer):
     try:
         while True:
             original_message = yield from aioconsole.ainput('>> ')
             if original_message != None:
                 console_message = original_message.strip()
                 if console_message == '':
                     continue
                 elif console_message == 'close()':
                     raise ClosingException()
                 writer.write(console_message.encode())
     except ClosingException:
         print('Got close() from user.')
     finally:
         if not writer.transport.is_closing():
             writer.close()
async def mash_button(controller_state, button, interval):
	# waits until controller is fully connected
	await controller_state.connect()

	if button not in controller_state.button_state.get_available_buttons():
		raise ValueError(f'Button {button} does not exist on {controller_state.get_controller()}')

	user_input = asyncio.ensure_future(
		ainput(prompt=f'Pressing the {button} button every {interval} seconds... Press <enter> to stop.')
	)
	# push a button repeatedly until user input
	while not user_input.done():
		await button_push(controller_state, button)
		await asyncio.sleep(float(interval))

	# await future to trigger exceptions in case something went wrong
	await user_input
Beispiel #16
0
async def run(controller_state: ControllerState):
    user_input = asyncio.ensure_future(
        ainput(prompt='Running plugin... Press <enter> to stop.'))

    async def press_a():
        await button_push(controller_state, 'a')
        await asyncio.sleep(0.3)

    now = datetime.now()
    stop_at = now.replace(hour=4, minute=50, second=0, microsecond=0)
    if stop_at < now:
        stop_at = stop_at + timedelta(days=1)

    while not user_input.done():
        await press_a()
        now = datetime.now()
        if stop_at < now:
            break

    await user_input
Beispiel #17
0
async def authorize(ctx):
    nonce = secrets.token_urlsafe(32)
    server = OAuthServer(
        client_id=ctx.obj.client_id,
        client_secret=ctx.obj.client_secret,
        nonce=nonce,
        http_session=ctx.obj.http,
    )

    stderr_echo(OAUTH_PROMPT)
    _ = click.prompt(
        text=
        "Hit [ENTER] to open your browser to authenticate this application to your Monzo account",
        default="done",
        hide_input=True,
        show_default=False,
        err=True,
    )

    click.launch(server.auth_request_url)
    pretty_url = style_url(server.auth_request_url)
    stderr_echo(
        MANUAL_BROWSER_PROMPT.format(url=pretty_url) + "\n" +
        SERVER_KILL_PROMPT)

    await server.run()

    user_killed = asyncio.Task(aioconsole.ainput())
    got_access_data = asyncio.Task(server.access_data())

    completed, _ = await asyncio.wait([user_killed, got_access_data],
                                      return_when=FIRST_COMPLETED)

    if got_access_data in completed:
        access_data = got_access_data.result()

        stderr_echo(IN_APP_AUTHENTICATION_PROMPT)
        got_user = asyncio.Task(
            retry(
                select_default_account,
                kwargs=dict(http=ctx.obj.http,
                            access_token=access_data["access_token"]),
                allowed_exceptions=InsufficientPermissions,
            ))

        completed, _ = await asyncio.wait([user_killed, got_user],
                                          return_when=FIRST_COMPLETED)

        if user_killed in completed:
            stderr_echo("Authentication Canceled", color="red")
            ctx.exit(0)
        elif got_user in completed:
            default_user = got_user.result()
            return access_data, default_user
        else:
            stderr_echo("Unhandled Condition", color="red")
            ctx.exit(1)

    elif user_killed in completed:
        stderr_echo("Authentication Canceled", color="red")
        ctx.exit(0)
    else:
        stderr_echo("Unhandled Condition", color="red")
        ctx.exit(1)
async def show_oven_menu(backend_selector, auth, said):
    def print_menu():
        print("\n")
        print(30 * "-", "MENU", 30 * "-")
        print("u. Update status from server")
        print("l. Control lock toggle")
        print("L. Light toggle")
        print("b. Set display brightness")
        print("t. Set cooking mode/temp")
        print("o. Stop/cancel cooking")
        print("k. Set kitchen timer")
        print("s. Toggle Sabbath mode")
        print("p. Print status")
        print("v. Print raw status")
        print("c. Custom command")
        print("q. Exit")
        print(67 * "-")

    def print_status(ov: Oven):
        print("online: " + str(ov.get_online()))
        print("display brightness (%): " +
              str(ov.get_display_brightness_percent()))
        print("control lock: " + str(ov.get_control_locked()))
        timer = ov.get_kitchen_timer(timer_id=1)
        timer_state = timer.get_state()
        print("kitchen timer 1 state: " + str(timer_state))
        if timer_state != KitchenTimerState.Standby:
            print("kitchen timer 1 time remaining/set time: " +
                  str(timer.get_remaining_time()) + "/" +
                  str(timer.get_total_time()))
        if ov.get_oven_cavity_exists(Cavity.Upper):
            print("upper meat probe: " +
                  str(ov.get_meat_probe_status(Cavity.Upper)))
            print("upper light: " + str(ov.get_light(Cavity.Upper)))
            print("upper door open: " + str(ov.get_door_opened(Cavity.Upper)))
            print("upper temp (current/target, in C): " +
                  str(ov.get_temp(Cavity.Upper)) + "/" +
                  str(ov.get_target_temp(Cavity.Upper)))
            print("upper state: " + str(ov.get_cavity_state(Cavity.Upper)))
            print("upper cook mode: " + str(ov.get_cook_mode(Cavity.Upper)))
            print("upper cook time (seconds): " +
                  str(ov.get_cook_time(Cavity.Upper)))
        if ov.get_oven_cavity_exists(Cavity.Lower):
            print("lower meat probe: " +
                  str(ov.get_meat_probe_status(Cavity.Upper)))
            print("lower light: " + str(ov.get_light(Cavity.Lower)))
            print("lower door open: " + str(ov.get_door_opened(Cavity.Lower)))
            print("lower temp (current/target, in C): " +
                  str(ov.get_temp(Cavity.Lower)) + "/" +
                  str(ov.get_target_temp(Cavity.Lower)))
            print("lower state: " + str(ov.get_cavity_state(Cavity.Lower)))
            print("lower cook mode: " + str(ov.get_cook_mode(Cavity.Lower)))
            print("lower cook time (seconds): " +
                  str(ov.get_cook_time(Cavity.Lower)))

    def attr_upd():
        print("Attributes updated")

    ov = Oven(backend_selector, auth, said, attr_upd)
    await ov.connect()

    loop = True
    while loop:
        print_menu()
        choice = await aioconsole.ainput("Enter your choice: ")

        if choice == "p":
            print_status(ov)
        elif choice == "l":
            await ov.set_control_locked(not ov.get_control_locked())
        elif choice == "L":
            await ov.set_light(not ov.get_light())
        elif choice == "b":
            brightness = await aioconsole.ainput("Brightness (0-100): ")
            await ov.set_display_brightness_percent(brightness)
        elif choice == "k":
            minutes = await aioconsole.ainput("Timer minutes: ")
            await ov.get_kitchen_timer(timer_id=1
                                       ).set_timer(int(float(minutes) * 60))
        elif choice == "o":
            await ov.stop_cook()
        elif choice == "t":
            print("""Cooking modes:
            b: Bake
            c: Convect Bake
            r: Broil
            o: Convect Broil
            s: Convect Roast
            a: Air Fry
            w: Keep Warm
            """)
            cookmode = await aioconsole.ainput("Enter cook mode: ")
            temp = await aioconsole.ainput("Enter cook temperature: ")
            if cookmode == "b":
                await ov.set_cook(mode=CookMode.Bake, target_temp=float(temp))
            if cookmode == "c":
                await ov.set_cook(mode=CookMode.ConvectBake,
                                  target_temp=float(temp))
            if cookmode == "r":
                await ov.set_cook(mode=CookMode.Broil, target_temp=float(temp))
            if cookmode == "o":
                await ov.set_cook(mode=CookMode.ConvectBroil,
                                  target_temp=float(temp))
            if cookmode == "s":
                await ov.set_cook(mode=CookMode.ConvectRoast,
                                  target_temp=float(temp))
            if cookmode == "a":
                await ov.set_cook(mode=CookMode.AirFry,
                                  target_temp=float(temp))
            if cookmode == "w":
                await ov.set_cook(mode=CookMode.KeepWarm,
                                  target_temp=float(temp))
            else:
                print("Invalid cook mode")
        elif choice == "s":
            await ov.set_sabbath_mode(not ov.get_sabbath_mode())
        elif choice == "u":
            await ov.fetch_data()
            print_status(ov)
        elif choice == "v":
            print(ov._data_dict)
        elif choice == "c":
            cmd = aioconsole.ainput("Command: ")
            val = aioconsole.ainput("Value: ")
            await ov.send_attributes({cmd: val})
        elif choice == "q":
            await ov.disconnect()
            auth.cancel_auto_renewal()
            print("Bye")
            loop = False
        else:
            print("Wrong option selection. Enter any key to try again..")
Beispiel #19
0
def input(*args, **kwargs):
    return ainput(*args, **kwargs)
Beispiel #20
0
async def test_controller_buttons(controller_state: ControllerState):

    if controller_state.get_controller() != Controller.PRO_CONTROLLER:
        raise ValueError('This script only works with the Pro Controller!')

    # waits until controller is fully connected
    await controller_state.connect()

    await ainput(
        prompt=
        'Make sure your character is in the right place press <enter> to continue.'
    )

    user_input = asyncio.ensure_future(
        ainput(prompt='Starting the script... Press <enter> to stop.'))

    # push all buttons consecutively until user input
    while not user_input.done():
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(5)

        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)

        await button_push(controller_state, 'x')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'up')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'a')
        await asyncio.sleep(1)
        await button_push(controller_state, 'b')
        await asyncio.sleep(1)

        await button_push(controller_state, 'plus')
        await asyncio.sleep(1)
        await button_push(controller_state, 'up')
        await asyncio.sleep(1)
        await button_push(controller_state, 'down')
        await asyncio.sleep(0.5)
        await button_push(controller_state, 'down')
        await asyncio.sleep(0.5)
        await button_push(controller_state, 'a')
        await asyncio.sleep(0.5)
        await button_push(controller_state, 'a')
        await asyncio.sleep(20)

        if user_input.done():
            break
Beispiel #21
0
 def make_inp():
     return asyncio.create_task(aioconsole.ainput(">>> "))
Beispiel #22
0
async def test_controller_buttons(controller_state: ControllerState):
    """
    Example controller script.
    Navigates to the "Test Controller Buttons" menu and presses all buttons.
    """
    if controller_state.get_controller() != Controller.PRO_CONTROLLER:
        raise ValueError('This script only works with the Pro Controller!')

    # waits until controller is fully connected
    await controller_state.connect()

    await ainput(
        prompt=
        'Make sure the Switch is in the Home menu and press <enter> to continue.'
    )
    """
    # We assume we are in the "Change Grip/Order" menu of the switch
    await button_push(controller_state, 'home')

    # wait for the animation
    await asyncio.sleep(1)
    """

    # Goto settings
    await button_push(controller_state, 'down', sec=1)
    await button_push(controller_state, 'right', sec=2)
    await asyncio.sleep(0.3)
    await button_push(controller_state, 'left')
    await asyncio.sleep(0.3)
    await button_push(controller_state, 'a')
    await asyncio.sleep(0.3)

    # go all the way down
    await button_push(controller_state, 'down', sec=4)
    await asyncio.sleep(0.3)

    # goto "Controllers and Sensors" menu
    for _ in range(2):
        await button_push(controller_state, 'up')
        await asyncio.sleep(0.3)
    await button_push(controller_state, 'right')
    await asyncio.sleep(0.3)

    # go all the way down
    await button_push(controller_state, 'down', sec=3)
    await asyncio.sleep(0.3)

    # goto "Test Input Devices" menu
    await button_push(controller_state, 'up')
    await asyncio.sleep(0.3)
    await button_push(controller_state, 'a')
    await asyncio.sleep(0.3)

    # goto "Test Controller Buttons" menu
    await button_push(controller_state, 'a')
    await asyncio.sleep(0.3)

    # push all buttons except home and capture
    button_list = controller_state.button_state.get_available_buttons()
    if 'capture' in button_list:
        button_list.remove('capture')
    if 'home' in button_list:
        button_list.remove('home')

    user_input = asyncio.ensure_future(
        ainput(prompt='Pressing all buttons... Press <enter> to stop.'))

    # push all buttons consecutively until user input
    while not user_input.done():
        for button in button_list:
            await button_push(controller_state, button)
            await asyncio.sleep(0.1)

            if user_input.done():
                break

    # await future to trigger exceptions in case something went wrong
    await user_input

    # go back to home
    await button_push(controller_state, 'home')
Beispiel #23
0
async def show_aircon_menu(backend_selector, auth, said):
    def print_menu():
        print("\n")
        print(30 * "-", "MENU", 30 * "-")
        print("1. Turn on")
        print("0. Turn off")
        print("+. Temp up")
        print("-. Temp down")
        print("C. Mode: Cool")
        print("H. Mode: Heat")
        print("F. Mode: Fan")
        print("S. Mode: Sixth Sense")
        print("2. Swing toggle")
        print("3. Turbo toggle")
        print("4. Eco toggle")
        print("5. Quiet toggle")
        print("6. Display toggle")
        print("u. Update status from server")
        print("p. Print status")
        print("v. Print raw status")
        print("c. Custom command")
        print("q. Exit")
        print(67 * "-")

    def print_status(ac: Aircon):
        print("online: " + str(ac.get_online()))
        print("power_on: " + str(ac.get_power_on()))
        print("temp: " + str(ac.get_temp()))
        print("humidity: " + str(ac.get_humidity()))
        print("current_temp: " + str(ac.get_current_temp()))
        print("current_humidity: " + str(ac.get_current_humidity()))
        print("mode: " + str(ac.get_mode()))
        print("sixthsense_mode: " + str(ac.get_sixthsense_mode()))
        print("fanspeed: " + str(ac.get_fanspeed()))
        print("h_louver_swing: " + str(ac.get_h_louver_swing()))
        print("turbo_mode: " + str(ac.get_turbo_mode()))
        print("eco_mode: " + str(ac.get_eco_mode()))
        print("quiet_mode: " + str(ac.get_quiet_mode()))
        print("display_on: " + str(ac.get_display_on()))

    def attr_upd():
        print("Attributes updated")

    ac = Aircon(backend_selector, auth, said, attr_upd)
    await ac.connect()

    loop = True
    while loop:
        print_menu()
        choice = await aioconsole.ainput("Enter your choice: ")

        if choice == "1":
            await ac.set_power_on(True)
        elif choice == "0":
            await ac.set_power_on(False)
        elif choice == "+":
            temp = ac.get_temp() + 1
            await ac.set_temp(temp)
        elif choice == "-":
            temp = ac.get_temp() - 1
            await ac.set_temp(temp)
        elif choice == "C":
            await ac.set_mode(Mode.Cool)
        elif choice == "H":
            await ac.set_mode(Mode.Heat)
        elif choice == "F":
            await ac.set_mode(Mode.Fan)
        elif choice == "S":
            await ac.set_mode(Mode.SixthSense)
        elif choice == "2":
            await ac.set_h_louver_swing(not ac.get_h_louver_swing())
        elif choice == "3":
            await ac.set_turbo_mode(not ac.get_turbo_mode())
        elif choice == "4":
            await ac.set_eco_mode(not ac.get_eco_mode())
        elif choice == "5":
            await ac.set_quiet_mode(not ac.get_quiet_mode())
        elif choice == "6":
            await ac.set_display_on(not ac.get_display_on())
        elif choice == "p":
            print_status(ac)
        elif choice == "u":
            await ac.fetch_data()
            print_status(ac)
        elif choice == "v":
            print(ac._data_dict)
        elif choice == "c":
            cmd = aioconsole.ainput("Command: ")
            val = aioconsole.ainput("Value: ")
            await ac.send_attributes({cmd: val})
        elif choice == "q":
            await ac.disconnect()
            auth.cancel_auto_renewal()
            print("Bye")
            loop = False
        else:
            print("Wrong option selection. Enter any key to try again..")