def test_23_power(self): tl = Entity('POWER-0', EntityType.find(100), 'Power plug') tl.assigned_id = 1 tl.last_checkin = time.time() - 3600 # one hour before tl.save() self.printall() print tl
def test_20_light_create(self): tl = Entity('LIGHT-1', EntityType.find(101), name='Sample light') tl.assigned_id = 2 tl.state = STATE_ON tl.last_checkin = time.time() tl.save() self.printall() print tl
def describe(self, address, unique_id, data): ''' Registers a device for the given physical address. ''' DeviceHandler.describe(self, address, unique_id, data) etype_id = data[0] etype = EntityType.find(etype_id) if etype: entity = Entity.find(unique_id) if entity is None: entity = Entity(unique_id, etype, 'Unknown device: ' + unique_id, last_checkin=time.time()) entity.save() print 'Device registered:', entity ClientModule.instance().send_state_change(entity) else: entity.last_checkin = time.time() entity.save() print 'Device found:', entity ClientModule.instance().send_state_change(entity) else: print 'Entity type not found:', etype_id
def test_10_Create(self): te = Entity( 'UID-1234', EntityType.find(199) ) te.save() self.printall()