blynkkk / lib-python

Blynk IoT library for Python and Micropython
MIT License
238 stars 82 forks source link

Terminal is not updated #34

Closed ndrdmarshmallow closed 4 years ago

ndrdmarshmallow commented 4 years ago

I am writing to the the pin connected to terminal as per the example given but I am not getting any details on Blynk terminal screen.

@blynk.handle_event("connect")
def connect_handler():
        header = ''
        result = ''
        delimiter = '{}\n'.format('=' * 30)
        # write details of device to terminal
        for command in DEVICE_COMMANDS:
                try:
                        result = subprocess.check_output(command).decode('utf-8')
                        header = '[output]\n'
                except Exception as err:
                        header = '[error]\n'
                        result = 'Return code: {}\n'.format(err)
                if result:
                        output = '{}{}{}{}'.format(header, delimiter, result, delimiter)
                        print(output)
                        blynk.virtual_write(TERMINAL_PIN, output)
                        blynk.virtual_write(TERMINAL_PIN, '\n')

Am I doing anything wrong ? or is it an issue in library?

antohaUa commented 4 years ago

Hi ndrdmarshmallow! First - please try to use example https://github.com/blynkkk/lib-python/blob/master/examples/06_terminal_widget.py as is( just add your token). It should work for sure.

In your code I can see registered events for "connect", but probably you need handler for

@blynk.handle_event('write V6')
def write_handler(pin, values):

Also for terminal example please check that all requested environment preparations done:

In your Blynk App project:

  • add "Terminal" widget,
  • bind it to Virtual Pin V6,
  • add input line option in widget settings
  • Run the App (green triangle in the upper right corner).
  • define your auth token for current example
  • optionally you can define your own "ALLOWED_COMMANDS_LIST"
  • run current example
antohaUa commented 4 years ago

Can be closed.