Exemple #1
0
 def test_01_Interface(self):
     l_ctlr = self.m_xml.controller_sect[1]
     l_device = ControllerData()
     l_obj = lightingcoreAPI.read_core_lighting_xml(l_device, l_ctlr, self.m_version)
     print(PrettyFormatAny.form(l_obj, 'L L'))
     L_interface = usbXML.read_interface_xml(l_ctlr)
     stuff_new_attrs(l_obj, L_interface)
     print(PrettyFormatAny.form(l_obj, 'L L'))
     self.assertEqual(l_obj.Vendor, int(TESTING_USB_VENDOR))
     self.assertEqual(l_obj.Product, int(TESTING_USB_PRODUCT))
Exemple #2
0
 def test_01_Interface(self):
     l_ctlr = self.m_xml.controller_sect[1]
     l_device = ControllerData()
     l_obj = lightingcoreAPI.read_core_lighting_xml(l_device, l_ctlr,
                                                    self.m_version)
     print(PrettyFormatAny.form(l_obj, 'L L'))
     L_interface = usbXML.read_interface_xml(l_ctlr)
     stuff_new_attrs(l_obj, L_interface)
     print(PrettyFormatAny.form(l_obj, 'L L'))
     self.assertEqual(l_obj.Vendor, int(TESTING_USB_VENDOR))
     self.assertEqual(l_obj.Product, int(TESTING_USB_PRODUCT))
Exemple #3
0
 def test_01_Interface(self):
     l_ctlr = self.m_xml.controller_sect[1]
     l_device = ControllerData()
     l_obj = lightingcoreAPI.read_core_lighting_xml(l_device, l_ctlr, self.m_version)
     L_interface = usbXML.read_interface_xml(l_ctlr)
     stuff_new_attrs(l_obj, L_interface)
     #
     l_xml = lightingcoreAPI.write_core_lighting_xml('TestController', l_obj)
     usbXML.write_interface_xml(l_xml, l_obj)
     print(PrettyFormatAny.form(l_xml, 'XML'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_CONTROLLER_NAME_1)
     self.assertEqual(l_xml.attrib['Key'], TESTING_CONTROLLER_KEY_1)
     self.assertEqual(l_xml.attrib['Active'], TESTING_CONTROLLER_ACTIVE_1)
     self.assertEqual(l_xml.find('Vendor').text, TESTING_USB_VENDOR)
     self.assertEqual(l_xml.find('Product').text, TESTING_USB_PRODUCT)
Exemple #4
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.
        @param p_index: is the index of the first byte in the message.
                Various messages contain the address at different offsets.
        @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 = DeviceData()
            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
Exemple #5
0
 def test_01_Interface(self):
     l_ctlr = self.m_xml.controller_sect[1]
     l_device = ControllerData()
     l_obj = lightingcoreAPI.read_core_lighting_xml(l_device, l_ctlr,
                                                    self.m_version)
     L_interface = usbXML.read_interface_xml(l_ctlr)
     stuff_new_attrs(l_obj, L_interface)
     #
     l_xml = lightingcoreAPI.write_core_lighting_xml(
         'TestController', l_obj)
     usbXML.write_interface_xml(l_xml, l_obj)
     print(PrettyFormatAny.form(l_xml, 'XML'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_CONTROLLER_NAME_1)
     self.assertEqual(l_xml.attrib['Key'], TESTING_CONTROLLER_KEY_1)
     self.assertEqual(l_xml.attrib['Active'], TESTING_CONTROLLER_ACTIVE_1)
     self.assertEqual(l_xml.find('Vendor').text, TESTING_USB_VENDOR)
     self.assertEqual(l_xml.find('Product').text, TESTING_USB_PRODUCT)
Exemple #6
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.
        @param p_index: is the index of the first byte in the message.
                Various messages contain the address at different offsets.
        @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 = DeviceData()
            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
Exemple #7
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 = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Lights, p_address)
     l_dotted = conversions.int2dotted_hex(p_address, 3)
     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)
     #  Add additional classes in here
     if l_ret == None:
         LOG.info("WARNING - Address {} ({}) *NOT* found.".format(l_dotted, p_address))
         l_ret = DeviceData()
         device_tools.stuff_new_attrs(l_ret, InsteonData())  #  an empty new object
         l_ret.Name = '**NoName-' + l_dotted + '-**'
     return l_ret
Exemple #8
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 = Decode._find_addr_one_class(p_pyhouse_obj, p_pyhouse_obj.House.Lighting.Lights, p_address)
     l_dotted = conversions.int2dotted_hex(p_address, 3)
     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)
     #  Add additional classes in here
     if l_ret == None:
         LOG.info("WARNING - Address {} ({}) *NOT* found.".format(l_dotted, p_address))
         l_ret = DeviceData()
         device_tools.stuff_new_attrs(l_ret, InsteonData())  #  an empty new object
         l_ret.Name = '**NoName-' + l_dotted + '-**'
     return l_ret