Exemplo n.º 1
0
def test_factory_creates_the_right_type_for_fire_sensor():
    data = {"data": {"cmdId": Command.DEVICE_STATUS_UPDATE.value,
                     "device_name": DeviceType.FIRE_ALARM.value,
                     "device_ID": "vader",
                     "device_status": "  2AAA  "}}
    device = create_device_from_data(data)
    assert isinstance(device, AlarmSensor)
Exemplo n.º 2
0
def alarm_device():
    data = {"data": {"cmdId": Command.DEVICE_STATUS_UPDATE.value,
                     "device_name": DeviceType.CO_ALARM.value,
                     "device_ID": "vader",
                     "device_status": "  2AAA  "}}
    device = create_device_from_data(data)
    return device
Exemplo n.º 3
0
def test_factory_creates_the_right_type_for_window_sensor():
    data = {"data": {"cmdId": Command.DEVICE_STATUS_UPDATE.value,
                     "device_name": DeviceType.DOOR_WINDOW_SENSOR.value,
                     "device_ID": "vader",
                     "device_status": "  2AAA  "}}
    device = create_device_from_data(data)
    assert isinstance(device, WindowSensor)
Exemplo n.º 4
0
 async def create_device(self, data):
     """
     Creates a new device in the device dict
     :param data: The data to create the device from
     :return: The device object
     """
     logging.info("Create device.")
     dev = create_device_from_data(data)
     d_id = data["data"]["device_ID"]
     if self.unregistered_names.get(d_id):
         dev.name = self.unregistered_names[d_id]
         del self.unregistered_names[d_id]
     self.devices[d_id] = dev
     await self.new_device_send_ch.send(d_id)
     return self.devices[d_id]
Exemplo n.º 5
0
def device(update_data):
    device = create_device_from_data(update_data)
    return device