Esempio n. 1
0
 def saveControllerInformation(self, p_json):
     """A new/changed controller is returned.  Process it and update the internal data via controller.py
     """
     l_json = json_tools.decode_json_unicode(p_json)
     l_ix = int(l_json['Key'])
     l_delete = l_json['Delete']
     if l_delete:
         try:
             del self.m_pyhouse_obj.House.Lighting.Controllers[l_ix]
         except AttributeError:
             LOG.error(
                 "web_controllers - Failed to delete - JSON: {}".FORMAT(
                     l_json))
         return
     l_obj = ControllerInformation()
     try:
         l_obj = self.m_pyhouse_obj.House.Lighting.Controllers[l_ix]
     except KeyError:
         LOG.warning('Creating a new controller {}'.format(l_ix))
     web_utils.get_base_info(l_obj, l_json)
     l_obj.Comment = l_json['Comment']
     l_obj.DeviceFamily = l_json['DeviceFamily']
     l_obj.DeviceType = 1
     l_obj.DeviceSubType = 2
     l_obj.InterfaceType = l_json['InterfaceType']
     l_obj.Port = l_json['Port']
     if l_obj.InterfaceType == 'Serial':
         l_obj.BaudRate = l_json['BaudRate']
     web_family.get_family_json_data(l_obj, l_json)
     web_utils.get_room_info(l_obj, l_json)
     self.m_pyhouse_obj.House.Lighting.Controllers[l_ix] = l_obj
     LOG.info('Controller Added - {}'.format(l_obj.Name))
Esempio n. 2
0
 def test_02_Write(self):
     l_list = list(self.m_xml.controller_sect.iterfind('Controller'))
     l_xml = l_list[1]
     l_dev = ControllerInformation()
     upbXML.ReadXml(l_dev, l_xml)
     l_out = ET.Element('Testing')
     upbXML.WriteXml(l_out, l_dev)
Esempio n. 3
0
 def setUp(self, p_root):
     self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root)
     self.m_xml = SetupPyHouseObj().BuildXml(p_root)
     self.m_api = deviceXML
     self.m_button_obj = ButtonData()
     self.m_controller_obj = ControllerInformation()
     self.m_light_obj = LightData()
Esempio n. 4
0
 def test_01_Read(self):
     l_list = list(self.m_xml.controller_sect.iterfind('Controller'))
     l_xml = l_list[1]
     l_dev = ControllerInformation()
     upbXML.ReadXml(l_dev, l_xml)
     self.assertEqual(l_dev.UPBAddress, int(TESTING_UPB_ADDRESS))
     self.assertEqual(l_dev.UPBNetworkID, int(TESTING_UPB_NETWORK))
     self.assertEqual(l_dev.UPBPassword, int(TESTING_UPB_PASSWORD))
Esempio n. 5
0
 def test_01_Interface(self):
     l_xml = self.m_xml.controller_sect[1]
     # print(PrettyFormatAny.form(l_xml, 'B1-01-A - L L'))
     l_device = ControllerInformation()
     l_obj = self.m_api.read_base_device_object_xml(l_device, l_xml)
     # print(PrettyFormatAny.form(l_obj, 'B1-01-B - L L'))
     l_interface = usbXML.read_interface_xml(l_xml)
     # print(PrettyFormatAny.form(l_interface, 'B1-01-C - L L'))
     stuff_new_attrs(l_obj, l_interface)
     # print(PrettyFormatAny.form(l_obj, 'B1-01-D - L L'))
     self.assertEqual(l_obj.Vendor, int(TESTING_USB_VENDOR))
     self.assertEqual(l_obj.Product, int(TESTING_USB_PRODUCT))
Esempio n. 6
0
 def test_02_BaseController(self):
     """ Read in the xml file and fill in the lights
     """
     l_obj = ControllerInformation()
     l_base = self.m_api.read_base_device_object_xml(
         l_obj, self.m_xml.controller)
     self.assertEqual(str(l_base.Name), TESTING_CONTROLLER_NAME_0)
     self.assertEqual(str(l_base.Key), TESTING_CONTROLLER_KEY_0)
     self.assertEqual(str(l_base.Active), TESTING_CONTROLLER_ACTIVE_0)
     self.assertEqual(l_base.Comment, TESTING_DEVICE_COMMENT_0)
     self.assertEqual(l_base.RoomCoords.X_Easting,
                      float(TESTING_DEVICE_ROOM_X))
     self.assertEqual(l_base.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON)
     self.assertEqual(l_base.RoomName, TESTING_DEVICE_ROOM_NAME)
Esempio n. 7
0
 def test_01_Interface(self):
     l_xml = self.m_xml.controller_sect[1]
     # print(PrettyFormatAny.form(l_xml, 'B2-01-A - L L'))
     l_device = ControllerInformation()
     l_obj = self.m_api.read_base_device_object_xml(l_device, l_xml)
     # print(PrettyFormatAny.form(l_obj, 'B2-01-B - L L'))
     l_interface = usbXML.read_interface_xml(l_xml)
     # print(PrettyFormatAny.form(l_interface, 'B2-01-C - L L'))
     stuff_new_attrs(l_obj, l_interface)
     # print(PrettyFormatAny.form(l_obj, 'B2-01-D - Controller xml'))
     l_xml = self.m_api.write_base_device_object_xml('TestController', l_obj)
     l_xml.append(usbXML.write_interface_xml(l_obj))
     # print(PrettyFormatAny.form(l_xml, 'B2-01-E - 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('USB/Vendor').text, TESTING_USB_VENDOR)
     self.assertEqual(l_xml.find('USB/Product').text, TESTING_USB_PRODUCT)
Esempio n. 8
0
 def test_02_BaseController(self):
     """ Read in the xml file and fill in the lights
     """
     l_obj = ControllerInformation()
     l_base = self.m_api.read_base_device_object_xml(
         l_obj, self.m_xml.controller)
     l_xml = self.m_api.write_base_device_object_xml('Light', l_base)
     # print(PrettyFormatAny.form(l_xml, 'C1-02-A - Base'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_CONTROLLER_NAME_0)
     self.assertEqual(l_xml.attrib['Key'], TESTING_CONTROLLER_KEY_0)
     self.assertEqual(l_xml.attrib['Active'], TESTING_CONTROLLER_ACTIVE_0)
     self.assertEqual(l_xml.find('UUID').text, TESTING_CONTROLLER_UUID_0)
     self.assertEqual(l_xml.find('Comment').text, TESTING_DEVICE_COMMENT_0)
     self.assertEqual(
         l_xml.find('DeviceSubType').text, TESTING_DEVICE_SUBTYPE)
     self.assertEqual(l_xml.find('DeviceType').text, TESTING_DEVICE_TYPE)
     # self.assertEqual(l_xml.find('RoomCoords').text, TESTING_LIGHT_ROOM_COORDS_0)
     self.assertEqual(l_xml.find('RoomName').text, TESTING_DEVICE_ROOM_NAME)
     self.assertEqual(l_xml.find('RoomUUID').text, TESTING_DEVICE_ROOM_UUID)
Esempio n. 9
0
 def setUp(self):
     SetupMixin.setUp(self, ET.fromstring(XML_LONG))
     self.m_ctrlr = ControllerInformation()
     self.m_decode = Insteon_decoder.DecodeResponses(
         self.m_pyhouse_obj, self.m_ctrlr)
Esempio n. 10
0
 def setUp(self):
     SetupMixin.setUp(self, ET.fromstring(XML_LONG))
     self.m_ctrlr = ControllerInformation()
Esempio n. 11
0
 def setUp(self):
     self.m_controller_obj = ControllerInformation()
     self.m_controller_obj._Queue = Queue.Queue(300)
Esempio n. 12
0
 def setUp(self):
     self.m_api = DecodeResponses()
     self.m_controller_obj = ControllerInformation()
     self.m_controller_obj._Message = TEST_MESSAGE
Esempio n. 13
0
 def setUp(self, p_root):
     self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root)
     self.m_xml = SetupPyHouseObj().BuildXml(p_root)
     self.m_controller_obj = ControllerInformation()
     self.m_ctlr_api = controllerAPI()