pyvizio


Namepyvizio JSON
Version 0.1.61 PyPI version JSON
download
home_pagehttps://github.com/vkorn/pyvizio
SummaryPython library for interfacing with Vizio SmartCast TVs and Sound Bars (2016+ models)
upload_time2023-04-28 08:06:34
maintainer
docs_urlNone
authorVlad Korniev
requires_python>=3.8
licenseGPLv3
keywords vizio smartcast
VCS
bugtrack_url
requirements aiohttp click jsonpickle requests tabulate xmltodict zeroconf
Travis-CI
coveralls test coverage No coveralls.
            ## Description

Simple cli and API implementation for Vizio SmartCast TVs and Speakers (Sound Bars). Mainly created for 
integration with [HASS](http://home-assistant.io). Note that some of the interaction commands are not supported by 
speakers.

## Installation

Use `pip`: 
```bash
pip3 install pyvizio
```
or
```bash
pip install pyvizio
```
if `pip3` is not found.

## Upgrade

Use `pip`: 
```bash
pip3 install --upgrade pyvizio
```
or
```bash
pip install --upgrade pyvizio
```
if `pip3` is not found.

## CLI Usage

To avoid repeating IP (`--ip`), Auth (`--auth`), and Device Type (`--device_type`) params in each CLI call, you can add them to environment variables as `VIZIO_IP`, `VIZIO_AUTH`, and `VIZIO_DEVICE_TYPE` respectively

`--device-type` options are `tv` and `speaker`. If the parameter is not included, the device type is assumed to be `tv`. Note that TVs always require a pairing process to get an auth token. Speakers may not always need an auth token but YMMV based on your particular model.

### Find your device

First, find your device (yeah, I'm too lazy to add another cli group)
```bash
pyvizio --ip=0 discover
```

and note its IP address and port number. If you have trouble finding a device you were expecting to, you can try increasing the discovery timeout period by adding the `--timeout` option.

### Pairing

Using your device's IP address and port number, request pairing procedure:

```bash
pyvizio --ip={ip:port} --device_type={device_type} pair
```
After running the above command:
- For TVs, lookup the PIN code on your TV and note challenge token and type in console
- For speakers, press the physical "Volume Up" and note challenge token and type in console

> It's better to have your device turned on as it's "forgetting" the PIN sometimes if it was turned off prior to pairing command.

Using these data points, finalize pairing procedure: (a pin is not necessary for speakers as they appear to always use `0000`)
```bash
pyvizio --ip={ip:port} --device_type={device_type} pair-finish --ch_type={challenge_type} --token={challenge_token} --pin={pin}
```
If everything done correctly, you should see new connected device named `Python Vizio` 
in Vizio SmartCast mobile APP 


> For a TV, you'll need auth code for any further commands. If you are interacting with a Speaker, and skipped the pairing process, you don't need to include the `--auth` parameter in any of the following calls since you don't have an auth code.

### Turning on/off

```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} power {on|off|toggle}
```

To get current power state simply call

```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-power-state
```

### Volume operations

You could change volume
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} volume {up|down} amount
```

and get current level (0-100)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-volume-level
```

In addition mute command is available
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} mute {on|off|toggle}
```

### Switching channels (TVs only)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} channel {up|down|prev} amount
```

### Input sources

You can get current source (if the value is SMARTCAST, then an app is currently runniing)

```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-current-input
```

List all connected devices

```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-inputs-list
```

And using `Name` column from this list, you can switch input:

```bash
pyvizio --ip={ip:port}  --device_type={device_type} --auth={auth_code} input {input_name}
```

Other options is to circle through all inputs
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} next-input
```

### Managing audio settings
> You may have to experiment to find the available options for a given setting. For example, numeric settings have a finite range. I've also found that certain ranges returned by the API aren't correct

List available audio setting names and their current values
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-audio-settings
```

Get the current value of a given audio setting
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-audio-setting {setting_name}
```

List available audio setting names and their available choices/ranges
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-audio-settings-options
```

Get the choices/range of a given audio setting
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-audio-setting-options {setting_name}
```

Set a new value for a given audio setting
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} audio-setting {setting_name} {new_value}
```

### Managing any setting type
List all available setting types
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-setting-types-list
```

List available setting names and their current values for a given setting type
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-settings {setting_type}
```

Get the current value of a given setting (must specify setting type)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-setting {setting_type} {setting_name}
```

List available setting names and their available choices/ranges for a given setting type
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-settings-options {setting_type}
```

Get the choices/range of a given setting (must specify setting type)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-setting-options {setting_type} {setting_name}
```

Set a new value for a given setting (must specify setting type)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} setting {setting_type} {setting_name} {new_value}
```

### Apps (TVs with app support only)

Get a list of available apps by name (this will attempt to get the latest list of apps which is stored exterenally, but will fall back to a static list found in the Vizio SmartCast Android source code. If you would like to add apps to the static list and can retrieve the latest source code, you can use `pyvizio.util.gen_apps_list_from_src("path/to/root/of/source")` to retrieve the latest list. The list is stored in `APPS` in `pyvizio/_api/apps.py` and you are welcome to submit a PR with updates)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-apps-list
```

Get currently running app (if value is `_NO_APP_RUNNING` then no app is currently running, and if the value is `_UNKNOWN_APP` then the app name couldn't be determined from the current `APPS` list)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-current-app
```

Launch an app (app names must match the names listed in the `get-apps-list` command but are not case sensitive. Be sure to use quotes if the app name has a space)
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} launch-app "{app_name}"
```

If an app isn't found by name, but you know the config required to launch it, you can specify the config
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} launch-app-config {APP_ID} {NAME_SPACE} {MESSAGE}
```

One way to get the config of an app that is not already stored in the APPS list is to launch the app on your device and then run
```bash
pyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-current-app-config
```

## Contribution

Thanks for great research uploaded [here](https://github.com/exiva/Vizio_SmartCast_API) and 
absolutely awesome SSDP discovery [snippet](https://gist.github.com/dankrause/6000248)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vkorn/pyvizio",
    "name": "pyvizio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "vizio smartcast",
    "author": "Vlad Korniev",
    "author_email": "vladimir.kornev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/60/97/a9e977a44617916f94a70b2f0f333eff275b9d2b5039975c86e8c7634016/pyvizio-0.1.61.tar.gz",
    "platform": null,
    "description": "## Description\n\nSimple cli and API implementation for Vizio SmartCast TVs and Speakers (Sound Bars). Mainly created for \nintegration with [HASS](http://home-assistant.io). Note that some of the interaction commands are not supported by \nspeakers.\n\n## Installation\n\nUse `pip`: \n```bash\npip3 install pyvizio\n```\nor\n```bash\npip install pyvizio\n```\nif `pip3` is not found.\n\n## Upgrade\n\nUse `pip`: \n```bash\npip3 install --upgrade pyvizio\n```\nor\n```bash\npip install --upgrade pyvizio\n```\nif `pip3` is not found.\n\n## CLI Usage\n\nTo avoid repeating IP (`--ip`), Auth (`--auth`), and Device Type (`--device_type`) params in each CLI call, you can add them to environment variables as `VIZIO_IP`, `VIZIO_AUTH`, and `VIZIO_DEVICE_TYPE` respectively\n\n`--device-type` options are `tv` and `speaker`. If the parameter is not included, the device type is assumed to be `tv`. Note that TVs always require a pairing process to get an auth token. Speakers may not always need an auth token but YMMV based on your particular model.\n\n### Find your device\n\nFirst, find your device (yeah, I'm too lazy to add another cli group)\n```bash\npyvizio --ip=0 discover\n```\n\nand note its IP address and port number. If you have trouble finding a device you were expecting to, you can try increasing the discovery timeout period by adding the `--timeout` option.\n\n### Pairing\n\nUsing your device's IP address and port number, request pairing procedure:\n\n```bash\npyvizio --ip={ip:port} --device_type={device_type} pair\n```\nAfter running the above command:\n- For TVs, lookup the PIN code on your TV and note challenge token and type in console\n- For speakers, press the physical \"Volume Up\" and note challenge token and type in console\n\n> It's better to have your device turned on as it's \"forgetting\" the PIN sometimes if it was turned off prior to pairing command.\n\nUsing these data points, finalize pairing procedure: (a pin is not necessary for speakers as they appear to always use `0000`)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} pair-finish --ch_type={challenge_type} --token={challenge_token} --pin={pin}\n```\nIf everything done correctly, you should see new connected device named `Python Vizio` \nin Vizio SmartCast mobile APP \n\n\n> For a TV, you'll need auth code for any further commands. If you are interacting with a Speaker, and skipped the pairing process, you don't need to include the `--auth` parameter in any of the following calls since you don't have an auth code.\n\n### Turning on/off\n\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} power {on|off|toggle}\n```\n\nTo get current power state simply call\n\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-power-state\n```\n\n### Volume operations\n\nYou could change volume\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} volume {up|down} amount\n```\n\nand get current level (0-100)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-volume-level\n```\n\nIn addition mute command is available\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} mute {on|off|toggle}\n```\n\n### Switching channels (TVs only)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} channel {up|down|prev} amount\n```\n\n### Input sources\n\nYou can get current source (if the value is SMARTCAST, then an app is currently runniing)\n\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-current-input\n```\n\nList all connected devices\n\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-inputs-list\n```\n\nAnd using `Name` column from this list, you can switch input:\n\n```bash\npyvizio --ip={ip:port}  --device_type={device_type} --auth={auth_code} input {input_name}\n```\n\nOther options is to circle through all inputs\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} next-input\n```\n\n### Managing audio settings\n> You may have to experiment to find the available options for a given setting. For example, numeric settings have a finite range. I've also found that certain ranges returned by the API aren't correct\n\nList available audio setting names and their current values\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-audio-settings\n```\n\nGet the current value of a given audio setting\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-audio-setting {setting_name}\n```\n\nList available audio setting names and their available choices/ranges\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-audio-settings-options\n```\n\nGet the choices/range of a given audio setting\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-audio-setting-options {setting_name}\n```\n\nSet a new value for a given audio setting\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} audio-setting {setting_name} {new_value}\n```\n\n### Managing any setting type\nList all available setting types\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-setting-types-list\n```\n\nList available setting names and their current values for a given setting type\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-settings {setting_type}\n```\n\nGet the current value of a given setting (must specify setting type)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-setting {setting_type} {setting_name}\n```\n\nList available setting names and their available choices/ranges for a given setting type\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-all-settings-options {setting_type}\n```\n\nGet the choices/range of a given setting (must specify setting type)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-setting-options {setting_type} {setting_name}\n```\n\nSet a new value for a given setting (must specify setting type)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} setting {setting_type} {setting_name} {new_value}\n```\n\n### Apps (TVs with app support only)\n\nGet a list of available apps by name (this will attempt to get the latest list of apps which is stored exterenally, but will fall back to a static list found in the Vizio SmartCast Android source code. If you would like to add apps to the static list and can retrieve the latest source code, you can use `pyvizio.util.gen_apps_list_from_src(\"path/to/root/of/source\")` to retrieve the latest list. The list is stored in `APPS` in `pyvizio/_api/apps.py` and you are welcome to submit a PR with updates)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-apps-list\n```\n\nGet currently running app (if value is `_NO_APP_RUNNING` then no app is currently running, and if the value is `_UNKNOWN_APP` then the app name couldn't be determined from the current `APPS` list)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-current-app\n```\n\nLaunch an app (app names must match the names listed in the `get-apps-list` command but are not case sensitive. Be sure to use quotes if the app name has a space)\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} launch-app \"{app_name}\"\n```\n\nIf an app isn't found by name, but you know the config required to launch it, you can specify the config\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} launch-app-config {APP_ID} {NAME_SPACE} {MESSAGE}\n```\n\nOne way to get the config of an app that is not already stored in the APPS list is to launch the app on your device and then run\n```bash\npyvizio --ip={ip:port} --device_type={device_type} --auth={auth_code} get-current-app-config\n```\n\n## Contribution\n\nThanks for great research uploaded [here](https://github.com/exiva/Vizio_SmartCast_API) and \nabsolutely awesome SSDP discovery [snippet](https://gist.github.com/dankrause/6000248)\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Python library for interfacing with Vizio SmartCast TVs and Sound Bars (2016+ models)",
    "version": "0.1.61",
    "split_keywords": [
        "vizio",
        "smartcast"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6097a9e977a44617916f94a70b2f0f333eff275b9d2b5039975c86e8c7634016",
                "md5": "2bdadc3261fbb72046cd71e7f781d328",
                "sha256": "02da8c59edb3811a8ea794bda0aabb91e1cd1ccf299d3995d667c6895cf28137"
            },
            "downloads": -1,
            "filename": "pyvizio-0.1.61.tar.gz",
            "has_sig": false,
            "md5_digest": "2bdadc3261fbb72046cd71e7f781d328",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 32678,
            "upload_time": "2023-04-28T08:06:34",
            "upload_time_iso_8601": "2023-04-28T08:06:34.331329Z",
            "url": "https://files.pythonhosted.org/packages/60/97/a9e977a44617916f94a70b2f0f333eff275b9d2b5039975c86e8c7634016/pyvizio-0.1.61.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-28 08:06:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "vkorn",
    "github_project": "pyvizio",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": []
        },
        {
            "name": "click",
            "specs": []
        },
        {
            "name": "jsonpickle",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "tabulate",
            "specs": [
                [
                    ">=",
                    "0.8.6"
                ]
            ]
        },
        {
            "name": "xmltodict",
            "specs": []
        },
        {
            "name": "zeroconf",
            "specs": [
                [
                    ">=",
                    "0.24.4"
                ]
            ]
        }
    ],
    "lcname": "pyvizio"
}
        
Elapsed time: 0.08019s