Beispiel #1
0
 def test_firmware_version(self):
     with open('{}/api_responses/v1_hub.json'.format(os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     firmware = wink_hub.firmware_version()
     self.assertEqual(firmware, '3.3.26-0-gf4fa1428f9')
Beispiel #2
0
 def test_ip_address(self):
     with open('{}/api_responses/v1_hub.json'.format(os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     ip = wink_hub.ip_address()
     self.assertEqual(ip, '192.168.1.2')
Beispiel #3
0
 def test_update_needed(self):
     with open('{}/api_responses/v1_hub.json'.format(os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     update = wink_hub.update_needed()
     self.assertFalse(update)
Beispiel #4
0
 def test_kidde_radio_code(self):
     with open('{}/api_responses/v1_hub.json'.format(os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     code = wink_hub.kidde_radio_code()
     self.assertEqual(code, 0)
Beispiel #5
0
 def test_device_id_should_be_number(self):
     with open('{}/api_responses/v1_hub.json'.format(os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     device_id = wink_hub.device_id()
     self.assertRegex(device_id, "^[0-9]{4,6}")
Beispiel #6
0
 def test_firmware_version(self):
     with open('{}/api_responses/v1_hub.json'.format(
             os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     firmware = wink_hub.firmware_version()
     self.assertEqual(firmware, '3.3.26-0-gf4fa1428f9')
Beispiel #7
0
 def test_ip_address(self):
     with open('{}/api_responses/v1_hub.json'.format(
             os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     ip = wink_hub.ip_address()
     self.assertEqual(ip, '192.168.1.2')
Beispiel #8
0
 def test_update_needed(self):
     with open('{}/api_responses/v1_hub.json'.format(
             os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     update = wink_hub.update_needed()
     self.assertFalse(update)
Beispiel #9
0
 def test_kidde_radio_code(self):
     with open('{}/api_responses/v1_hub.json'.format(
             os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     code = wink_hub.kidde_radio_code()
     self.assertEqual(code, 0)
Beispiel #10
0
 def test_device_id_should_be_number(self):
     with open('{}/api_responses/v1_hub.json'.format(
             os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     device_id = wink_hub.device_id()
     self.assertRegex(device_id, "^[0-9]{4,6}")
Beispiel #11
0
 def test_model_name(self):
     with open('{}/api_responses/v1_hub.json'.format(
             os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     model_name = wink_hub.model_name
     self.assertEqual(model_name, 'Hub')
Beispiel #12
0
 def test_manufacturer(self):
     with open('{}/api_responses/v1_hub.json'.format(
             os.path.dirname(__file__))) as hub_file:
         response_dict = json.load(hub_file)
     hub = response_dict.get('data')[0]
     wink_hub = WinkHub(hub, self.api_interface)
     manufacturer = wink_hub.device_manufacturer
     self.assertEqual(manufacturer, 'wink')
Beispiel #13
0
def __get_sensor_from_hub(item, api_interface, filter_key):
    if filter_key != 'hub_id':
        return []
    keys = list(DEVICE_ID_KEYS.values())
    # Most devices have a hub_id, but we only want the actual hub.
    # This will only return hubs by checking for any other keys
    # being present along with the hub_id
    skip = False
    for key in keys:
        if key == "hub_id":
            continue
        if item.get(key, None) is not None:
            skip = True
    if skip:
        return []
    else:
        return [WinkHub(item, api_interface)]
Beispiel #14
0
def build_device(device_state_as_json, api_interface):

    new_object = None

    # These objects all share the same base class: WinkDevice

    if "light_bulb_id" in device_state_as_json:
        new_object = WinkBulb(device_state_as_json, api_interface)
    elif "sensor_pod_id" in device_state_as_json:
        new_object = WinkSensorPod(device_state_as_json, api_interface)
    elif "binary_switch_id" in device_state_as_json:
        new_object = WinkBinarySwitch(device_state_as_json, api_interface)
    elif "outlet_id" in device_state_as_json:
        new_object = WinkPowerStripOutlet(device_state_as_json, api_interface)
    elif "lock_id" in device_state_as_json:
        new_object = WinkLock(device_state_as_json, api_interface)
    elif "eggtray_id" in device_state_as_json:
        new_object = WinkEggTray(device_state_as_json, api_interface)
    elif "garage_door_id" in device_state_as_json:
        new_object = WinkGarageDoor(device_state_as_json, api_interface)
    elif "shade_id" in device_state_as_json:
        new_object = WinkShade(device_state_as_json, api_interface)
    elif "siren_id" in device_state_as_json:
        new_object = WinkSiren(device_state_as_json, api_interface)
    elif "key_id" in device_state_as_json:
        new_object = WinkKey(device_state_as_json, api_interface)
    elif "thermostat_id" in device_state_as_json:
        new_object = WinkThermostat(device_state_as_json, api_interface)
    elif "fan_id" in device_state_as_json:
        new_object = WinkFan(device_state_as_json, api_interface)
    # This must be at the bottom most devices have a hub_id listed
    # as their associated hub.
    elif "hub_id" in device_state_as_json:
        new_object = WinkHub(device_state_as_json, api_interface)

    return new_object or WinkDevice(device_state_as_json, api_interface)