How to use the somecomfort.SomeComfort 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(self):
        recorder = betamax.Betamax(self.session)
        with recorder.use_cassette('basic'):
            c = SomeComfort(self.username, self.password)

        self.assertIn(self.location, c.locations_by_id)
        self.assertIn(self.device,
                      c.locations_by_id[self.location].devices_by_id)
        device = self._get_device(c)
        self.assertEqual('THERMOSTAT', device.name)
github kk7ds / somecomfort / tests / test_client.py View on Github external
def _test_device_set_attribute(self, attr, value):
        # Thanks windows :(
        attr = str(attr).replace(':', '')
        value = str(value).replace(':', '')
        recorder = betamax.Betamax(self.session)
        with recorder.use_cassette('set-attr-%s-%s' % (attr, value)):
            c = SomeComfort(self.username, self.password)
            device = self._get_device(c)
            setattr(device, attr, value)
            self.assertEqual(value, getattr(device, attr))
github kk7ds / somecomfort / tests / test_client.py View on Github external
def test_device_attributes(self):
        recorder = betamax.Betamax(self.session)
        with recorder.use_cassette('basic'):
            c = SomeComfort(self.username, self.password)

        device = self._get_device(c)
        self.assertEqual('THERMOSTAT', device.name)
        self.assertEqual(self.device, device.deviceid)
        self.assertFalse(device.fan_running)
        self.assertTrue(device.is_alive)
        self.assertEqual(77.0, device.setpoint_cool)
        self.assertEqual(58.0, device.setpoint_heat)
        self.assertEqual(58.0, device.current_temperature)
        self.assertEqual('F', device.temperature_unit)
        self.assertEqual('heat', device.system_mode)
        self.assertEqual('circulate', device.fan_mode)
        self.assertEqual(True, device.hold_heat)
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
help='Get the current hold mode')

    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():
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)
github kk7ds / somecomfort / somecomfort / __main__.py View on Github external
help='Get the current hold mode')

    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():
github home-assistant / home-assistant / homeassistant / components / honeywell / climate.py View on Github external
def _retry(self) -> bool:
        """Recreate a new somecomfort client.

        When we got an error, the best way to be sure that the next query
        will succeed, is to recreate a new somecomfort client.
        """
        try:
            self._client = somecomfort.SomeComfort(self._username, self._password)
        except somecomfort.AuthError:
            _LOGGER.error("Failed to login to honeywell account %s", self._username)
            return False
        except somecomfort.SomeComfortError as ex:
            _LOGGER.error("Failed to initialize honeywell client: %s", str(ex))
            return False

        devices = [
            device
            for location in self._client.locations_by_id.values()
            for device in location.devices_by_id.values()
            if device.name == self._device.name
        ]

        if len(devices) != 1:
            _LOGGER.error("Failed to find device %s", self._device.name)