def saveControllerData(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 = ControllerData() 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))
def _read_base_device(p_pyhouse_obj, p_xml): """ @param p_xml: is the XML Element for the entire device @param p_version: is some helper data to get the correct information from the config file. @return: a Controller data object with the base info filled in """ l_obj = ControllerData() # Create an empty controller object. l_obj = deviceXML.read_base_device_object_xml(p_pyhouse_obj, l_obj, p_xml) l_obj.DeviceType = 1 l_obj.DeviceSubType = 2 return l_obj