How to use the somecomfort.AuthError function in somecomfort

To help you get started, we’ve selected a few somecomfort examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kk7ds / somecomfort / tests / test_client.py View on Github external
def test_login_failed(self):
        recorder = betamax.Betamax(self.session)
        with recorder.use_cassette('badlogin'):
            self.assertRaises(somecomfort.AuthError,
                              SomeComfort, 'nosuchuser',
                              'definitelynotapassword')
github home-assistant / home-assistant / tests / components / thermostat / test_honeywell.py View on Github external
def test_setup_us_failures(self, mock_sc):
        """Test the US setup."""
        hass = mock.MagicMock()
        add_devices = mock.MagicMock()
        config = {
            CONF_USERNAME: 'user',
            CONF_PASSWORD: 'pass',
            'region': 'us',
        }

        mock_sc.side_effect = somecomfort.AuthError
        result = honeywell.setup_platform(hass, config, add_devices)
        self.assertFalse(result)
        self.assertFalse(add_devices.called)

        mock_sc.side_effect = somecomfort.SomeComfortError
        result = honeywell.setup_platform(hass, config, add_devices)
        self.assertFalse(result)
        self.assertFalse(add_devices.called)
github home-assistant / home-assistant / tests / components / honeywell / test_climate.py View on Github external
def test_setup_us_failures(self, mock_sc):
        """Test the US setup."""
        hass = mock.MagicMock()
        add_entities = mock.MagicMock()
        config = {
            CONF_USERNAME: "user",
            CONF_PASSWORD: "pass",
            honeywell.CONF_REGION: "us",
        }

        mock_sc.side_effect = somecomfort.AuthError
        result = honeywell.setup_platform(hass, config, add_entities)
        assert not result
        assert not add_entities.called

        mock_sc.side_effect = somecomfort.SomeComfortError
        result = honeywell.setup_platform(hass, config, add_entities)
        assert not result
        assert not add_entities.called
github home-assistant / home-assistant / homeassistant / components / thermostat / honeywell.py View on Github external
def _setup_us(username, password, config, add_devices):
    """Setup user."""
    import somecomfort

    try:
        client = somecomfort.SomeComfort(username, password)
    except somecomfort.AuthError:
        _LOGGER.error('Failed to login to honeywell account %s', username)
        return False
    except somecomfort.SomeComfortError as ex:
        _LOGGER.error('Failed to initialize honeywell client: %s', str(ex))
        return False

    dev_id = config.get('thermostat')
    loc_id = config.get('location')

    add_devices([HoneywellUSThermostat(client, device)
                 for location in client.locations_by_id.values()
                 for device in location.devices_by_id.values()
                 if ((not loc_id or location.locationid == loc_id) and
                     (not dev_id or device.deviceid == dev_id))])
    return True
github Haynie-Research-and-Development / jarvis / deps / lib / python3.4 / site-packages / somecomfort / __main__.py View on Github external
parser.add_argument('--username', help='username')
    parser.add_argument('--password', help='password')
    parser.add_argument('--device', help='device', default=None,
                        type=int)
    parser.add_argument('--login', help='Just try to login',
                        action='store_const', const=True,
                        default=False)
    parser.add_argument('--devices', help='List available devices',
                        action='store_const', const=True,
                        default=False)
    args = parser.parse_args()

    try:
        client = somecomfort.SomeComfort(args.username, args.password,
                                         session=session)
    except somecomfort.AuthError as ex:
        if not args.username and args.password:
            print('Login required and no credentials provided')
        else:
            print(str(ex))
        return 1

    if args.login:
        print('Success')
        return 0

    if args.devices:
        for l_name, location in client.locations_by_id.items():
            print('Location %s:' % l_name)
            for key, device in location.devices_by_id.items():
                print('  Device %s: %s' % (key, device.name))
        return 0
github kk7ds / somecomfort / somecomfort / __main__.py View on Github external
parser.add_argument('--username', help='username')
    parser.add_argument('--password', help='password')
    parser.add_argument('--device', help='device', default=None,
                        type=int)
    parser.add_argument('--login', help='Just try to login',
                        action='store_const', const=True,
                        default=False)
    parser.add_argument('--devices', help='List available devices',
                        action='store_const', const=True,
                        default=False)
    args = parser.parse_args()

    try:
        client = somecomfort.SomeComfort(args.username, args.password,
                                         session=session)
    except somecomfort.AuthError as ex:
        if not args.username and args.password:
            print('Login required and no credentials provided')
        else:
            print(str(ex))
        return 1

    if args.login:
        print('Success')
        return 0

    if args.devices:
        for l_name, location in client.locations_by_id.items():
            print('Location %s:' % l_name)
            for key, device in location.devices_by_id.items():
                print('  Device %s: %s' % (key, device.name))
        return 0
github home-assistant / home-assistant / homeassistant / components / honeywell / climate.py View on Github external
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Honeywell thermostat."""
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)

    if config.get(CONF_REGION) == "us":
        try:
            client = somecomfort.SomeComfort(username, password)
        except somecomfort.AuthError:
            _LOGGER.error("Failed to login to honeywell account %s", username)
            return
        except somecomfort.SomeComfortError:
            _LOGGER.error(
                "Failed to initialize the Honeywell client: "
                "Check your configuration (username, password), "
                "or maybe you have exceeded the API rate limit?"
            )
            return

        dev_id = config.get("thermostat")
        loc_id = config.get("location")
        cool_away_temp = config.get(CONF_COOL_AWAY_TEMPERATURE)
        heat_away_temp = config.get(CONF_HEAT_AWAY_TEMPERATURE)

        add_entities(