custom_components/vizio/media_player.py
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Vizio media player platform."""
    host = config.get(CONF_HOST)
    token = config.get(CONF_ACCESS_TOKEN)
    name = config.get(CONF_NAME)
    volume_step = config.get(CONF_VOLUME_STEP)
    device_type = config.get(CONF_DEVICE_CLASS)
    device = VizioDevice(host, token, name, volume_step, device_type)
    if device.validate_setup() is False:
        _LOGGER.error("Failed to set up Vizio platform, "
                      "please check if host and API key are correct")
        return
    elif (token is None or token == "") and device_type == "tv":
        _LOGGER.error("Failed to set up Vizio platform, "
                      "if device_class is 'tv' then an auth_token needs "
                      "to be provided, otherwise if device_class is "
                      "'soundbar' then add the right device_class to config")
        return

    if config.get(CONF_SUPPRESS_WARNING):
        from requests.packages import urllib3
        _LOGGER.warning("InsecureRequestWarning is disabled "
                        "because of Vizio platform configuration")
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    add_entities([device], True)
def setup_platform(hass, config, add_entities, discovery_info=None):
    host = config.get(CONF_HOST)
    token = config.get(CONF_ACCESS_TOKEN)
    name = config.get(CONF_NAME)
    volume_step = config.get(CONF_VOLUME_STEP)
    device_type = config.get(CONF_DEVICE_CLASS)
    device = VizioDevice(host, token, name, volume_step, device_type)
    if device.validate_setup() is False:
        _LOGGER.error("Failed to set up Vizio platform, "
                      "please check if host and API key are correct")
        return
    elif (token is None or token == "") and device_type == "tv":
        _LOGGER.error("Failed to set up Vizio platform, "
                      "if device_class is 'tv' then an auth_token needs "
                      "to be provided, otherwise if device_class is "
                      "'soundbar' then add the right device_class to config")
        return

    if config.get(CONF_SUPPRESS_WARNING):
        from requests.packages import urllib3
        _LOGGER.warning("InsecureRequestWarning is disabled "
                        "because of Vizio platform configuration")
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    add_entities([device], True)
def setup_platform ( hass , config , add_entities , discovery_info = None ) : host = config . get ( CONF_HOST ) token = config . get ( CONF_ACCESS_TOKEN ) name = config . get ( CONF_NAME ) volume_step = config . get ( CONF_VOLUME_STEP ) device_type = config . get ( CONF_DEVICE_CLASS ) device = VizioDevice ( host , token , name , volume_step , device_type ) if device . validate_setup ( ) is False : _LOGGER . error ( "Failed to set up Vizio platform, " "please check if host and API key are correct" ) return elif ( token is None or token == "" ) and device_type == "tv" : _LOGGER . error ( "Failed to set up Vizio platform, " "if device_class is 'tv' then an auth_token needs " "to be provided, otherwise if device_class is " "'soundbar' then add the right device_class to config" ) return if config . get ( CONF_SUPPRESS_WARNING ) : from requests . packages import urllib3 _LOGGER . warning ( "InsecureRequestWarning is disabled " "because of Vizio platform configuration" ) urllib3 . disable_warnings ( urllib3 . exceptions . InsecureRequestWarning ) add_entities ( [ device ] , True )
Set up the Vizio media player platform.
Set up the Vizio media player platform .