Пример #1
0
 def _read_base_device(p_xml, p_version):
     """
     @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 Light data object with the base info filled in
     """
     l_obj = LightData()
     l_obj = LightingCoreAPI.read_core_lighting_xml(l_obj, p_xml, p_version)
     l_obj.DeviceType = 1
     l_obj.DeviceSubType = 2
     return l_obj
Пример #2
0
 def saveControlLightData(self, p_json):
     """A changed Light is returned.  Process it and update the light level
     """
     l_json = json_tools.decode_json_unicode(p_json)
     l_light_ix = int(l_json['Key'])
     l_light_obj = LightData()
     l_light_obj.Name = l_json['Name']
     l_light_obj.Key = l_light_ix
     l_light_obj.BrightnessPct = l_brightness = l_json['BrightnessPct']
     l_light_obj.UUID = l_json['UUID']
     LOG.info('Control Light via Web - Change {} device to Brightness {}'.format(l_light_obj.Name, l_light_obj.BrightnessPct))
     l_topic = 'lighting/web/{}/control'.format(l_light_obj.Name)
     self.m_pyhouse_obj.APIs.Computer.MqttAPI.MqttPublish(l_topic, l_light_obj)  # lighting/web/{}/control
     self.m_pyhouse_obj.APIs.House.LightingAPI.ChangeLight(l_light_obj, 'web', l_brightness)
Пример #3
0
 def setUp(self, p_root):
     self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root)
     self.m_xml = SetupPyHouseObj().BuildXml(p_root)
     self.m_family = familyAPI(self.m_pyhouse_obj).LoadFamilyTesting()
     self.m_pyhouse_obj.House.FamilyData = self.m_family
     self.m_light_obj = LightData()
     self.m_version = '1.4.0'
Пример #4
0
 def setUp(self, p_root):
     self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root)
     self.m_xml = SetupPyHouseObj().BuildXml(p_root)
     self.m_button_obj = ButtonData()
     self.m_controller_obj = ControllerData()
     self.m_light_obj = LightData()
     self.m_api = LightingCoreAPI()
Пример #5
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()
Пример #6
0
 def test_01_BaseLight(self):
     """ Read in the xml file and fill in the device info
     """
     l_obj = LightData()
     l_base = self.m_api.read_base_device_object_xml(
         l_obj, self.m_xml.light)
     # print(PrettyFormatAny.form(l_base, 'B1-01-A - Base'))
     # print(PrettyFormatAny.form(l_base.RoomCoords, 'B1-01-B - Base Coords'))
     self.assertEqual(l_base.Name, TESTING_LIGHT_NAME_0)
     self.assertEqual(l_base.Key, int(TESTING_LIGHT_KEY_0))
     self.assertEqual(l_base.Active, bool(TESTING_LIGHT_ACTIVE_0))
     self.assertEqual(l_base.UUID, TESTING_LIGHT_UUID_0)
     self.assertEqual(l_base.Comment, TESTING_LIGHT_COMMENT_0)
     self.assertEqual(l_base.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON)
     self.assertEqual(l_base.DeviceSubType,
                      int(TESTING_LIGHT_DEVICE_SUBTYPE_0))
     self.assertEqual(l_base.DeviceType, int(TESTING_LIGHT_DEVICE_TYPE_0))
     self.assertEqual(str(l_base.RoomCoords.X_Easting),
                      TESTING_LIGHT_ROOM_X0)
     self.assertEqual(str(l_base.RoomCoords.Y_Northing),
                      TESTING_LIGHT_ROOM_Y0)
     self.assertEqual(str(l_base.RoomCoords.Z_Height),
                      TESTING_LIGHT_ROOM_Z0)
     self.assertEqual(l_base.RoomName, TESTING_LIGHT_ROOM_NAME_0)
     self.assertEqual(l_base.RoomUUID, TESTING_LIGHT_ROOM_UUID_0)
Пример #7
0
 def _read_base_device(p_pyhouse_obj, p_xml):
     """
     @param p_xml: is the XML Element for the entire device
     @return: a Light data object with the base info filled in
     """
     l_obj = LightData()
     l_obj = LightingCoreAPI.read_core_lighting_xml(p_pyhouse_obj, l_obj, p_xml)
     return l_obj
Пример #8
0
 def saveControlLightData(self, p_json):
     """A changed Light is returned.  Process it and update the light level
     """
     l_json = json_tools.decode_json_unicode(p_json)
     l_light_ix = int(l_json['Key'])
     l_light_obj = LightData()
     l_light_obj.Name = l_json['Name']
     l_light_obj.Key = l_light_ix
     l_light_obj.BrightnessPct = l_brightness = l_json['BrightnessPct']
     l_light_obj.UUID = l_json['UUID']
     LOG.info(
         'Control Light via Web - Change {} device to Brightness {}'.format(
             l_light_obj.Name, l_light_obj.BrightnessPct))
     l_topic = 'house/lighting/web/{}/control'.format(l_light_obj.Name)
     self.m_pyhouse_obj._APIs.Core.MqttAPI.MqttPublish(
         l_topic, l_light_obj)  # lighting/web/{}/control
     self.m_pyhouse_obj._APIs.House.LightingAPI.AbstractControlLight(
         l_light_obj, 'web', l_brightness)
Пример #9
0
 def _read_one_light_xml(p_pyhouse_obj, p_xml):
     """
     Load all the xml for one controller.
     Base Device, Light, Family
     """
     try:
         l_obj = Utility._read_base_device(p_pyhouse_obj, p_xml)
         Utility._read_light_data(p_pyhouse_obj, l_obj, p_xml)
         Utility._read_family_data(p_pyhouse_obj, l_obj, p_xml)
     except Exception as e_err:
         LOG.error('ERROR - ReadOneController - {0:}'.format(e_err))
         l_obj = LightData()
     return l_obj
Пример #10
0
 def setUp(self, p_root):
     self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root)
     self.m_pyhouse_obj.House.FamilyData = familyAPI(
         self.m_pyhouse_obj).m_family
     self.m_xml = SetupPyHouseObj().BuildXml(p_root)
     self.m_device_obj = LightData()
     self.m_device_obj.Name = TESTING_LIGHT_NAME_0
     self.m_device_obj.Key = TESTING_LIGHT_KEY_0
     self.m_device_obj.Active = TESTING_LIGHT_ACTIVE_0
     self.m_device_obj.Comment = TESTING_DEVICE_COMMENT
     self.m_device_obj.CurLevel = TESTING_LIGHT_CUR_LEVEL_0
     self.m_device_obj.DeviceFamily = TESTING_LIGHT_FAMILY_0
     self.m_device_obj.DeviceType = 1
     self.m_device_obj.DeviceSubType = 234
     self.m_device_obj.RoomCoords = TESTING_DEVICE_ROOM_COORDS
     self.m_device_obj.RoomName = TESTING_DEVICE_ROOM_NAME
     self.m_version = '1.4.0'
Пример #11
0
 def test_1_Base(self):
     """ Read in the xml file and fill in the lights
     """
     l_xml = self.m_xml.light
     l_obj = LightData()
     l_obj = self.m_api._read_base(self.m_pyhouse_obj, l_obj, l_xml)
     # print(PrettyFormatAny.form(l_obj, 'Base'))
     self.assertEqual(l_obj.Name, TESTING_LIGHT_NAME_0)
     self.assertEqual(str(l_obj.Key), TESTING_LIGHT_KEY_0)
     self.assertEqual(str(l_obj.Active), TESTING_LIGHT_ACTIVE_0)
     self.assertEqual(l_obj.UUID, TESTING_LIGHT_UUID_0)
     self.assertEqual(l_obj.Comment, TESTING_LIGHT_COMMENT_0)
     self.assertEqual(l_obj.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON)
     self.assertEqual(str(l_obj.DeviceType), TESTING_LIGHT_DEVICE_TYPE_0)
     self.assertEqual(l_obj.DeviceSubType,
                      int(TESTING_LIGHT_DEVICE_SUBTYPE_0))
     self.assertEqual(l_obj.RoomCoords.X_Easting,
                      float(TESTING_LIGHT_ROOM_X))
     self.assertEqual(l_obj.RoomName, TESTING_LIGHT_ROOM_NAME_0)
     self.assertEqual(l_obj.RoomUUID, TESTING_LIGHT_ROOM_UUID_0)
Пример #12
0
 def saveControlLightData(self, p_json):
     """A changed Light is returned.  Process it and update the light level
     """
     l_json = JsonUnicode().decode_json(p_json)
     l_light_ix = int(l_json['Key'])
     l_light_obj = LightData()
     l_light_obj.Name = l_json['Name']
     l_light_obj.Key = l_light_ix
     l_light_obj.CurLevel = l_level = l_json['Level']
     l_light_obj.LightingType = 'Light'
     l_light_obj.UUID = l_json['UUID']
     LOG.info('Control Light via Web - Change {} device to level {}'.format(l_light_obj.Name, l_light_obj.CurLevel))
     l_topic = 'lighting/web/{}/control'.format(l_light_obj.Name)
     self.m_pyhouse_obj.APIs.Computer.MqttAPI.MqttPublish(l_topic, l_light_obj)  # lighting/web/{}/control
     self.m_pyhouse_obj.APIs.House.LightingAPI.ChangeLight(l_light_obj, 'web', l_level)
Пример #13
0
 def test_01_BaseLight(self):
     """ Read in the xml file and fill in the lights
     """
     l_obj = LightData()
     l_base = self.m_api.read_base_device_object_xml(
         l_obj, self.m_xml.light)
     l_xml = self.m_api.write_base_device_object_xml('Light', l_base)
     # print(PrettyFormatAny.form(l_xml, 'C1-01-A - Base'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_LIGHT_NAME_0)
     self.assertEqual(l_xml.attrib['Key'], TESTING_LIGHT_KEY_0)
     self.assertEqual(l_xml.attrib['Active'], TESTING_LIGHT_ACTIVE_0)
     self.assertEqual(l_xml.find('UUID').text, TESTING_LIGHT_UUID_0)
     self.assertEqual(l_xml.find('Comment').text, TESTING_LIGHT_COMMENT_0)
     self.assertEqual(
         l_xml.find('DeviceSubType').text, TESTING_LIGHT_DEVICE_SUBTYPE_0)
     self.assertEqual(
         l_xml.find('DeviceType').text, TESTING_LIGHT_DEVICE_TYPE_0)
     self.assertEqual(
         l_xml.find('RoomCoords').text, TESTING_LIGHT_ROOM_COORDS_0)
     self.assertEqual(
         l_xml.find('RoomName').text, TESTING_LIGHT_ROOM_NAME_0)
     self.assertEqual(
         l_xml.find('RoomUUID').text, TESTING_LIGHT_ROOM_UUID_0)
Пример #14
0
 def setUp(self, p_root):
     self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root)
     self.m_xml = SetupPyHouseObj().BuildXml(p_root)
     self.m_core_api = lightingCoreAPI()
     self.m_device = LightData()
     self.m_version = '1.4.0'