def test_01_StuffAttrs(self): l_objA = CoreLightingData() l_objA.Name = 'Test 1A' # print(PrettyFormatAny.form(l_objA, 'Obj A')) l_objB = LocationData() l_objB.Street = 'Some road' # print(PrettyFormatAny.form(l_objB, 'Obj B', 120)) # stuff_new_attrs(l_objA, l_objB) # print(PrettyFormatAny.form(l_objA, 'Result B stuffed into A', 120)) self.assertEqual(l_objA.Street, 'Some road')
def test_01_StuffAttrs(self): l_objA = CoreLightingData() l_objA.Name = 'Test 1A' # print(PrettyFormatAny.form(l_objA, 'Obj A')) l_objB = LocationInformation() l_objB.Street = 'Some road' # print(PrettyFormatAny.form(l_objB, 'Obj B', 120)) # stuff_new_attrs(l_objA, l_objB) # print(PrettyFormatAny.form(l_objA, 'Result B stuffed into A', 120)) self.assertEqual(l_objA.Street, 'Some road')
def get_obj_from_message(p_pyhouse_obj, p_message_addr): """ Here we have a message from the PLM. Find out what device has that address. @param p_message_addr: is the address portion of the message byte array from the PLM we are extracting the Insteon address from. @return: The object that contains the address -OR- a dummy object with noname in Name """ l_address = Util.message2int(p_message_addr) # Extract the 3 byte address from the message and convert to an Int. if l_address < (256 * 256): # First byte zero ? l_dotted = str(l_address) l_device_obj = CoreLightingData() device_tools.stuff_new_attrs(l_device_obj, InsteonData()) # an empty new object l_device_obj.Name = '**Group: ' + l_dotted + ' **' else: l_device_obj = Decode.find_address_all_classes(p_pyhouse_obj, l_address) return l_device_obj
def find_address_all_classes(p_pyhouse_obj, p_address): """ This will search thru all object groups that an inseton device could be in. @return: the object that has the address or a dummy object if not found """ l_ret = None l_house = p_pyhouse_obj.House if hasattr(l_house, 'Lighting'): if l_ret == None and l_house.Lighting.Lights != None: l_ret = Decode._find_addr_one_class( p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Lights, p_address) if l_ret == None and l_house.Lighting.Controllers != None: l_ret = Decode._find_addr_one_class( p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Controllers, p_address) if l_ret == None and l_house.Lighting.Buttons != None: l_ret = Decode._find_addr_one_class( p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Buttons, p_address) if l_ret == None and l_house.Lighting.Outlets != None: l_ret = Decode._find_addr_one_class( p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Outlets, p_address) if hasattr(l_house, 'Hvac') and hasattr(l_house.Hvac, 'Thermostats'): if l_ret == None and l_house.Hvac.Thermostats != None: l_ret = Decode._find_addr_one_class( p_pyhouse_obj, p_pyhouse_obj.House.Hvac.Thermostats, p_address) if hasattr(l_house, 'Security'): if hasattr(l_house.Security, 'GarageDoors'): if l_ret == None and l_house.Security.GarageDoors != None: l_ret = Decode._find_addr_one_class( p_pyhouse_obj, p_pyhouse_obj.House.Security.GarageDoors, p_address) if hasattr(l_house.Security, 'MotionSensors'): if l_ret == None and l_house.Security.MotionSensors != None: l_ret = Decode._find_addr_one_class( p_pyhouse_obj, p_pyhouse_obj.House.Security.MotionSensors, p_address) # Add additional classes in here if l_ret == None: LOG.info("WARNING - Address {} *NOT* found.".format(p_address)) l_ret = CoreLightingData() stuff_new_attrs(l_ret, InsteonData()) # an empty new object l_ret.Name = '**NoName-' + p_address + '-**' return l_ret
def get_obj_from_message(self, p_pyhouse_obj, p_message_addr, offset=0): """ Here we have a message to or from an Insteon device. Find out what device has that address. @param p_message_addr: is the address portion of the message byte array from the PLM we are extracting the Insteon address from. @return: The device object that contains the address -OR- a dummy object with noname in Name """ # LOG.debug('Addr ') # Extract the 3 byte Insteon address from the message l_address = extract_address_from_message(p_message_addr, offset) if l_address.startswith('00'): # First byte zero ? l_dotted = str(l_address) l_device_obj = CoreLightingData() stuff_new_attrs(l_device_obj, InsteonData()) # an empty new object l_device_obj.Name = '**Group: ' + l_dotted + ' **' else: l_device_obj = Decode.find_address_all_classes( p_pyhouse_obj, l_address) return l_device_obj
def find_address_all_classes(p_pyhouse_obj, p_address): """ This will search thru all object groups that an inseton device could be in. @return: the object that has the address or a dummy object if not found """ l_dotted = conversions.int2dotted_hex(p_address, 3) l_ret = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Lights, p_address) if l_ret == None: l_ret = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Controllers, p_address) if l_ret == None: l_ret = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Buttons, p_address) if l_ret == None: l_ret = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Hvac.Thermostats, p_address) if l_ret == None: l_ret = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Security.GarageDoors, p_address) if l_ret == None: l_ret = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Security.MotionSensors, p_address) # Add additional classes in here if l_ret == None: LOG.info("WARNING - Address {} ({}) *NOT* found.".format(l_dotted, p_address)) l_ret = CoreLightingData() device_tools.stuff_new_attrs(l_ret, InsteonData()) # an empty new object l_ret.Name = '**NoName-' + l_dotted + '-**' return l_ret