示例#1
0
    def __call__(self,
                 com_port=None,
                 adapter_name=None,
                 device='TV',
                 key=None):
        if key is None:
            key = getattr(self, 'value', None)
            if key is None or (com_port is None and adapter_name is None):
                eg.PrintNotice(
                    'CEC: This action needs to be configured before use.')
                return

        adapter = self._find_adapter(com_port, adapter_name)

        if adapter is None:
            eg.PrintNotice('CEC: Adapter %s on com port %s not found' %
                           (adapter_name, com_port))
        else:
            d = getattr(adapter, device.lower().replace(' ', ''), None)
            if d is None:
                eg.PrintNotice('CEC: Device %s not found in adapter %s' %
                               (device, adpater.name))
            else:
                remote = getattr(d, key, None)
                if remote is None:
                    eg.PrintError(
                        'CEC: Key %s not found for device %s on adapter %s' %
                        (key, device, adpater.name))
                else:
                    import time
                    remote.send_key_press()
                    time.sleep(0.1)
                    remote.send_key_release()
示例#2
0
    def Notice(self, message, item=None, messageOnly=False):

        if messageOnly:
            eg.PrintNotice(message)

        if not messageOnly:
            eg.PrintNotice(message + str(item))
示例#3
0
 def __call__(self):
     if self.plugin.client is None:
         return False
     result = self.plugin.client.GetDeviceInfo()
     if result is None:
         eg.PrintNotice("IR Service not running")
         self.plugin.TriggerEvent("IR_Service_Not_Running")
         return False
     if result[1] == 0 and result[2] == 0:
         eg.PrintNotice("IR Receiver is unplugged")
         self.plugin.TriggerEvent("IR_Receiver_Unplugged")
         return False
     nAttached = 0
     i = 0
     while (result[5] >> i) > 0:
         if result[5] & (1 << i):
             nAttached = nAttached + 1
         i = i + 1
     eg.PrintNotice(
         "%d Transmitters (%d attached), %s have learn capability" %
         (result[1], nAttached, "does" if result[2] == 2 else "does not"))
     if self.plugin.client.TestIR() == True:
         return True
     else:
         return False
    def Connect(self):
        """
        This function tries to connect to the named pipe from AlternateMceIrService.  If it can't connect, it will periodically
        retry until the plugin is stopped or the connection is made.
        """
        #eg.PrintNotice("MCE_Vista: Connect started")
        self.sentMessageOnce = False
        while self.file is None and self.keepRunning:
            try:
                self.file = win32file.CreateFile(
                    r'\\.\pipe\MceIr', win32file.GENERIC_READ
                    | win32file.GENERIC_WRITE, 0, None,
                    win32file.OPEN_EXISTING, win32file.FILE_ATTRIBUTE_NORMAL
                    | win32file.FILE_FLAG_OVERLAPPED, None)
            except:
                if not self.sentMessageOnce:
                    eg.PrintNotice(
                        "MCE_Vista: MceIr pipe is not available, app doesn't seem to be running"
                    )
                    eg.PrintNotice(
                        "    Will continue to try to connect to MceIr")
                    eg.PrintNotice(
                        "    Message = %s" %
                        win32api.FormatMessage(win32api.GetLastError()))
                    self.plugin.TriggerEvent("Disconnected")
                    self.sentMessageOnce = True

                if self.service and IsServiceStopped(self.service):
                    eg.PrintNotice(
                        "MCE_Vista: MceIr service is stopped, trying to start it..."
                    )
                    StartService(self.service)

                time.sleep(1)
        return
示例#5
0
    def __call__(self, com_port=None, adapter_name=None, device='TV'):
        adapter = self._find_adapter(com_port, adapter_name)

        if adapter is None:
            eg.PrintNotice('CEC: Adapter %s on com port %s not found' %
                           (adapter_name, com_port))
        else:
            d = getattr(adapter, device.lower().replace(' ', ''), None)
            if d is None:
                eg.PrintNotice('CEC: Device %s not found in adapter %s' %
                               (device, adpater.name))
            else:
                return self._process_call(d)
示例#6
0
    def CalculateWatts(self, DevID, Cost, Month):

        if DevID:
            try:
                DevWatts = dc(self.Watts[DevID])
                DevKWH = 0
                if DevWatts != []:
                    for i in range(len(DevWatts)):
                        if len(DevWatts[i]) == 7:
                            DevKWH += DevWatts[i][6] if DevWatts[i][1][1] == Month else 0
                    DevUsage = float(DevKWH) * Cost

                print "Device ID: ", DevID, ", KiloWatt Hours Used: ", DevKWH, ", Cost Month to Date: ", DevUsage
                return [DevKWH, DevUsage]
            except:
                eg.PrintNotice("MicasaVerdeVera: CalculateWatts: Unknown Device ID: "+DevID)
        else:
            DeviceUsage = {}
            CombinedKWH = 0
            for DevID, Data in self.Watts.iteritems():
                DevKWH = 0
                if Data == []: continue
                else:
                    for i in range(len(Data)):
                        if len(Data[i]) == 7:
                            DevKWH += Data[i][6] if Data[i][1][1] == Month else 0
                    CombinedKWH += DevKWH
                    DeviceUsage[DevID] = [DevKWH, float(DevKWH)*Cost]
            AllUsage = float(CombinedKWH)*Cost

            print "Device ID: AllDevices,  KiloWatt Hours Used: ", CombinedKWH, ", Cost Month to Date: ", AllUsage

            return [CombinedKWH, AllUsage, DeviceUsage]
        def NewItemsReporting(NI, NC, OI, OC):
            nItems, oItems = NewItemScan(NI, OI)
            nCounters, oCounters = NewItemScan(NC, OC)
            rItem = dc(nItems)
            rCount = NC if nCounters else dc(oCounters)
            noUp = False if nCounters or nItems else True

            if nCounters:
                eg.PrintNotice('MicasaVerde: OldCounters: ' + str(oCounters))
                eg.PrintNotice('MicasaVerde: NewCounters: ' + str(nCounters))

            if nItems:
                self.ItemLog.insert(0, [time.strftime("%c"), nItems])
                eg.PrintNotice('MicasaVerde: NewItems: ' + str(nItems))

            return rItem, rCount
示例#8
0
    def Animate(self,
                slide=False,
                blend=False,
                direction='',
                show=False,
                hide=False,
                duration=150):
        """
        Animates the hiding and showing of the window
        :param slide: Use the slide effect
        :type slide: bool
        :param blend: Use the blend effect
        :type blend: bool
        :param direction: the direction of the effect. choose from,
            'UP', 'DOWN', 'LEFT', 'RIGHT', ''
        :type direction: str
        :param show: Use effect when showing the window
        :type show: bool
        :param hide: Use the effect when hiding the window
        :type hide: bool
        :param duration: How long the total effect should run for in
            milliseconds
        :type duration: int
        :return: None
        :rtype: None
        """
        self.AssertAlive()
        if slide and blend:
            eg.PrintNotice(
                'You are only allowed to select one type of effect, '
                'or set both to False for roll effect.')
            return

        style = 0

        if direction.upper() == 'UP':
            style |= win32con.AW_HOR_NEGATIVE
        elif direction.upper() == 'DOWN':
            style |= win32con.AW_HOR_POSITIVE
        elif direction.upper() == 'LEFT':
            style |= win32con.AW_VER_NEGATIVE
        elif direction.upper() == 'RIGHT':
            style |= win32con.AW_VER_POSITIVE
        else:
            style |= win32con.AW_CENTER

        if hide:
            style |= win32con.AW_HIDE
        if show:
            style |= win32con.AW_ACTIVATE

        if slide:
            style |= win32con.AW_SLIDE

        elif blend:
            style |= win32con.AW_BLEND

        win32gui.AnimateWindow(self.hwnd, duration, style)
def PN(*args):
    args = list(args)
    for i in range(len(args)):
        if isinstance(args[i], str) or isinstance(args[i], unicode):
            args[i] += ': '
        else:
            args[i] = str(args[i])
    eg.PrintNotice("MiCasaVerde: " + "".join(args))
    return True
示例#10
0
    def __call__(self,startLevel,endLevel,deviceID,speed):

        if startLevel >= endLevel:
            eg.PrintNotice("the Starting Level has to be less than the End Level")
            return

        for level in range(endLevel,startLevel):
            time.sleep(speed)
            eg.plugins.Vera.SetDimming(deviceID,level)
    def initValues(self):
        zmDict = {}
        url = 'http://' + str(
            self.host) + ':80/goform/formMainZone_MainZoneXml.xml'

        try:
            r = urllib2.urlopen(url, timeout=1).read()
        except urllib2.HTTPError, e:
            eg.PrintNotice("Connection error, wrong IP or AVR not accessible")
            return False
示例#12
0
 def OnShutdown(self):
     eg.PrintNotice("Y.A.R.D.-Server shutdown")
     try:
        self.plugin.workerThread.comobj_yard.close()
     except:
        raise eg.Exception("YARD server not found")
     del self.plugin.workerThread.comobj_yard
     del self.plugin.comObj
     self.plugin.workerThread.comobj_yard = None
     self.plugin.comObj = None
示例#13
0
 def __call__(self):
     if self.plugin.client is None:
         return
     result = self.plugin.client.GetDeviceInfo()
     if result is None:
         eg.PrintNotice("IR Service not running")
         eg.TriggerEvent('IR Service Not Running', prefix="MCE_Vista")
         return
     if result[1] == 0 and result[2] == 0:
         eg.PrintNotice("IR Receiver is unplugged")
         return
     nAttached = 0
     i = 0
     while (result[5] >> i) > 0:
         if result[5] & (1 << i):
             nAttached = nAttached + 1
         i = i + 1
     eg.PrintNotice(
         "%d Transmitters (%d attached), %s have learn capability" %
         (result[1], nAttached, "does" if result[2] == 2 else "does not"))
示例#14
0
    def PrintCommand(self, ln, txt=""):
        limit = min(self.eechars, len(self.userchars))
        self.content[ln] = txt
        if txt == "":
            if self.workerThread:
                self.queue.put(((ln, ""), None))
            return

        usercharlst = [j[0] for j in self.userchars][:limit]
        usedchars = []
        for i in range(4):
            content = self.content[i] if i == ln else self.content[i][:self.
                                                                      cols]
            for c in content:
                if c in usercharlst and not c in usedchars:
                    usedchars.append(c)
        #find missing chars:
        missing = list(set(usedchars) - set(self.repldict.iterkeys()))
        # if len(missing) > 0   remaping is need
        if missing:
            needless = list(set(self.repldict.iterkeys()) - set(usedchars))
            # if len(needless) > 0 remap user chars
            remapcmd = []
            for k in range(min(len(missing), len(needless))):
                m = self.repldict[needless[k]]
                self.repldict[missing[k]] = m
                remapcmd.extend((usercharlst.index(missing[k]), m))
                del self.repldict[needless[k]]
            #if missing > needless, to use replacement char
            if len(missing) > len(needless):
                overdict = dict((p[0], p[1]) for p in self.userchars)
                missing = list(set(usedchars) - set(self.repldict.iterkeys()))
                self.reploverdict = {}
                for n in range(len(missing)):
                    miss = missing[n]
                    self.reploverdict[miss] = overdict[miss]
            if remapcmd:
                if self.workerThread:
                    self.queue.put(((COMMANDS["Remap"], remapcmd), None))
        for k, v in self.repldict.iteritems():
            txt = txt.replace(k, chr(v))
        for key, val in self.reploverdict.iteritems():
            txt = txt.replace(key, val)

        txt = [ord(ch) for ch in txt]
        for i, ch in enumerate(txt):
            if ch > 255:
                eg.PrintNotice(
                    u"Digispark-LCD: UNICODE CHARACTER: %s, code U%i" %
                    (unichr(ch), ch))
                txt[i] = 219
        if self.workerThread:
            self.queue.put(((ln, txt), None))
示例#15
0
 def __start__(self,
               prefix="Android",
               port=10600,
               remAddress="0.0.0.0",
               password=""):
     self.prefix = prefix
     self.port = port
     self.password = password
     try:
         self.receiver = udpReceiver(remAddress, port, self)
         eg.PrintNotice(self.text.listens % self.port)
     except socket_error, exc:
         raise self.Exception(exc[1].decode(localeEncoding()[1]))
示例#16
0
 def InitBoard(self, event):
     if self.flag:
         coms = self.enumerate_ports()
         diff = set(coms) - set(self.coms)
         self.coms = coms
         if not self.port in diff:
             return
         if event.payload[0].startswith(u'\\\\?\\USB#VID_067B&PID_2303#'):            
             self.ConnectPort()
             bType = self.SelectBoard()
         else:
             eg.PrintNotice(
                 self.text.info4 % (self.info.eventPrefix, self.port)
             )
示例#17
0
 def Synchro(self, servers = None):
     ntp = self.GetNTPtime(servers)
     res = self.Set_SystemTime(ntp[0]+time.timezone) if isinstance(ntp, list) else ntp
     if isinstance(res, int) and res:
         eg.PrintNotice("NTP: %s. SERVER: %s  OFFSET: %s s" % (
             self.text.synchro,
             str(ntp[2]),
             str(ntp[1]))
         )
         self.Log("%s. SERVER: %s  OFFSET: %s s" % (
             self.text.synchro,
             str(ntp[2]),
             str(ntp[1]))
         )
     else:
         eg.PrintError("NTP: %s. ERROR: %s" % (self.text.failed, res))
         self.Log("%s. ERROR: %s" % (self.text.failed, res))
     return res
示例#18
0
    def __call__(self, name, host, interval, timeout, modify=False):
        for client in Config.clients:
            if client[0] == name:
                if modify:
                    Config.clients.remove(client)
                    for t in self.plugin.threads:
                        if t.client_name == name:
                            t.stop()
                            self.plugin.threads.remove(t)
                else:
                    eg.PrintNotice(
                        'Is Connected: '
                        'A client with the name %s already exists.' % name)
                    return

        Config.clients += [(name, host, interval, timeout)]

        t = Thread(self.plugin, name, host, interval, timeout)
        self.plugin.threads += [t]
        t.start()
示例#19
0
 def enumerate_ports(self):
     SER2PL32 = 'SYSTEM\\CurrentControlSet\\Services\\Ser2pl\\Enum'
     SER2PL64 = 'SYSTEM\\CurrentControlSet\\Services\\Ser2pl64\\Enum'
     
     try:
         # 32-bit Prolific driver
         self.arch = 32
         self.prolific_path = OpenKey(HKEY_LOCAL_MACHINE, SER2PL32)
     except WindowsError:
         try:
             # 64-bit
             self.arch = 64
             self.prolific_path = OpenKey(HKEY_LOCAL_MACHINE, SER2PL64)
         except WindowsError:
             eg.PrintNotice(self.text.info2 % self.info.eventPrefix)
             return []
     ports, type = QueryValueEx(self.prolific_path, 'Count')
     if ports is 0:
         return []
     coms = [0] * ports
     ENUM = 'SYSTEM\\CurrentControlSet\\Enum\\'
     try:
         i = 0
         j = 0
         while 1:
             name, string, type = EnumValue(self.prolific_path, i)
             if type == 1: # 1 is for 'REG_SZ', 'A null-terminated string'
                 sn = search('(?<=[\][0-9]&)\w+',string)
                 offset = 0
                 try:
                     serint = ENUM + string + '\\Device Parameters'
                     serial_path = OpenKey(HKEY_LOCAL_MACHINE,serint)
                     port, type = QueryValueEx(serial_path, 'PortName')
                     coms[j] = int(str(port)[3:]) - 1
                     j += 1
                 except WindowsError:
                     pass
             i += 1
     except WindowsError:
         pass
     return coms
示例#20
0
 def __start__(
     self,
     port = 0,
     bType = '',
     initState = [0,0,0,0,0,0,0,0],
     prefix = "ICS_Relay"
 ):
     coms = self.enumerate_ports()
     self.coms = coms
     self.port = port
     self.bType = bType
     self.info.eventPrefix = prefix
     self.curState = initState[:]
     self.initState = initState[:]
     eg.Bind("System.DeviceAttached", self.InitBoard)
     eg.Bind("System.DeviceRemoved", self.DeleteBoard)
     if self.port in self.coms:
         self.ConnectPort()
         #bType = self.SelectBoard() # init or not ?
     else:
         eg.PrintNotice(self.text.info1 % (prefix, self.port + 1))
    def run(self):
        continueloop = True
        overlapped = self.plugin.serial._overlappedRead
        hComPort = self.plugin.serial.hComPort
        hEvent = overlapped.hEvent
        n = 1
        waitingOnRead = False
        buf = win32file.AllocateReadBuffer(n)
        reply = {'suffix': None, 'payload': None}
        lastEvent = None

        while continueloop:
            if not waitingOnRead:
                win32event.ResetEvent(hEvent)
                hr, _ = win32file.ReadFile(hComPort, buf, overlapped)
                if hr == 997:
                    waitingOnRead = True
                elif hr == 0:
                    pass
                else:
                    raise
            rc = win32event.MsgWaitForMultipleObjects(
                (hEvent, self.plugin.stopEvent), 0, 1000,
                win32event.QS_ALLINPUT)
            if rc == win32event.WAIT_OBJECT_0:
                n = win32file.GetOverlappedResult(hComPort, overlapped, 1)
                if n:
                    reply = self.plugin.Decode(ord(buf))
                    if reply is not None and reply != lastEvent:
                        self.plugin.TriggerEnduringEvent(**reply)
                        lastEvent = reply.copy()
                waitingOnRead = False
            elif rc == win32event.WAIT_OBJECT_0 + 1:
                continueloop = False
            elif rc == win32event.WAIT_TIMEOUT:
                self.plugin.EndLastEvent()
            else:
                eg.PrintError("unknown message")
                eg.PrintNotice(str(rc))
示例#22
0
 def OnCmdPython(self):
     eg.PrintNotice("DEBUG: TreeCtrl: OnCmdPython")
示例#23
0
 def __stop__(self):
     eg.PrintNotice("MCE_Vista: Stopping Mce Vista plugin")
     win32event.SetEvent(self.hFinishedEvent)
     self.client.Stop()
     self.client = None
示例#24
0
 def StopNTP(self):
     if self.task:
         eg.scheduler.CancelTask(self.task)
         eg.PrintNotice(self.text.stop)
         self.task = None
         self.SetStatusLabel()        
示例#25
0
 def StartNTP(self):
     self.StopNTP()
     self.task = eg.scheduler.AddTask(60 * self.rate, self.Polling)
     self.Synchro()
     eg.PrintNotice(self.text.start)
     self.SetStatusLabel()        
示例#26
0
 def __stop__(self):
     if self.receiver:
         self.receiver.close()
         eg.PrintNotice(self.text.released % self.port)
     self.receiver = None
示例#27
0
 def Init(self):
     while self.run and self.lcd is None:
         try:
             self.lcd = ArdUsbDev(idVendor=0x16c0,
                                  idProduct=0x05df,
                                  deviceName='Digispark-LCD')
             self.lcd.write(ENQ)
             sleep(1.0)
             ch = None
             while True:
                 try:
                     ch = self.lcd.read()
                 except:
                     ch = None
                     break
                 if ch == STX:
                     try:
                         ch = self.lcd.read()
                         rows = ch
                     except:
                         ch = None
                         break
                     try:
                         ch = self.lcd.read()
                         cols = ch
                     except:
                         ch = None
                         break
                     try:
                         ch = self.lcd.read()
                         user_chars = ch
                     except:
                         ch = None
                         break
                     try:
                         ch = self.lcd.read()
                         if ch != ETX:
                             ch = None
                         break
                     except:
                         ch = None
                         break
                 else:
                     ch = None
             if ch is None:
                 raise ValueError('Dummy error')
             else:
                 eg.PrintNotice(self.plugin.text.connect % (rows, cols))
                 self.plugin.eechars = user_chars if user_chars < 57 else 0
                 if len(self.plugin.userchars) != self.plugin.eechars:
                     eg.PrintNotice(self.plugin.text.ee_char %
                                    self.plugin.eechars)
                     eg.PrintNotice(self.plugin.text.cust_char %
                                    len(self.plugin.userchars))
                     eg.PrintNotice(self.plugin.text.edit)
                 else:
                     eg.PrintNotice(self.plugin.text.cust_chr %
                                    self.plugin.eechars)
                 self.plugin.rows = rows
                 self.plugin.cols = cols
                 self.udprint(2, "Digispark-LCD")
                 self.udprint(COMMANDS["InitCGRAM"])
                 self.udprint(COMMANDS["Clear"])
                 self.plugin.InitCGRAM()  # synchronization ...
         except:
             sleep(5.0)
 def HandleData(self):
     """
     This runs once a connection to the named pipe is made.  It receives the ir data and passes it to the plugins IRDecoder.
     """
     if self.sentMessageOnce:
         eg.PrintNotice(
             "MCE_Vista: Connected to MceIr pipe, started handling IR events"
         )
         self.plugin.TriggerEvent("Connected")
     nMax = 2048
     self.result = []
     self.freqs = [0]
     self.readOvlap = win32file.OVERLAPPED()
     self.readOvlap.hEvent = win32event.CreateEvent(None, 0, 0, None)
     handles = [self.plugin.hFinishedEvent, self.readOvlap.hEvent]
     self.timeout = win32event.INFINITE
     while self.keepRunning:
         try:
             (hr, data) = win32file.ReadFile(self.file, nMax,
                                             self.readOvlap)
         except:
             win32file.CloseHandle(self.file)
             self.file = None
             return
         rc = win32event.WaitForMultipleObjects(handles, False,
                                                self.timeout)
         if rc == win32event.WAIT_OBJECT_0:  #Finished event
             self.keepRunning = False
             break
         elif rc == win32event.WAIT_TIMEOUT and self.learnDialog:  #Learn timeout
             #eg.PrintNotice("LearnTimeout: Sending ir code %s"%str(self.result))
             self.learnDialog.GotCode(self.freqs, self.result)
             self.result = []
             self.timeout = win32event.INFINITE
             rc = win32event.WaitForMultipleObjects(handles, False,
                                                    self.timeout)
             if rc == win32event.WAIT_OBJECT_0:  #Finished event
                 self.keepRunning = False
                 break
         try:
             nGot = self.readOvlap.InternalHigh
             if nGot == 0:
                 continue
             if nGot % ptr_len == 1:  #Query result, not ir code data
                 if data[0] == "b".encode("ascii"):
                     self.deviceInfo = unpack_from(6 * ptr_fmt,
                                                   data[1:nGot])
                     win32event.SetEvent(self.deviceInfoEvent)
                 elif data[0] == "t".encode("ascii"):
                     win32event.SetEvent(self.deviceTestEvent)
                 continue
             #pull of the header data
             while nGot > 0:
                 header = unpack_from(3 * ptr_fmt, data)
                 if header[0] == 1 and header[2] > 0:
                     self.freqs.append(header[2])
                 dataEnd = nGot
                 if nGot > 100 + 3 * ptr_len:
                     dataEnd = 100 + 3 * ptr_len
                 nGot -= dataEnd
                 val_data = data[3 * ptr_len:dataEnd]
                 dataEnd = dataEnd - 3 * ptr_len
                 vals = unpack_from((dataEnd / 4) * "i", val_data)
                 data = data[100 + 3 * ptr_len:]
                 for i, v in enumerate(vals):
                     a = abs(v)
                     self.result.append(a)
                     if self.learnDialog is None:  #normal mode
                         if a > 6500:  #button held?
                             if self.CodeValid(self.result):
                                 #eg.PrintNotice("Sending ir code %s"%str(self.result))
                                 self.plugin.irDecoder.Decode(
                                     self.result, len(self.result))
                             self.result = []
                 if not self.learnDialog is None:  #learn mode
                     if header[0] == 1:  #one "learn" chunk
                         self.timeout = self.learnTimeout
         except:
             pass
class DenonTCPIP(eg.PluginBase):
    """ A plugin to control my Denon Receiver via TCP/IP """
    def __init__(self):
        self.host = "192.168.1.2"
        self.port = 23
        self.things = []
        self.connected = False
        self.volume = DenonVolume()
        self.volume.plugin = self
        self.mute = False
        self.muteZ2 = False
        self.state = False
        self.stateZ2 = False

        mainZone = self.AddGroup("Zone 1", "Actions for Zone 1")

        mainZoneInfo = mainZone.AddGroup("Information Retrieval",
                                         "Zone 1 Information Retrieval")
        mainZoneInfo.AddAction(GetMainZoneVolume)
        mainZoneInfo.AddAction(GetMainZoneSource)
        mainZoneInfo.AddAction(GetMainZoneState)
        mainZoneInfo.AddAction(GetMainZoneMute)

        mainZone.AddAction(ToggleMainZoneMute)
        mainZone.AddAction(ToggleMainZonePower)
        mainZone.AddAction(SetMainZonePowerOn)
        mainZone.AddAction(SetMainZonePowerOff)
        mainZone.AddAction(SetMainZoneSource)
        mainZone.AddAction(SetMainZoneAudioSource)
        mainZone.AddAction(SetMainZoneVolumeLevel)
        mainZone.AddAction(VolumeMainZoneUp)
        mainZone.AddAction(VolumeMainZoneDn)

        Zone2 = self.AddGroup("Zone 2", "Actions for Zone 2")

        Zone2Info = Zone2.AddGroup("Information Retrieval",
                                   "Zone 2 Information Retrieval")
        Zone2Info.AddAction(GetZone2State)
        Zone2Info.AddAction(GetZone2Mute)

        Zone2.AddAction(ToggleZone2Mute)
        Zone2.AddAction(ToggleZone2Power)
        Zone2.AddAction(SetZone2Source)
        Zone2.AddAction(SetZone2VolumeLevel)

        OSM = self.AddGroup("On Screen Menu",
                            "Actions for remote OSM button press'")
        OSM.AddAction(osmUp)
        OSM.AddAction(osmDown)
        OSM.AddAction(osmLeft)
        OSM.AddAction(osmRight)
        OSM.AddAction(osmSelect)
        OSM.AddAction(osmOption)
        OSM.AddAction(osmInfo)

        self.AddAction(GenericSend)

    def Configure(self, host="192.168.1.104", port=23):

        panel = eg.ConfigPanel()
        hostCtrl = panel.TextCtrl(host)
        portCtrl = panel.SpinIntCtrl(port, max=65535)

        st1 = panel.StaticText("Host:")
        st2 = panel.StaticText("Port:")

        eg.EqualizeWidths((st1, st2))
        IPBox = panel.BoxedGroup(
            "TCPIP/IP Settings",
            (st1, hostCtrl),
            (st2, portCtrl),
        )

        panel.sizer.Add(IPBox, 0, wx.EXPAND)

        while panel.Affirmed():
            panel.SetResult(
                hostCtrl.GetValue(),
                portCtrl.GetValue(),
            )

    def __start__(self, host, port):
        self.host = host
        self.port = port
        self.initValues()

    def __stop__(self):
        pass

    def initValues(self):
        zmDict = {}
        url = 'http://' + str(
            self.host) + ':80/goform/formMainZone_MainZoneXml.xml'

        try:
            r = urllib2.urlopen(url, timeout=1).read()
        except urllib2.HTTPError, e:
            eg.PrintNotice("Connection error, wrong IP or AVR not accessible")
            return False
        except urllib2.URLError, e:
            eg.PrintNotice("Connection error, wrong IP or AVR not accessible")
            return False