Esempio n. 1
0
 def decode(self, p_topic, p_message):
     """ Decode the computer specific portions of the message and append them to the log string.
     @param p-logmsg: is the partially decoded Mqtt message json
     @param p_topic: is a list of topic part strings ( pyhouse, housename have been dropped
     @param p_message: is the payload that is JSON
     """
     l_logmsg = '\tComputer:\n'
     #  computer/browser/***
     if p_topic[1] == 'browser':
         _l_name = 'unknown'
         l_logmsg += '\tBrowser: Message {}'.format(PrettyFormatAny.form(p_message, 'Computer msg', 160))
     #  computer/ip
     elif p_topic[1] == 'ip':
         l_ip = self._get_field(p_message, 'ExternalIPv4Address')
         l_logmsg += '\tIPv4: {}'.format(l_ip)
     #  computer/startup
     elif p_topic[1] == 'startup':
         self._extract_node(p_message)
         l_logmsg += '\tStartup {}'.format(PrettyFormatAny.form(p_message, 'Computer msg', 160))
         if self.m_myname == self.m_sender:
             l_logmsg += '\tMy own startup of PyHouse\n'
         else:
             l_logmsg += '\tAnother computer started up: {}'.format(self.m_sender)
     #  computer/shutdown
     elif p_topic[1] == 'shutdown':
         del self.m_pyhouse_obj.Computer.Nodes[self.m_name]
         l_logmsg += '\tSelf Shutdown {}'.format(PrettyFormatAny.form(p_message, 'Computer msg', 160))
     #  computer/node/???
     elif p_topic[1] == 'node':
         l_logmsg += syncAPI(self.m_pyhouse_obj).DecodeMqttMessage(p_topic, p_message)
     #  computer/***
     else:
         l_logmsg += '\tUnknown sub-topic {}'.format(PrettyFormatAny.form(p_message, 'Computer msg', 160))
     return l_logmsg
Esempio n. 2
0
 def test_02_Decode(self):
     # l_json = json_tools.encode_json(self.m_pyhouse_obj.Computer)
     l_json = json_tools.encode_json(MSG_DICT)
     print(PrettyFormatAny.form(l_json, 'A1-02-A - Encoded Info'))
     l_dict = json_tools.decode_json_unicode(l_json)
     print(l_dict)
     print(PrettyFormatAny.form(l_dict, 'A1-02-B - Decoded Info'))
Esempio n. 3
0
 def test_01_All(self):
     """ Be sure that the XML contains the right stuff.
     """
     l_controllers = self.m_ctlr_api.read_all_controllers_xml(self.m_pyhouse_obj)
     self.m_pyhouse_obj.House.Lighting.Controllers = l_controllers
     print(PrettyFormatAny.form(l_controllers[0], 'R1-01-A - Controller Obj'))
     print(PrettyFormatAny.form(self.m_xml.controller, 'R1-01-B - Controller Xml'))
     interfaceXml.read_interface_xml(l_controllers[0], self.m_xml.controller)
     print(PrettyFormatAny.form(l_controllers[0], 'R1-01-C - Controller Obj'))
Esempio n. 4
0
 def test_01_Family(self):
     """ Did we get everything set up for the rest of the tests of this class.
     """
     l_xml = self.m_xml.light_sect[0]
     print(PrettyFormatAny.form(l_xml, 'C3-01-A - XML'))
     l_device = self.m_device_obj
     l_light = FamUtil.read_family_data(self.m_pyhouse_obj, l_device, l_xml)
     print(PrettyFormatAny.form(l_light, 'C3-01-B - Light'))
     self.assertEqual(l_device.Name, TESTING_LIGHT_NAME_0)
     self.assertEqual(l_light.InsteonAddress, conversions.dotted_hex2int(TESTING_INSTEON_ADDRESS_0))
Esempio n. 5
0
 def test_02_Light(self):
     """ Did we get everything set up for the rest of the tests of this class.
     """
     l_xml = self.m_xml.light_sect[1]
     print(PrettyFormatAny.form(l_xml, 'C3-02-A - XML'))
     l_device = self.m_device_obj
     l_light = deviceXML.read_base_device_object_xml(self.m_pyhouse_obj, l_device, l_xml)
     print(PrettyFormatAny.form(l_light, 'C3-02-B - Light'))
     self.assertEqual(l_light.Name, TESTING_LIGHT_NAME_1)
     self.assertEqual(l_device.RoomName, TESTING_LIGHT_ROOM_NAME_1)
     self.assertEqual(l_light.UPBAddress, conversions.dotted_hex2int(TESTING_INSTEON_ADDRESS_0))
Esempio n. 6
0
 def test_04_All(self):
     """ test reading of entire device set.
     """
     l_obj = panasonicXML.read_panasonic_section_xml(self.m_pyhouse_obj)
     print(PrettyFormatAny.form(l_obj, 'C1-04-A - Plugins.'))
     print(PrettyFormatAny.form(l_obj.Devices, 'C1-04-B - Devices'))
     print(PrettyFormatAny.form(l_obj.Devices[0], 'C1-04-C - Device 0'))
     self.assertEqual(l_obj.Active, True)
     self.assertEqual(l_obj.Count, 2)
     self.assertEqual(str(l_obj.Devices[0].Name), TESTING_PANASONIC_DEVICE_NAME_0)
     self.assertEqual(str(l_obj.Devices[1].Name), TESTING_PANASONIC_DEVICE_NAME_1)
Esempio n. 7
0
 def test_05_Data(self):
     """ test that the data structure is correct.
     """
     l_obj = panasonicXML.read_panasonic_section_xml(self.m_pyhouse_obj)
     print(PrettyFormatAny.form(l_obj, 'C1-05-A - Read'))
     l_base = self.m_pyhouse_obj.House.Entertainment
     print(PrettyFormatAny.form(l_base, 'C1-05-B1 - Base'))
     print(PrettyFormatAny.form(l_base.Plugins, 'C1-05-B2 - Plugins'))
     print(PrettyFormatAny.form(l_base.Plugins[SECTION], 'C1-05-B2 - Plugins[SECTION]'))
     self.assertEqual(l_obj.Type, TESTING_PANASONIC_TYPE)
     self.assertEqual(l_base.Plugins[SECTION].Name, SECTION)
     self.assertEqual(l_base.Plugins[SECTION].Devices[0].Name, TESTING_PANASONIC_DEVICE_NAME_0)
     self.assertEqual(l_base.Plugins[SECTION].Devices[1].Name, TESTING_PANASONIC_DEVICE_NAME_1)
Esempio n. 8
0
 def test_04_Add(self):
     l_obj_0 = UuidData()
     l_obj_0.UUID = '12345678-dead-beef-dead-fedcba987654'
     l_obj_0.UuidType = 'House'
     Uuid.add_uuid(self.m_pyhouse_obj, l_obj_0)
     print(PrettyFormatAny.form(self.m_pyhouse_obj.Uuids, 'B2-04-A - one'))
     self.assertEqual(self.m_pyhouse_obj.Uuids.All[l_obj_0.UUID].UuidType, l_obj_0.UuidType)
     #
     l_obj_1 = UuidData()
     l_obj_1.UUID = '01234567-dead-beef-dead-fedcba987654'
     l_obj_1.UuidType = 'Room'
     Uuid.add_uuid(self.m_pyhouse_obj, l_obj_1)
     print(PrettyFormatAny.form(self.m_pyhouse_obj.Uuids.All, 'B2-04-B - two'))
     self.assertEqual(self.m_pyhouse_obj.Uuids.All[l_obj_1.UUID].UuidType, l_obj_1.UuidType)
Esempio n. 9
0
 def test_02_Xml1(self):
     """ Did we get the XML correctly
     """
     l_xml = self.m_xml.light_sect[1]
     print(PrettyFormatAny.form(l_xml, 'C1-02-A - XML'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_LIGHT_NAME_1)
     self.assertEqual(l_xml.find('DeviceFamily').text, TESTING_DEVICE_FAMILY_UPB)
Esempio n. 10
0
 def test_03_AllDevices(self):
     """ Write the entire PandoraSection XML
     """
     l_xml = pandoraXml.write_pandora_section_xml(self.m_pyhouse_obj)
     print(PrettyFormatAny.form(l_xml, 'D1-03-A - All Devices'))
     self.assertEqual(l_xml.attrib['Active'], TESTING_PANDORA_ACTIVE)
     self.assertEqual(l_xml.find('Type').text, TESTING_PANDORA_DEVICE_TYPE_0)
Esempio n. 11
0
 def _save_light(self, p_obj, p_json):
     LOG.info(PrettyFormatAny.form(p_json, 'JSON'))
     p_obj.Level = int(p_json['Level'])
     p_obj.LightName = p_json['LightName']
     p_obj.Rate = p_json['Rate']
     p_obj.RoomName = p_json['RoomName']
     return p_obj
Esempio n. 12
0
 def test_01_House(self):
     l_house_obj = houseXml.read_house_xml(self.m_pyhouse_obj)
     self.m_pyhouse_obj.House = l_house_obj
     l_xml = houseXml.write_house_xml(self.m_pyhouse_obj)
     print(PrettyFormatAny.form(l_xml, 'C3-01-A - XML'))
     self.assertEqual(l_xml.tag, 'HouseDivision')
     self.assertEqual(l_xml.attrib['Name'], TESTING_HOUSE_NAME)
     self.assertEqual(l_xml.find('UUID').text, TESTING_HOUSE_UUID)
Esempio n. 13
0
 def test_01_Init(self):
     """ Test that the data structure is correct.
     """
     self.m_pyhouse_obj.House.Entertainment.Plugins[SECTION] = EntertainmentPluginData()
     print(PrettyFormatAny.form(self.m_pyhouse_obj.House.Entertainment.Plugins[SECTION], 'E1-01-D - Section', 180))
     l_base = self.m_pyhouse_obj.House.Entertainment.Plugins[SECTION]
     self.assertIsNone(l_base._API)
     self.assertEqual(l_base.Active, False)
     self.assertEqual(l_base.Count, 0)
Esempio n. 14
0
 def test_01_Data(self):
     """ test that the data structure is correct.
     """
     l_base = self.m_pyhouse_obj.House.Entertainment.Plugins[SECTION]
     print(PrettyFormatAny.form(l_base, 'C1-05-B1 - Base'))
     self.assertEqual(l_base.Type, TESTING_PANASONIC_TYPE)
     self.assertEqual(l_base.Name, SECTION)
     self.assertEqual(l_base.Devices[0].Name, TESTING_PANASONIC_DEVICE_NAME_0)
     self.assertEqual(l_base.Devices[1].Name, TESTING_PANASONIC_DEVICE_NAME_1)
Esempio n. 15
0
 def _open_find_device(p_USB_obj):
     """First step in opening a USB device.
     @return:  None if no such device or a pyusb device object
     """
     l_vpn = Utility.format_names(p_USB_obj)
     l_device = None
     try:
         l_device = usb.core.find(idVendor=p_USB_obj.Vendor, idProduct=p_USB_obj.Product)
     except (usb.USBError, ValueError):
         LOG.error("ERROR no such USB device for {}".format(l_vpn))
         return None
     if l_device == None:
         LOG.error('ERROR - USB device not found  {}'.format(l_vpn))
         return None
     LOG.debug(PrettyFormatAny.form(l_device, 'Device'))
     LOG.debug(PrettyFormatAny.form(p_USB_obj, 'pUSB_obj'))
     p_USB_obj.UsbDevice = API._save_find_device(p_USB_obj, l_device)
     LOG.info('Found a device - HID: {}'.format(l_vpn))
     return l_device
Esempio n. 16
0
 def test_03_Pool1(self):
     """ Write one entire pool XML
     """
     l_xml = poolXml._write_one_pool(self.m_pools[1])
     print(PrettyFormatAny.form(l_xml, 'W1-03-A - Pool 1'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_POOL_NAME_1)
     self.assertEqual(l_xml.attrib['Key'], TESTING_POOL_KEY_1)
     self.assertEqual(l_xml.attrib['Active'], TESTING_POOL_ACTIVE_1)
     self.assertEqual(l_xml.find('Comment').text, TESTING_POOL_COMMENT_1)
     self.assertEqual(l_xml.find('PoolType').text, TESTING_POOL_TYPE_1)
Esempio n. 17
0
 def test_02_Line(self):
     """ Test that the data structure is correct.
     """
     l_obj = PandoraStatusData()
     l_res = PianoBarProcessControl(self.m_pyhouse_obj)._extract_nowplaying(l_obj, PLAY_LN)
     print(PrettyFormatAny.form(l_obj, 'F2-02-A - Status', 180))
     self.assertEqual(l_res.Album, 'Greatest Hits')
     self.assertEqual(l_res.Artist, 'Dave Koz')
     self.assertEqual(l_res.Likability, '3')
     self.assertEqual(l_res.Song, 'Love Is On The Way')
     self.assertEqual(l_res.Station, 'Smooth Jazz Radio')
Esempio n. 18
0
 def decode(self, p_topic, p_message):
     """ Decode the Mqtt message
     ==> pyhouse/<house name>/hvac/<type>/<Name>/...
     <type> = thermostat, ...
     """
     l_logmsg = '\tHVAC:\n'
     if p_topic[1] == 'Thermostat':
         l_logmsg += '\tThermostat: {}\n'.format(self._get_field(p_message, 'Name'))
     else:
         l_logmsg += '\tUnknown sub-topic {}'.format(PrettyFormatAny.form(p_message, 'Security msg', 160))
     return l_logmsg
Esempio n. 19
0
 def test_04_AllPools(self):
     """ Write Pool Section with all pools.
     """
     l_xml, l_count = poolXml.write_all_pools_xml(self.m_pyhouse_obj)
     print(PrettyFormatAny.form(l_xml, 'W1-04-A - Pool'))
     # l_xml1 = l_xml.find('Pool')
     l_xml2 = l_xml[0]
     self.assertEqual(l_xml2.attrib['Name'], TESTING_POOL_NAME_0)
     self.assertEqual(l_xml2.attrib['Key'], TESTING_POOL_KEY_0)
     self.assertEqual(l_xml2.attrib['Active'], TESTING_POOL_ACTIVE_0)
     self.assertEqual(l_xml2.find('Comment').text, TESTING_POOL_COMMENT_0)
     self.assertEqual(l_xml2.find('PoolType').text, TESTING_POOL_TYPE_0)
Esempio n. 20
0
 def _initilaize_pim(p_controller_obj):
     """Initialize a new UPBData object.
     """
     l_pim = UPBData()
     l_pim.InterfaceType = p_controller_obj.InterfaceType
     l_pim.Name = p_controller_obj.Name
     l_pim.UPBAddress = p_controller_obj.UPBAddress
     l_pim.UPBPassword = p_controller_obj.UPBPassword
     l_pim.UPBNetworkID = p_controller_obj.UPBNetworkID
     LOG.info('Initializing UPB PIM named: {}, Type={}'.format(l_pim.Name, l_pim.InterfaceType))
     LOG.debug(PrettyFormatAny.form(l_pim, 'PIM data'))
     return l_pim
Esempio n. 21
0
 def test_04_All(self):
     """Test the write for proper XML elements
     """
     l_xml = panasonicXML.write_panasonic_section_xml(self.m_pyhouse_obj)
     print(PrettyFormatAny.form(l_xml, 'D1-03-A - XML'))
     self.assertEqual(l_xml.find('Type').text, TESTING_PANASONIC_TYPE)
     self.assertEqual(l_xml[1].attrib['Name'], TESTING_PANASONIC_DEVICE_NAME_0)
     self.assertEqual(l_xml[1].attrib['Key'], TESTING_PANASONIC_DEVICE_KEY_0)
     self.assertEqual(l_xml[1].attrib['Active'], TESTING_PANASONIC_DEVICE_ACTIVE_0)
     self.assertEqual(l_xml[2].attrib['Name'], TESTING_PANASONIC_DEVICE_NAME_1)
     self.assertEqual(l_xml[2].attrib['Key'], TESTING_PANASONIC_DEVICE_KEY_1)
     self.assertEqual(l_xml[2].attrib['Active'], TESTING_PANASONIC_DEVICE_ACTIVE_1)
Esempio n. 22
0
 def decode(self, p_topic, p_message):
     """ Decode the Mqtt message
     ==> pyhouse/<house name>/security/<type>/<Name>
     <type> = garage door, motion sensor, camera
     """
     l_logmsg = '\tSecurity:\n'
     if p_topic[1] == 'garage_door':
         l_logmsg += '\tGarage Door: {}\n'.format(self._get_field(p_message, 'Name'))
     elif p_topic[1] == 'motion_sensor':
         l_logmsg += '\tMotion Sensor:{}\n\t{}'.format(self._get_field(p_message, 'Name'), self._get_field(p_message, 'Status'))
     else:
         l_logmsg += '\tUnknown sub-topic {}'.format(PrettyFormatAny.form(p_message, 'Security msg', 160))
     return l_logmsg
Esempio n. 23
0
 def test_02_Device1(self):
     """ Did we get the Device correctly (UPB)
     """
     self.m_device_obj.DeviceFamily = TESTING_FAMILY_NAME_2
     self.m_api = FamUtil._get_family_device_api(self.m_pyhouse_obj, self.m_device_obj)
     print(PrettyFormatAny.form(self.m_device_obj, 'C2-02-A - Device'))
     self.assertEqual(self.m_device_obj.Name, TESTING_LIGHT_NAME_1)
     self.assertEqual(self.m_device_obj.Key, TESTING_LIGHT_KEY_1)
     self.assertEqual(self.m_device_obj.Active, TESTING_LIGHT_ACTIVE_1)
     self.assertEqual(self.m_device_obj.DeviceFamily, TESTING_DEVICE_FAMILY_UPB)
     self.assertEqual(str(self.m_device_obj.DeviceType), TESTING_LIGHT_DEVICE_TYPE_0)
     self.assertEqual(str(self.m_device_obj.DeviceSubType), TESTING_LIGHT_DEVICE_SUBTYPE_0)
     self.assertEqual(self.m_device_obj.RoomName, TESTING_LIGHT_ROOM_NAME_0)
Esempio n. 24
0
 def test_01_Device0(self):
     """ Did we get the Device correctly (Insteon)
     """
     self.m_device_obj.DeviceFamily = TESTING_FAMILY_NAME_1
     l_device = self.m_device_obj
     print(PrettyFormatAny.form(l_device, 'C2-01-A - Device'))
     self.assertEqual(l_device.Name, TESTING_LIGHT_NAME_0)
     self.assertEqual(l_device.Key, TESTING_LIGHT_KEY_0)
     self.assertEqual(l_device.Active, TESTING_LIGHT_ACTIVE_0)
     self.assertEqual(l_device.DeviceFamily, TESTING_DEVICE_FAMILY_INSTEON)
     self.assertEqual(str(l_device.DeviceType), TESTING_LIGHT_DEVICE_TYPE_0)
     self.assertEqual(str(l_device.DeviceSubType), TESTING_LIGHT_DEVICE_SUBTYPE_0)
     self.assertEqual(l_device.RoomName, TESTING_LIGHT_ROOM_NAME_0)
Esempio n. 25
0
 def _decode_room(self, p_topic, p_message):
     l_logmsg = '\tRooms:\n'
     if p_topic[1] == 'add':
         l_logmsg += '\tName: {}\n'.format(self._get_field(p_message, 'Name'))
     elif p_topic[1] == 'delete':
         l_logmsg += '\tName: {}\n'.format(self._get_field(p_message, 'Name'))
     elif p_topic[1] == 'sync':
         l_logmsg += '\tName: {}\n'.format(self._get_field(p_message, 'Name'))
     elif p_topic[1] == 'update':
         l_logmsg += '\tName: {}\n'.format(self._get_field(p_message, 'Name'))
     else:
         l_logmsg += '\tUnknown sub-topic {}'.format(PrettyFormatAny.form(p_message, 'Rooms msg', 160))
     return l_logmsg
Esempio n. 26
0
 def Start(self):
     """ Start all the Onkyo factories if we have any Onkyo devices.
     """
     l_count = 0
     l_mfg = self.m_pyhouse_obj.House.Entertainment.Plugins[SECTION]
     print(PrettyFormatAny.form(l_mfg, 'onkyo.Start() Plugins'))
     for l_onkyo_obj in l_mfg.Devices.values():
         if not l_onkyo_obj.Active:
             continue
         l_host = l_onkyo_obj.IPv4
         l_port = l_onkyo_obj.Port
         l_onkyo_obj._Factory = OnkyoFactory(self.m_pyhouse_obj, l_onkyo_obj)
         _l_connector = self.m_pyhouse_obj.Twisted.Reactor.connectTCP(l_host, l_port, l_onkyo_obj._Factory)
         LOG.info("Started Onkyo {} {}".format(l_host, l_port))
     LOG.info("Started {} Onkyo devices".format(l_count))
Esempio n. 27
0
    def decode(self, p_topic, p_message):
        """ Decode the Mqtt message
        ==> pyhouse/<house name>/entertainment/samsung/<type>/<Name>/...
        <type> = ?
        """
        if self.m_API == None:
            # LOG.debug('Decoding initializing')
            self.m_API = API(self.m_pyhouse_obj)

        l_logmsg = ''
        if p_topic[2] == 'control':
            l_logmsg += '\tSamsung: {}\n'.format(self._decode_control(p_topic, p_message))
        else:
            l_logmsg += '\tUnknown Samsung sub-topic {}'.format(PrettyFormatAny.form(p_message, 'Entertainment msg', 160))
        return l_logmsg
Esempio n. 28
0
 def test_03_Base(self):
     """Test the write for proper XML elements
     """
     l_obj = self.m_pyhouse_obj.House.Entertainment
     print(PrettyFormatAny.form(self.m_pyhouse_obj.House, 'E1-01-A - House'))
     print(PrettyFormatAny.form(l_obj, 'E1-01-B - Entertainment'))
     print(PrettyFormatAny.form(l_obj.Plugins, 'E1-01-C - Plugins'))
     print(PrettyFormatAny.form(l_obj.Plugins[SECTION], "E1-01-D - Plugins['panasonic]"))
     print(PrettyFormatAny.form(l_obj.Plugins[SECTION].Devices, "E1-01-E - Devices"))
     print(PrettyFormatAny.form(l_obj.Plugins[SECTION].Devices[0], "E1-01-F - Devices"))
Esempio n. 29
0
 def _get_family_obj(p_pyhouse_obj, p_device_obj):
     """
     Given some device object, extract the Family object using .DeviceFamily
     """
     l_family_name = p_device_obj.DeviceFamily
     try:
         l_family_obj = p_pyhouse_obj.House.FamilyData[l_family_name]
     except KeyError as e_err:
         l_msg = PrettyFormatAny.form(p_pyhouse_obj.House, ' House Information', 40)
         LOG.error('Could not get family object for:\n\tDevice Name:\t{}\n\tFamily:\t\t{}\n\tKey Error:\t{}{}'
                   .format(p_device_obj.Name, l_family_name, e_err, l_msg))
         if l_family_name == 'Null':
             p_pyhouse_obj.House.FamilyData['Null'] = FamilyData()
             p_pyhouse_obj.House.FamilyData['Null'].Name = 'Null'
         l_family_obj = p_pyhouse_obj.House.FamilyData['Null']
     return l_family_obj
Esempio n. 30
0
 def test_02_Base(self):
     """Test the write for proper XML elements
     """
     # print(PrettyFormatAny.form(self.m_panasonic, 'D1-01-A - Plugin'))
     l_xml = panasonicXML._write_device(self.m_panasonic.Devices[0])
     print(PrettyFormatAny.form(l_xml, 'D1-01-B - XML'))
     self.assertEqual(l_xml.attrib['Name'], TESTING_PANASONIC_DEVICE_NAME_0)
     self.assertEqual(l_xml.attrib['Key'], TESTING_PANASONIC_DEVICE_KEY_0)
     self.assertEqual(l_xml.attrib['Active'], TESTING_PANASONIC_DEVICE_ACTIVE_0)
     self.assertEqual(l_xml.find('UUID').text, TESTING_PANASONIC_DEVICE_UUID_0)
     self.assertEqual(l_xml.find('Comment').text, TESTING_PANASONIC_DEVICE_COMMENT_0)
     #
     self.assertEqual(l_xml.find('IPv4').text, TESTING_PANASONIC_DEVICE_IPV4_0)
     self.assertEqual(l_xml.find('Port').text, TESTING_PANASONIC_DEVICE_PORT_0)
     self.assertEqual(l_xml.find('RoomName').text, TESTING_PANASONIC_DEVICE_ROOM_NAME_0)
     self.assertEqual(l_xml.find('RoomUUID').text, TESTING_PANASONIC_DEVICE_ROOM_UUID_0)
     self.assertEqual(l_xml.find('Type').text, TESTING_PANASONIC_DEVICE_TYPE_0)
     self.assertEqual(l_xml.find('Volume').text, TESTING_PANASONIC_DEVICE_VOLUME_0)
Esempio n. 31
0
 def test_01_Build(self):
     """ The basic read info as set up
     """
     # print(PrettyFormatAny.form(self.m_working_sched, 'C1-01-A - WorkingSchedule'))
     # print(PrettyFormatAny.form(self.m_pyhouse_obj.House, 'C1-01-B - House'))
     print(PrettyFormatAny.form(self.m_pyhouse_obj.House.Schedules, 'C1-01-C - Schedules'))
Esempio n. 32
0
 def test_01_Build(self):
     """ The basic read info as set up
     """
     print(PrettyFormatAny.form(self.m_working_rooms, 'C1-01-A - WorkingRooms'))
     print(PrettyFormatAny.form(self.m_pyhouse_obj.House, 'C1-01-B - House'))
     print(PrettyFormatAny.form(self.m_pyhouse_obj.House.Rooms, 'C1-01-C - Rooms'))
Esempio n. 33
0
 def test_03_ByteArray(self):
     print(PrettyFormatAny.form(MSG_JSON, 'A1-03-A - byte array'))
     l_json = MSG_JSON.decode('utf-8')
     print(PrettyFormatAny.form(l_json, 'A1-03-B - Ascii String', 5000))
     l_dict = json_tools.decode_json_unicode(l_json)
     print(PrettyFormatAny.form(l_dict, 'A1-03-C - Decoded Info'))
Esempio n. 34
0
 def Stop(self):
     _x = PrettyFormatAny.form(self.m_pyhouse_obj, 'PyHouse')
Esempio n. 35
0
 def test_04_Parsed(self):
     l_xml = ET.fromstring(XML_USB)
     print(PrettyFormatAny.form(l_xml, 'A2-04-A Parsed'))
     self.assertEqual(l_xml.tag, "USB")
Esempio n. 36
0
 def test_01_(self):
     """Test the write for proper XML Base elements
     """
     print(PrettyFormatAny.form(self.m_pyhouse_obj.House.Lighting.Lights, 'C2-01-A - Node'))
Esempio n. 37
0
 def test_00_Id(self):
     _x = PrettyFormatAny.form('_test', 'title', 190)  # so it is defined when printing is cleaned up.
     print('Id: test_lighting')
Esempio n. 38
0
 def test_01_Encode(self):
     l_json = json_tools.encode_json(MSG_DICT)
     print(PrettyFormatAny.form(l_json, 'A1-01-A - JSON'))
     print(PrettyFormatObject(l_json, 'A1-01-B - JSON'))
     self.assertSubstring('Street', l_json)
     self.assertSubstring('Elevation', l_json)
Esempio n. 39
0
 def test_02_GetApi1(self):
     self.m_device_obj.DeviceFamily = TESTING_FAMILY_NAME_1
     l_api = FamUtil._get_family_device_api(self.m_pyhouse_obj,
                                            self.m_device_obj)
     print(PrettyFormatAny.form(l_api, 'B4-02-A - API'))
     self.assertNotEqual(l_api, None)
Esempio n. 40
0
 def get_schedules(self, p_body):
     l_msg = jsonpickle.decode(p_body)
     LOG.debug('Got Schedules {}'.format(
         PrettyFormatAny.form(l_msg, 'Schedules', 190)))
Esempio n. 41
0
 def test_02_Parsed(self):
     l_xml = ET.fromstring(XML_LIGHT_SECTION)
     print('A2-02-A - Parsed\n{}'.format(PrettyFormatAny.form(l_xml, 'A2-02-A - Parsed')))
     self.assertEqual(l_xml.tag, TESTING_LIGHT_SECTION)
Esempio n. 42
0
 def get_sensors(self, p_body):
     l_msg = jsonpickle.decode(p_body)
     LOG.debug('Got Sensors {}'.format(
         PrettyFormatAny.form(l_msg, 'Sensors', 190)))
Esempio n. 43
0
 def test_02_Parsed(self):
     l_xml = ET.fromstring(XML_WEB_SERVER)
     print(PrettyFormatAny.form(l_xml, 'A2-02-A - Parsed XML'))
     self.assertEqual(l_xml.tag, TESTING_WEB_SECTION)
Esempio n. 44
0
 def test_03_House(self):
     """ Did we get everything set up for the rest of the tests of this class.
     """
     l_url = HueHub(self.m_pyhouse_obj)._build_uri(b'/config')
     print(PrettyFormatAny.form(l_url, '1-03-A - Url'))
     pass
Esempio n. 45
0
 def test_01_Modulepath(self):
     print(PrettyFormatAny.form(modulepath.path, 'B01-01-A - modulepath'))
     print(PrettyFormatAny.form(webpath.path, 'B01-01-A - modulepath'))
     self.assertEqual(
         modulepath.path,
         '/home/briank/workspace/PyHouse/Project/src/Modules/Computer/Web')
Esempio n. 46
0
 def test_00_Print(self):
     _x = PrettyFormatAny.form('_test', 'title', 190)  # so it is defined when printing is cleaned up.
     print('Id: test_Insteon_device')        self.m_light = deviceXML().read_base_device_object_xml(self.m_device, self.m_xml.light)
Esempio n. 47
0
 def _Stop(self):
     LOG.debug(PrettyFormatAny.form(self.m_pyhouse_obj, 'Dummy', 190))
Esempio n. 48
0
 def test_01_Nodes(self):
     """ Be sure that the XML contains the right stuff.
     """
     print(PrettyFormatAny.form(self.m_xml.node_sect, 'A2-01-A - Light'))
     pass
Esempio n. 49
0
 def test_02_Parsed(self):
     l_xml = ET.fromstring(XML_SERIAL)
     print(PrettyFormatAny.form(l_xml, 'A2-02-A - Parsed\n'))
     self.assertEqual(l_xml.tag, "Serial")
Esempio n. 50
0
 def test_00_Print(self):
     _x = PrettyFormatAny.form(
         '_test', 'title',
         190)  # so it is defined when printing is cleaned up.
     print('Id: test_mqtt_util')
Esempio n. 51
0
 def test_03_BA(self):
     y = json_tools.convert_from_unicode(MSG_JSON)
     print(PrettyFormatAny.form(y, 'A2-03-A - Decoded Info'))
     print(
         PrettyFormatObject(y, 'A2-03-A - Decoded Info', suppressdoc=False))
Esempio n. 52
0
 def test_01_Onkyo(self):
     l_obj = self.m_pyhouse_obj.House.Entertainment.Plugins['onkyo']
     print(PrettyFormatAny.form(l_obj, 'E1-01-A - PyHouse', 190))
     self.assertEqual(l_obj.DeviceCount, 2)
     self.assertEqual(l_obj.Name, 'onkyo')
Esempio n. 53
0
 def test_02_Lighting(self):
     l_xml = self.m_apix.find_xml_section(self.m_pyhouse_obj,
                                          'HouseDivision/LightingSection')
     print(PrettyFormatAny.form(l_xml, 'J3-02-A Base'))
     # self.assertEqual(l_xml.Name, '')
     pass
Esempio n. 54
0
 def add_browser(self, p_login):
     self.ConnectedBrowsers.append(p_login)
     LOG.warn('Connected to: {}'.format(
         PrettyFormatAny.form(p_login, 'Login')))
Esempio n. 55
0
 def test_02_Write(self):
     l_xml = ET.Element('TestElement')
     l_obj = DeviceInformation()
     utils.read_room_reference_xml(l_obj, l_xml)
     print(PrettyFormatAny.form(l_obj, 'B1-02-A - Data'))
Esempio n. 56
0
 def startedConnecting(self, p_connector):
     LOG.debug('Started to connect. {}'.format(
         PrettyFormatAny.form(p_connector, 'Connector', 180)))
Esempio n. 57
0
 def test_02_Uuids(self):
     print(PrettyFormatAny.form(self.m_pyhouse_obj._Uuids, 'UUIDS'))
     print(PrettyFormatAny.form(self.m_pyhouse_obj._Uuids.All, 'All'))
Esempio n. 58
0
 def test_00_Print(self):
     _x = PrettyFormatAny.form(
         '_test', 'title')  # so it is defined when printing is cleaned up.
     print('Id: test_sonoff_device')
Esempio n. 59
0
 def test_01_Data(self):
     """ Test that the data is in the correct form
     """
     l_plugins = self.m_pyhouse_obj.House.Entertainment.Plugins
     print(PrettyFormatAny.form(l_plugins, 'E1-01-A - Plugins'))
     self.assertEqual(l_plugins['panasonic'].DeviceCount, 2)
Esempio n. 60
0
 def Stop(self):
     LOG.debug(PrettyFormatAny.form(self.m_pyhouse_obj.House))
     LOG.info("Stopped.")