• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python api.get_devices_from_response_dict函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pywink.api.get_devices_from_response_dict函数的典型用法代码示例。如果您正苦于以下问题:Python get_devices_from_response_dict函数的具体用法?Python get_devices_from_response_dict怎么用?Python get_devices_from_response_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_devices_from_response_dict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_should_handle_porkfolio_response

 def test_should_handle_porkfolio_response(self):
     with open('{}/api_responses/porkfolio.json'.format(os.path.dirname(__file__))) as porkfolio_file:
         response_dict = json.load(porkfolio_file)
     devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.PIGGY_BANK])
     self.assertEqual(2, len(devices))
     self.assertIsInstance(devices[0], WinkCurrencySensor)
     self.assertIsInstance(devices[1], WinkPorkfolioNose)
开发者ID:w1ll1am23,项目名称:python-wink,代码行数:7,代码来源:init_test.py


示例2: test_should_handle_power_strip_response

 def test_should_handle_power_strip_response(self):
     with open('{}/api_responses/power_strip.json'.format(os.path.dirname(__file__))) as powerstrip_file:
         response_dict = json.load(powerstrip_file)
     devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.POWER_STRIP])
     self.assertEqual(2, len(devices))
     self.assertIsInstance(devices[0], WinkPowerStripOutlet)
     self.assertIsInstance(devices[1], WinkPowerStripOutlet)
开发者ID:BryonCLewis,项目名称:python-wink,代码行数:7,代码来源:init_test.py


示例3: test_gocontrol_motion_sensor_should_be_identified

 def test_gocontrol_motion_sensor_should_be_identified(self):
     response = ApiResponseJSONLoader('motion_sensor_gocontrol.json').load()
     devices = get_devices_from_response_dict(response,
                                              DEVICE_ID_KEYS[
                                                  device_types.SENSOR_POD])
     self.assertEqual(1, len(devices))
     self.assertIsInstance(devices[0], WinkSensorPod)
开发者ID:BryonCLewis,项目名称:python-wink,代码行数:7,代码来源:init_test.py


示例4: test_pubnub_key_and_channel_should_be_none

    def test_pubnub_key_and_channel_should_be_none(self):
        with open('{}/api_responses/lock.json'.format(os.path.dirname(__file__))) as lock_file:
            response_dict = json.load(lock_file)
        device = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.LOCK])[0]

        self.assertIsNone(device.pubnub_key)
        self.assertIsNone(device.pubnub_channel)
开发者ID:w1ll1am23,项目名称:python-wink,代码行数:7,代码来源:init_test.py


示例5: test_battery_level_should_return_float

    def test_battery_level_should_return_float(self):
        with open('{}/api_responses/quirky_spotter_2.json'.format(os.path.dirname(__file__))) as spotter_file:
            response_dict = json.load(spotter_file)

        sensors = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])

        for sensor in sensors:
            self.assertEqual(sensor.battery_level, 0.86)
开发者ID:BryonCLewis,项目名称:python-wink,代码行数:8,代码来源:init_test.py


示例6: test_should_be_true_if_thermostat_fan_is_on

    def test_should_be_true_if_thermostat_fan_is_on(self):
        with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
            response_dict = json.load(thermostat_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])

        thermostat = devices[0]
        """ :type thermostat: pywink.devices.standard.WinkThermostat """
        self.assertTrue(thermostat.fan_on())
开发者ID:python-wink,项目名称:python-wink,代码行数:8,代码来源:thermostat_test.py


示例7: test_should_be_cool_only_for_current_hvac_mode

    def test_should_be_cool_only_for_current_hvac_mode(self):
        with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
            response_dict = json.load(thermostat_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])

        thermostat = devices[0]
        """ :type thermostat: pywink.devices.standard.WinkThermostat """
        self.assertEqual('cool_only', thermostat.current_hvac_mode())
开发者ID:python-wink,项目名称:python-wink,代码行数:8,代码来源:thermostat_test.py


示例8: test_should_be_false_if_response_doesnt_contains_aux_capabilities

    def test_should_be_false_if_response_doesnt_contains_aux_capabilities(self):
        with open('{}/api_responses/nest.json'.format(os.path.dirname(__file__))) as thermostat_file:
            response_dict = json.load(thermostat_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])

        thermostat = devices[0]
        """ :type thermostat: pywink.devices.standard.WinkThermostat """
        self.assertFalse('aux' in thermostat.hvac_modes())
开发者ID:python-wink,项目名称:python-wink,代码行数:8,代码来源:thermostat_test.py


示例9: test_current_min_set_point

    def test_current_min_set_point(self):
        with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
            response_dict = json.load(thermostat_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])

        thermostat = devices[0]
        """ :type thermostat: pywink.devices.standard.WinkThermostat """
        self.assertEqual(22.22222222222222, thermostat.current_min_set_point())
开发者ID:python-wink,项目名称:python-wink,代码行数:8,代码来源:thermostat_test.py


示例10: test_objectprefix_should_be_correct

 def test_objectprefix_should_be_correct(self):
     with open('{}/api_responses/smoke_detector.json'.format(os.path.dirname(__file__))) as smoke_detector_file:
         response_dict = json.load(smoke_detector_file)
     devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SMOKE_DETECTOR])
     objectprefix = devices[0].objectprefix
     self.assertRegex(objectprefix, "smoke_detectors")
     objectprefix = devices[1].objectprefix
     self.assertRegex(objectprefix, "smoke_detectors")
开发者ID:python-wink,项目名称:python-wink,代码行数:8,代码来源:init_test.py


示例11: test_should_handle_relay_response

 def test_should_handle_relay_response(self):
     with open('{}/api_responses/wink_relay_sensor.json'.format(os.path.dirname(__file__))) as relay_file:
         response_dict = json.load(relay_file)
     devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])
     self.assertEqual(4, len(devices))
     self.assertIsInstance(devices[0], WinkHumiditySensor)
     self.assertIsInstance(devices[1], WinkTemperatureSensor)
     self.assertIsInstance(devices[2], WinkPresenceSensor)
     self.assertIsInstance(devices[3], WinkProximitySensor)
开发者ID:w1ll1am23,项目名称:python-wink,代码行数:9,代码来源:init_test.py


示例12: test_device_id_should_be_number

    def test_device_id_should_be_number(self):
        with open('{}/api_responses/porkfolio.json'.format(os.path.dirname(__file__))) as porkfolio_file:
            response_dict = json.load(porkfolio_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.PIGGY_BANK])
        device_id = devices[0].device_id()
        self.assertRegex(device_id, "^[0-9]{4,6}")

        device_id = devices[1].device_id()
        self.assertRegex(device_id, "^[0-9]{4,6}")
开发者ID:w1ll1am23,项目名称:python-wink,代码行数:9,代码来源:init_test.py


示例13: test_current_humidifier_mode

    def test_current_humidifier_mode(self):
        # sensi.json been faked to add in the humidifier_mode field for testing.
        with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
            response_dict = json.load(thermostat_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])

        thermostat = devices[0]
        """ :type thermostat: pywink.devices.standard.WinkThermostat """
        self.assertEqual('auto', thermostat.current_humidifier_mode())
开发者ID:python-wink,项目名称:python-wink,代码行数:9,代码来源:thermostat_test.py


示例14: test_should_be_true_if_thermostat_has_detected_occupancy

    def test_should_be_true_if_thermostat_has_detected_occupancy(self):
        # sensi.json been faked to add in the occupied field for testing.
        with open('{}/api_responses/sensi.json'.format(os.path.dirname(__file__))) as thermostat_file:
            response_dict = json.load(thermostat_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.THERMOSTAT])

        thermostat = devices[0]
        """ :type thermostat: pywink.devices.standard.WinkThermostat """
        self.assertTrue(thermostat.occupied())
开发者ID:python-wink,项目名称:python-wink,代码行数:9,代码来源:thermostat_test.py


示例15: test_brightness_should_have_correct_value

    def test_brightness_should_have_correct_value(self):
        with open('{}/api_responses/quirky_spotter.json'.format(os.path.dirname(__file__))) as spotter_file:
            response_dict = json.load(spotter_file)

        sensors = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])
        """:type : list of WinkBrightnessSensor"""
        brightness_sensor = [sensor for sensor in sensors if sensor.capability() is WinkBrightnessSensor.CAPABILITY][0]
        expected_brightness = 1
        self.assertEquals(expected_brightness, brightness_sensor.brightness_percentage())
开发者ID:johnsonld123,项目名称:python-wink,代码行数:9,代码来源:sensor_test.py


示例16: test_device_id_should_start_with_a_number

    def test_device_id_should_start_with_a_number(self):
        with open('{}/api_responses/quirky_spotter.json'.format(os.path.dirname(__file__))) as spotter_file:
            response_dict = json.load(spotter_file)

        sensors = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])

        for sensor in sensors:
            device_id = sensor.device_id()
            self.assertRegex(device_id, "^[0-9]{4,6}")
开发者ID:BryonCLewis,项目名称:python-wink,代码行数:9,代码来源:init_test.py


示例17: test_temperature_should_have_correct_value

    def test_temperature_should_have_correct_value(self):
        with open('{}/api_responses/quirky_spotter.json'.format(os.path.dirname(__file__))) as spotter_file:
            response_dict = json.load(spotter_file)

        sensors = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])
        """:type : list of WinkTemperatureSensor"""
        temp_sensor = [sensor for sensor in sensors if sensor.capability() is WinkTemperatureSensor.CAPABILITY][0]
        expected_temperature = 5
        self.assertEquals(expected_temperature, temp_sensor.temperature_float())
开发者ID:BryonCLewis,项目名称:python-wink,代码行数:9,代码来源:init_test.py


示例18: test_vibration_should_have_correct_value

    def test_vibration_should_have_correct_value(self):
        with open('{}/api_responses/quirky_spotter.json'.format(os.path.dirname(__file__))) as spotter_file:
            response_dict = json.load(spotter_file)

        sensors = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.SENSOR_POD])
        """:type : list of WinkVibrationPresenceSensor"""
        vibration_sensor = [sensor for sensor in sensors if sensor.capability() is WinkVibrationPresenceSensor.CAPABILITY][0]
        expected_vibrartion_presence = False
        self.assertEquals(expected_vibrartion_presence, vibration_sensor.vibration_boolean())
开发者ID:BryonCLewis,项目名称:python-wink,代码行数:9,代码来源:init_test.py


示例19: test_should_be_false_if_response_does_not_contain_rgb_capabilities

    def test_should_be_false_if_response_does_not_contain_rgb_capabilities(self):
        with open('{}/api_responses/rgb_absent.json'.format(os.path.dirname(__file__))) as light_file:
            response_dict = json.load(light_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.LIGHT_BULB])

        bulb = devices[0]
        """ :type bulb: pywink.devices.standard.WinkBulb """
        supports_rgb = bulb.supports_rgb()
        self.assertFalse(supports_rgb,
                        msg="Expected rgb to be un-supported")
开发者ID:w1ll1am23,项目名称:python-wink,代码行数:10,代码来源:bulb_test.py


示例20: test_should_be_true_if_response_contains_xy_capabilities

    def test_should_be_true_if_response_contains_xy_capabilities(self):
        with open('{}/api_responses/xy_present.json'.format(os.path.dirname(__file__))) as light_file:
            response_dict = json.load(light_file)
        devices = get_devices_from_response_dict(response_dict, DEVICE_ID_KEYS[device_types.LIGHT_BULB])

        bulb = devices[0]
        """ :type bulb: pywink.devices.standard.WinkBulb """
        supports_xy = bulb.supports_xy_color()
        self.assertTrue(supports_xy,
                        msg="Expected xy to be supported")
开发者ID:w1ll1am23,项目名称:python-wink,代码行数:10,代码来源:bulb_test.py



注:本文中的pywink.api.get_devices_from_response_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python hid.find_all_hid_devices函数代码示例发布时间:2022-05-26
下一篇:
Python pywink.set_bearer_token函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap