Пример #1
0
 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))
Пример #2
0
 def test_04_MessageObj(self):
     """ Add an object.
     """
     l_data = ControllerData()
     l_data.Name = 'Mqtt Schedule Object'
     l_data.LightName = 'Test Light'
     l_data.RoomName = 'Living Room'
     l_data.Comment = 'The formal Living Room.'
     l_message = _make_message(self.m_pyhouse_obj, l_data)
     # print(PrettyFormatAny.form(l_message, 'C2-04-A - Message', 80))
     self.assertEqual(self.jsonPair(l_message, 'Sender'), self.m_pyhouse_obj.Computer.Name)
     self.assertSubstring('DateTime', l_message)
     self.assertEqual(self.jsonPair(l_message, 'Name'), l_data.Name)
Пример #3
0
 def test_04_MessageObj(self):
     """ Add an object.
     """
     l_data = ControllerData()
     l_data.Name = 'Mqtt Schedule Object'
     l_data.LightName = 'Test Light'
     l_data.RoomName = 'Living Room'
     l_data.Comment = 'The formal Living Room.'
     l_message = Util._make_message(self.m_pyhouse_obj, l_data)
     #  print(PrettyFormatAny.form(l_message, 'Message', 80))
     self.assertEqual(self.jsonPair(l_message, 'Sender'),
                      self.m_pyhouse_obj.Computer.Name)
     self.assertSubstring('DateTime', l_message)
     self.assertEqual(self.jsonPair(l_message, 'Name'), l_data.Name)
Пример #4
0
 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_controller_ix = int(l_json['Key'])
     l_delete = l_json['Delete']
     if l_delete:
         try:
             del self.m_pyhouse_obj.House.Lighting.Controllers[l_controller_ix]
         except AttributeError:
             print("web_controllers - Failed to delete - JSON: {0:}".FORMAT(l_json))
         return
     try:
         l_obj = self.m_pyhouse_obj.House.Lighting.Controllers[l_controller_ix]
     except KeyError:
         l_obj = ControllerData()
     l_obj.Name = l_json['Name']
     l_obj.Active = l_json['Active']
     l_obj.Key = l_controller_ix
     l_obj.Comment = l_json['Comment']
     l_obj.RoomCoords = l_json['RoomCoords']
     l_obj.IsDimmable = l_json['IsDimmable']
     l_obj.DeviceFamily = l_json['DeviceFamily']
     l_obj.RoomName = l_json['RoomName']
     l_obj.LightingType = l_json['LightingType']
     l_obj.UUID = l_json['UUID']
     l_obj.InterfaceType = l_json['InterfaceType']
     l_obj.Port = l_json['Port']
     if l_obj.DeviceFamily == 'Insteon':
         Insteon_utils.Util().get_json_data(l_obj, l_json)
     elif l_obj.DeviceFamily == 'UPB':
         l_obj.UPBAddress = l_json['UPBAddress']
         l_obj.UPBPassword = l_json['UPBPassword']
         l_obj.UPBNetworkID = l_json['UPBNetworkID']
     if l_obj.InterfaceType == 'Serial':
         l_obj.BaudRate = l_json['BaudRate']
     self.m_pyhouse_obj.House.Lighting.Controllers[l_controller_ix] = l_obj
     LOG.info('Controller Added - {}'.format(l_obj))
Пример #5
0
 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_controller_ix = int(l_json['Key'])
     l_delete = l_json['Delete']
     if l_delete:
         try:
             del self.m_pyhouse_obj.House.Lighting.Controllers[l_controller_ix]
         except AttributeError:
             LOG.error("web_controllers - Failed to delete - JSON: {}".FORMAT(l_json))
         return
     try:
         l_obj = self.m_pyhouse_obj.House.Lighting.Controllers[l_controller_ix]
     except KeyError:
         l_obj = ControllerData()
     l_obj.Name = l_json['Name']
     l_obj.Active = l_json['Active']
     l_obj.Key = l_controller_ix
     l_obj.Comment = l_json['Comment']
     l_obj.RoomCoords = l_json['RoomCoords']
     l_obj.IsDimmable = l_json['IsDimmable']
     l_obj.DeviceFamily = l_json['DeviceFamily']
     l_obj.RoomName = l_json['RoomName']
     l_obj.LightingType = l_json['LightingType']
     l_obj.UUID = l_json['UUID']
     l_obj.InterfaceType = l_json['InterfaceType']
     l_obj.Port = l_json['Port']
     if l_obj.DeviceFamily == 'Insteon':
         Insteon_utils.Util().get_json_data(l_obj, l_json)
     elif l_obj.DeviceFamily == 'UPB':
         l_obj.UPBAddress = l_json['UPBAddress']
         l_obj.UPBPassword = l_json['UPBPassword']
         l_obj.UPBNetworkID = l_json['UPBNetworkID']
     if l_obj.InterfaceType == 'Serial':
         l_obj.BaudRate = l_json['BaudRate']
     self.m_pyhouse_obj.House.Lighting.Controllers[l_controller_ix] = l_obj
     LOG.info('Controller Added - {}'.format(l_obj))