def test_05_OneController(self): """ Read in the xml file and fill in the lights """ l_obj = Utility._read_one_controller_xml(self.m_pyhouse_obj, self.m_xml.controller) # print(PrettyFormatAny.form(l_obj, 'B1-05-A - OneController', 100)) self.assertEqual(l_obj.Name, TESTING_CONTROLLER_NAME_0) self.assertEqual(l_obj.Active, (TESTING_CONTROLLER_ACTIVE_0 == 'True')) self.assertEqual(l_obj.Comment, TESTING_DEVICE_COMMENT_0) self.assertEqual(l_obj.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON) self.assertEqual(l_obj.DeviceType, int(TESTING_DEVICE_TYPE)) self.assertEqual(l_obj.DeviceSubType, int(TESTING_DEVICE_SUBTYPE)) self.assertEqual(l_obj.RoomName, TESTING_DEVICE_ROOM_NAME) self.assertEqual(l_obj.InterfaceType, TESTING_INTERFACE_TYPE_SERIAL) self.assertEqual(l_obj.Port, TESTING_INTERFACE_PORT_SERIAL) self.assertEqual(l_obj.BaudRate, int(TESTING_SERIAL_BAUD_RATE)) self.assertEqual(l_obj.ByteSize, int(TESTING_SERIAL_BYTE_SIZE)) self.assertEqual(l_obj.Parity, TESTING_SERIAL_PARITY) self.assertEqual(str(l_obj.RtsCts), TESTING_SERIAL_RTS_CTS) self.assertEqual(l_obj.StopBits, float(TESTING_SERIAL_STOP_BITS)) self.assertEqual(l_obj.Timeout, float(TESTING_SERIAL_TIMEOUT)) self.assertEqual(l_obj.XonXoff, TESTING_SERIAL_XON_XOFF == 'True') self.assertEqual(conversions.int2dotted_hex(l_obj.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_1) self.assertEqual(conversions.int2dotted_hex(l_obj.DevCat, 2), TESTING_INSTEON_DEVCAT_1) self.assertEqual(l_obj.GroupList, TESTING_INSTEON_GROUP_LIST_1) self.assertEqual(str(l_obj.GroupNumber), TESTING_INSTEON_GROUP_NUM_1)
def test_03_Insteon(self): """Read the Insteon specific information. """ l_insteon = insteonXml._read_insteon(self.m_xml.light) self.assertEqual(conversions.int2dotted_hex(l_insteon.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_0) self.assertEqual(conversions.int2dotted_hex(l_insteon.DevCat, 2), TESTING_INSTEON_DEVCAT_0) self.assertEqual(l_insteon.GroupList, TESTING_INSTEON_GROUP_LIST_0) self.assertEqual(l_insteon.GroupNumber, int(TESTING_INSTEON_GROUP_NUM_0)) self.assertEqual(conversions.int2dotted_hex(l_insteon.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def WriteXml(p_out_xml, p_device): """ @param p_xml_out: is a parent element to which the Insteon Specific information is appended. """ PutGetXML.put_text_element(p_out_xml, 'InsteonAddress', conversions.int2dotted_hex(p_device.InsteonAddress, 3)) PutGetXML.put_int_element(p_out_xml, 'DevCat', conversions.int2dotted_hex(p_device.DevCat, 2)) PutGetXML.put_text_element(p_out_xml, 'GroupList', p_device.GroupList) PutGetXML.put_int_element(p_out_xml, 'GroupNumber', p_device.GroupNumber) PutGetXML.put_text_element(p_out_xml, 'ProductKey', conversions.int2dotted_hex(p_device.ProductKey, 3)) PutGetXML.put_int_element(p_out_xml, 'Version', p_device.Version) return p_out_xml
def test_03_Insteon(self): """Read the Insteon specific information. """ l_obj = insteonXml._read_insteon(self.m_xml.light) # print(PrettyFormatAny.form(l_obj, 'C1-03-A - Insteon (only)')) self.assertEqual(conversions.int2dotted_hex(l_obj.DevCat, 2), TESTING_INSTEON_DEVCAT_0) self.assertEqual(str(l_obj.EngineVersion), TESTING_INSTEON_ENGINE_VERSION_0) self.assertEqual(str(l_obj.FirmwareVersion), TESTING_INSTEON_FIRMWARE_VERSION_0) self.assertEqual(l_obj.GroupList, TESTING_INSTEON_GROUP_LIST_0) self.assertEqual(str(l_obj.GroupNumber), TESTING_INSTEON_GROUP_NUM_0) self.assertEqual(conversions.int2dotted_hex(l_obj.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_0) self.assertEqual(conversions.int2dotted_hex(l_obj.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def test_04_Family(self): """Read and add the family specific parts. """ l_xml = self.m_xml.thermostat l_obj = Utility._read_thermostat_base(l_xml) Utility._read_thermostat_data(l_obj, l_xml) Utility._read_family_data(self.m_pyhouse_obj, l_obj, l_xml) self.assertEqual(conversions.int2dotted_hex(l_obj.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_0) self.assertEqual(conversions.int2dotted_hex(l_obj.DevCat, 2), TESTING_INSTEON_DEVCAT_0) self.assertEqual(l_obj.GroupList, TESTING_INSTEON_GROUP_LIST_0) self.assertEqual(l_obj.GroupNumber, int(TESTING_INSTEON_GROUP_NUM_0)) self.assertEqual(conversions.int2dotted_hex(l_obj.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def test_04_Family(self): """Read controller family """ l_xml = self.m_xml.controller l_obj = Utility._read_base_device(self.m_pyhouse_obj, l_xml) Utility._read_controller_data(self.m_pyhouse_obj, l_obj, l_xml) Utility._read_interface_data(self.m_pyhouse_obj, l_obj, l_xml) Utility._read_family_data(self.m_pyhouse_obj, l_obj, l_xml) # print(PrettyFormatAny.form(l_obj, 'B1-04-A - Family')) self.assertEqual(conversions.int2dotted_hex(l_obj.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_1) self.assertEqual(conversions.int2dotted_hex(l_obj.DevCat, 2), TESTING_INSTEON_DEVCAT_1) self.assertEqual(conversions.int2dotted_hex(l_obj.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_1) self.assertEqual(l_obj.GroupList, TESTING_INSTEON_GROUP_LIST_1) self.assertEqual(str(l_obj.GroupNumber), TESTING_INSTEON_GROUP_NUM_1)
def test_03_Insteon(self): """Read the Insteon specific information. """ l_insteon = insteonXml._read_insteon(self.m_xml.light) self.assertEqual( conversions.int2dotted_hex(l_insteon.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_0) self.assertEqual(conversions.int2dotted_hex(l_insteon.DevCat, 2), TESTING_INSTEON_DEVCAT_0) self.assertEqual(l_insteon.GroupList, TESTING_INSTEON_GROUP_LIST_0) self.assertEqual(l_insteon.GroupNumber, int(TESTING_INSTEON_GROUP_NUM_0)) self.assertEqual(conversions.int2dotted_hex(l_insteon.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def test_04_Family(self): """Read and add the family specific parts. """ l_xml = self.m_xml.thermostat l_obj = Utility._read_thermostat_base(l_xml) Utility._read_thermostat_data(l_obj, l_xml) Utility._read_family_data(self.m_pyhouse_obj, l_obj, l_xml) self.assertEqual(conversions.int2dotted_hex(l_obj.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_0) self.assertEqual(conversions.int2dotted_hex(l_obj.DevCat, 2), TESTING_INSTEON_DEVCAT_0) self.assertEqual(l_obj.GroupList, TESTING_INSTEON_GROUP_LIST_0) self.assertEqual(l_obj.GroupNumber, int(TESTING_INSTEON_GROUP_NUM_0)) self.assertEqual(conversions.int2dotted_hex(l_obj.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def test_05_OneThermostat(self): """Read one thermostat entirely. """ l_obj = Utility._read_one_thermostat_xml(self.m_pyhouse_obj, self.m_xml.thermostat) self.assertEqual(l_obj.Name, TESTING_THERMOSTAT_NAME_0) self.assertEqual(l_obj.CoolSetPoint, float(TESTING_THERMOSTAT_COOL_SETPOINT_0)) self.assertEqual(conversions.int2dotted_hex(l_obj.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_0)
def test_01_GetObj(self): """ """ # print(PrettyFormatAny.form(self.m_pyhouse_obj.House.Lighting.Lights[0], 'E1-01-A - Lighting')) l_addr = INSTEON_0_MSG l_ret = utilDecode.get_obj_from_message(self.m_pyhouse_obj, l_addr) l_dotted = conversions.int2dotted_hex(l_ret.InsteonAddress, 3) # print(PrettyFormatAny.form(l_ret, 'E1-01-B - Lighting')) self.assertEqual(l_dotted, TESTING_INSTEON_ADDRESS_0)
def test_05_OneThermostat(self): """Read one thermostat entirely. """ l_obj = Utility._read_one_thermostat_xml(self.m_pyhouse_obj, self.m_xml.thermostat) self.assertEqual(l_obj.Name, TESTING_THERMOSTAT_NAME_0) self.assertEqual(l_obj.CoolSetPoint, float(TESTING_THERMOSTAT_COOL_SETPOINT_0)) self.assertEqual(conversions.int2dotted_hex(l_obj.InsteonAddress, 3), TESTING_INSTEON_ADDRESS_0)
def test_06_All(self): """ Did we get everything set up for the rest of the tests of this class. """ l_xml = self.m_xml.light l_device = self.m_device_obj # l_light = LightingCoreAPI.read_core_lighting_xml(l_device, l_xml, self.m_version) FamUtil.read_family_data(self.m_pyhouse_obj, l_light, l_xml) self.assertEqual(l_light.Name, TESTING_LIGHTING_LIGHTS_NAME_1) self.assertEqual(l_light.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON) self.assertEqual(l_light.InsteonAddress, conversions.dotted_hex2int(TESTING_INSTEON_ADDRESS_0)) self.assertEqual(l_light.DevCat, conversions.dotted_hex2int(TESTING_INSTEON_DEVCAT_0)) self.assertEqual(conversions.int2dotted_hex(l_light.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def test_05_All(self): """ Did we get everything set up for the rest of the tests of this class. """ l_xml = self.m_xml.light l_device = self.m_device_obj # l_light = deviceXML.read_base_device_object_xml(self.m_pyhouse_obj, l_device, l_xml) FamUtil.read_family_data(self.m_pyhouse_obj, l_light, l_xml) # print(PrettyFormatAny.form(l_light, 'C4-05-A - Light')) self.assertEqual(l_light.Name, TESTING_LIGHT_NAME_0) self.assertEqual(l_light.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON) self.assertEqual(l_light.InsteonAddress, conversions.dotted_hex2int(TESTING_INSTEON_ADDRESS_0)) self.assertEqual(l_light.DevCat, conversions.dotted_hex2int(TESTING_INSTEON_DEVCAT_0)) self.assertEqual(conversions.int2dotted_hex(l_light.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def test_05_All(self): """ Did we get everything set up for the rest of the tests of this class. """ l_xml = self.m_xml.light l_device = self.m_device_obj # l_light = LightingCoreAPI.read_core_lighting_xml( self.m_pyhouse_obj, l_device, l_xml) FamUtil.read_family_data(self.m_pyhouse_obj, l_light, l_xml) print(PrettyFormatAny.form(l_light, 'Light')) self.assertEqual(l_light.Name, TESTING_LIGHT_NAME_0) self.assertEqual(l_light.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON) self.assertEqual(l_light.InsteonAddress, conversions.dotted_hex2int(TESTING_INSTEON_ADDRESS_0)) self.assertEqual(l_light.DevCat, conversions.dotted_hex2int(TESTING_INSTEON_DEVCAT_0)) self.assertEqual(conversions.int2dotted_hex(l_light.ProductKey, 3), TESTING_INSTEON_PRODUCT_KEY_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
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
def test_01_A1B2C3(self): l_int = 10597059 l_hex = conversions.int2dotted_hex(l_int, 3) print('C2-01-A - ', l_int, l_hex) self.assertEqual(l_hex, 'A1.B2.C3')
def test_01_ProductKey(self): l_product_key = insteonXml._read_product_key(self.m_xml.light) self.assertEqual(conversions.int2dotted_hex(l_product_key, 3), TESTING_INSTEON_PRODUCT_KEY_0)
def test_01_ProductKey(self): l_product_key = insteonXml._read_product_key(self.m_xml.light) self.assertEqual(conversions.int2dotted_hex(l_product_key, 3), TESTING_INSTEON_PRODUCT_KEY_0)