Beispiel #1
0
    def test_state_should_be_true_or_false(self):
        with open('{}/api_responses/key.json'.format(os.path.dirname(__file__))) as keys_file:
            response_dict = json.load(keys_file)
        key = response_dict.get('data')

        wink_true_key = WinkKey(key, self.api_interface) 
        self.assertTrue(wink_true_key.state())
Beispiel #2
0
    def test_state_should_be_true_or_false(self):
        with open('{}/api_responses/key.json'.format(
                os.path.dirname(__file__))) as keys_file:
            response_dict = json.load(keys_file)
        key = response_dict.get('data')

        wink_true_key = WinkKey(key, self.api_interface)
        self.assertTrue(wink_true_key.state())
Beispiel #3
0
    def test_device_id_should_be_number(self):
        with open('{}/api_responses/key.json'.format(os.path.dirname(__file__))) as keys_file:
            response_dict = json.load(keys_file)
        key = response_dict.get('data')

        wink_key = WinkKey(key, self.api_interface)
        device_id = wink_key.device_id()
        self.assertRegex(device_id, "^[0-9]{4,6}$") 
Beispiel #4
0
    def test_device_id_should_be_number(self):
        with open('{}/api_responses/key.json'.format(
                os.path.dirname(__file__))) as keys_file:
            response_dict = json.load(keys_file)
        key = response_dict.get('data')

        wink_key = WinkKey(key, self.api_interface)
        device_id = wink_key.device_id()
        self.assertRegex(device_id, "^[0-9]{4,6}$")
Beispiel #5
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)