Пример #1
0
 def test_02_BaseObject(self):
     """Write Base Object XML w/ NO UUID
     """
     l_base_obj = CoreLightingData()
     XmlConfigTools.read_base_object_xml(l_base_obj, self.m_xml.light)
     l_base_obj.Key = 44
     l_xml = XmlConfigTools.write_base_object_xml('Light', l_base_obj, no_uuid = True)
     print(PrettyFormatAny.form(l_xml, 'XML'))
     self.assertEqual(l_xml.attrib['Name'], 'Insteon Light')
     self.assertEqual(l_xml.attrib['Key'], '44')
Пример #2
0
 def test_02_BaseObject(self):
     """Write Base Object XML w/ NO UUID
     """
     l_base_obj = CoreLightingData()
     self.m_apix.read_base_UUID_object_xml(l_base_obj, self.m_xml.light)
     l_base_obj.Key = 44
     l_xml = self.m_apix.write_base_object_xml('Light', l_base_obj)
     # print(PrettyFormatAny.form(l_xml, 'K1-02-A - XML'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_LIGHT_NAME_0)
     self.assertEqual(l_xml.attrib['Key'], '44')
Пример #3
0
 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')
Пример #4
0
 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')
Пример #5
0
 def test_01_BaseObject(self):
     """Write Base Object XML w/UUID
     """
     l_base_obj = CoreLightingData()
     XmlConfigTools.read_base_object_xml(l_base_obj, self.m_xml.light)
     l_base_obj.Key = 43
     l_uuid = '12345678-fedc-1111-ffff-aaBBccDDeeFF'
     l_base_obj.UUID = l_uuid
     l_xml = XmlConfigTools.write_base_object_xml('Light', l_base_obj)
     print(PrettyFormatAny.form(l_xml, 'XML'))
     self.assertEqual(l_xml.attrib['Name'], 'Insteon Light')
     self.assertEqual(l_xml.attrib['Key'], '43')
     self.assertEqual(l_xml.find('UUID').text, l_uuid)
Пример #6
0
 def test_01_BaseObject(self):
     """Write Base Object XML w/UUID
     """
     l_base_obj = CoreLightingData()
     self.m_apix.read_base_UUID_object_xml(l_base_obj, self.m_xml.light)
     l_base_obj.Key = 43
     l_uuid = '12345678-fedc-1111-ffff-aaBBccDDeeFF'
     l_base_obj.UUID = l_uuid
     l_xml = self.m_apix.write_base_UUID_object_xml('Light', l_base_obj)
     # print(PrettyFormatAny.form(l_xml, 'K1-01-A - XML'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_LIGHT_NAME_0)
     self.assertEqual(l_xml.attrib['Key'], '43')
     self.assertEqual(l_xml.find('UUID').text, l_uuid)
Пример #7
0
    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
Пример #8
0
 def test_01_BaseObject(self):
     l_base_obj = CoreLightingData()
     self.m_apix.read_base_object_xml(l_base_obj, self.m_xml.light)
     # print(PrettyFormatAny.form(l_base_obj, 'J2-01-A Base))
     self.assertEqual(l_base_obj.Name, '')
     self.assertEqual(l_base_obj.Key, 0)
     self.assertEqual(l_base_obj.Active, False)
Пример #9
0
 def test_02_readBaseObject(self):
     l_base_obj = CoreLightingData()
     self.m_apix.read_base_UUID_object_xml(l_base_obj,
                                           self.m_xml.controller)
     self.assertEqual(str(l_base_obj.Name), TESTING_CONTROLLER_NAME_0)
     self.assertEqual(str(l_base_obj.Key), TESTING_CONTROLLER_KEY_0)
     self.assertEqual(str(l_base_obj.Active), TESTING_CONTROLLER_ACTIVE_0)
Пример #10
0
 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
Пример #11
0
 def test_01_BaseUUIDObject(self):
     l_base_obj = CoreLightingData()
     self.m_apix.read_base_UUID_object_xml(l_base_obj, self.m_xml.light)
     print(PrettyFormatAny.form(l_base_obj, 'J1-01-A - Base Obj'))
     self.assertEqual(l_base_obj.Name, TESTING_LIGHT_NAME_0)
     self.assertEqual(l_base_obj.Key, 0)
     self.assertEqual(str(l_base_obj.Active), TESTING_LIGHT_ACTIVE_0)
     self.assertEqual(l_base_obj.UUID, TESTING_LIGHT_UUID_0)
Пример #12
0
    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
Пример #13
0
 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
Пример #14
0
 def test_02_readBaseObject(self):
     l_base_obj = CoreLightingData()
     self.m_api.read_base_object_xml(l_base_obj, self.m_xml.controller)
     self.assertEqual(l_base_obj.Name, 'Insteon Serial Controller')
     self.assertEqual(l_base_obj.Key, 0)
     self.assertEqual(l_base_obj.Active, True)
Пример #15
0
 def test_01_BaseObject(self):
     l_base_obj = CoreLightingData()
     self.m_api.read_base_object_xml(l_base_obj, self.m_xml.light)
     self.assertEqual(l_base_obj.Name, TESTING_LIGHT_NAME_0)
     self.assertEqual(l_base_obj.Key, 0)
     self.assertEqual(l_base_obj.Active, True)