exiva / Vizio_SmartCast_API

API documentation for Vizio SmartCast TV's
173 stars 33 forks source link

text and keyboard input #38

Open Ganime422 opened 1 year ago

Ganime422 commented 1 year ago

hello

is there a way to send keyboard input and text? so for example instead of using the arrows on the TV, I would just write the text i need using a keyboard and the characters would be sent to the tv.

thanks

iOS090Bravo commented 1 year ago

@Ganime422 Have you configured it yet?

exiva commented 1 year ago

Does the app support doing that?

kbrown01 commented 9 months ago

Yes. You can use ASCII Decimal codes and key_command. For example, this in my setup will (in Home Assistant) take a textbox and send each "letter" as the ord ASCII code:

alias: Execute Vizio Search
sequence:
  - repeat:
      sequence:
        - service: rest_command.vizio_processkey
          data:
            ip: 192.168.1.232
            port: "7345"
            auth: XXXXXXXXXX
            codeset: "0"
            code: |
              {{ repeat.item | ord }}
      for_each: |
        {{ states("input_text.vizio_search") | list }}
fields: {}
mode: single
icon: mdi:search-web

The command is built like this:

vizio_processkey:
  url: 'https://{{ ip }}:{{ port }}/key_command/'
  method: put
  content_type: "application/json"
  headers:
    AUTH: '{{ auth }}'
  payload: '{"KEYLIST": [{"CODESET": {{ codeset | int }},"CODE": {{ code | int }},"ACTION":"KEYPRESS"}]}'
  verify_ssl: false

It could be better, like I culd build an array for KEYLIST and send all the keys but it is very fast as is.

So let's say you want to search for "Hot Ones" ... this code in Home Assistant takes that string and converts every letter to it's ASCII equivalent (i.e. "a" = 97) and sends that key stroke. It loops for the entire length of the string and sends all the keys.

keyur-Dev commented 8 months ago

Can you provide some code snippet for reference? Also, which value should be passed to the codeset and code? give example.

kun510 commented 4 months ago

Convert to ASCII code then pass in code and give codeset = 0 sample: text = A, code = 65 code set = 0 link ASCII: https://blog.28tech.com.vn/c-bang-ma-ascii then pass the API key command