Exemplo n.º 1
0
class IR_Devices(Devices):
    brand = models.CharField(max_length=100, blank=True)
    deviceModelNumber = models.CharField(max_length=100, blank=True)
    remoteModelNumber = models.CharField(max_length=100, blank=True)
    transceiver = models.ForeignKey(Transceivers)

    class Meta:
        app_label = 'webmote'
Exemplo n.º 2
0
class XBMC_Actions(Actions):
    command = models.CharField(max_length=50)
    args = models.CharField(max_length=50, default='')

    class Meta:
        app_label = 'webmote'

    def runAction(self):
        server = jsonrpc.Server(
            self.device.getSubclassInstance().serverAddress())
        print self.command, self.args
        server._request(self.command, self.args)
Exemplo n.º 3
0
class Button(models.Model):
    name = models.CharField(max_length=100, null=True)
    x = models.IntegerField()
    y = models.IntegerField()
    icon = models.CharField(max_length=50, choices=ICONS)
    color = models.CharField(max_length=1, choices=COLORS)
    action = models.ForeignKey(Actions, null=True)
    url = models.CharField(max_length=1000, null=True)
    remote = models.ForeignKey(Remote)

    class Meta:
        app_label = 'webmote'
Exemplo n.º 4
0
class X10_Actions(Actions):
    code = models.CharField(max_length=10)

    class Meta:
        app_label = 'webmote'

    def runAction(self):
        transceiver = self.getTransceiver()
        if transceiver:
            try:
                device = self.device.getSubclassInstance()
                ser = serial.Serial('/dev/' + transceiver.usbPort, 9600)
                message = "%04x" % transceiver.id + 'p'.encode("hex")
                message += chr(
                    int(HOUSE_CODES[device.house].replace('B', '0b0000'),
                        2)).encode("hex")
                message += chr(
                    int(UNIT_CODES[str(device.unit)].replace('B', '0b000'),
                        2)).encode("hex")
                message += chr(
                    int(COMMAND_CODES[self.name].replace('B', '0b000'),
                        2)).encode("hex")
                ser.write(message)
            except:
                print 'Failed to play'
                return False
        else:
            print 'Couldn\'t find transceiver for action'
            return False
Exemplo n.º 5
0
class Remote(models.Model):
    name = models.CharField(max_length=100)
    style = models.IntegerField(choices=STYLES)
    user = models.ForeignKey(User)
    rows = models.IntegerField()

    class Meta:
        app_label = 'webmote'
Exemplo n.º 6
0
class Example_Actions(Actions):
    code = models.CharField(max_length=300)

    class Meta:
        app_label = 'webmote'

    def runAction(self):
        print 'Ran Action'
Exemplo n.º 7
0
class Schedules(models.Model):
    name = models.CharField(max_length=100, blank=True)
    active = models.BooleanField()

    class Meta:
        app_label = 'webmote'

    def delete(self, *args, **kwargs):
        for schedlet in self.schedlet_set.all():
            schedlet.delete()
        super(Schedules, self).delete(*args, **kwargs)
Exemplo n.º 8
0
class XBMC_Devices(Devices):
    ip = models.CharField(max_length=15)
    port = models.CharField(max_length=5)
    username = models.CharField(max_length=50)
    #plaintext for now
    password = models.CharField(max_length=50)

    class Meta:
        app_label = 'webmote'

    def serverAddress(self):
        serverAddress = 'http://'
        if self.username:
            serverAddress += self.username
            if self.password:
                serverAddress += ':' + self.password
            serverAddress += '@'
        return serverAddress + self.ip + ':' + self.port + '/jsonrpc'

    def getActions(self):
        server = jsonrpc.Server(self.serverAddress())
        return server.JSONRPC.Introspect()

    def getInputActions(self):
        inputActions = []
        for action in self.getActions()['methods']:
            if 'Input' in action:
                inputActions.append(action)
        return inputActions

    def saveInputActions(self):
        inputActions = self.getInputActions()
        for action in inputActions:
            newAction = XBMC_Actions(name=action.split('.')[-1],
                                     device=self,
                                     command=action)
            newAction.save()
Exemplo n.º 9
0
class X10_Devices(Devices):
    house = models.CharField(max_length=1)
    unit = models.IntegerField()
    state = models.IntegerField(default=0)
    lastCommand = models.IntegerField(null=True)
    transceiver = models.ForeignKey(Transceivers)

    class Meta:
        app_label = 'webmote'

    def save(self, *args, **kwargs):
        super(X10_Devices, self).save(*args, **kwargs)
        for command in COMMAND_CODES:
            newCommand = X10_Actions(name=command,
                                     device=self,
                                     code=COMMAND_CODES[command])
            newCommand.save()
Exemplo n.º 10
0
class IR_Actions(Actions):
    code = models.CharField(max_length=300)

    class Meta:
        app_label = 'webmote'

    def recordAction(self):
        transceiver = self.getTransceiver()
        if transceiver:
            try:
                print '/dev/' + transceiver.usbPort
                ser = serial.Serial('/dev/' + transceiver.usbPort, 9600)
                message = "%04x" % transceiver.id + 'r'.encode("hex")
                ser.write(message)
                print message
                print 'Recording...'
                self.code = str(ser.readline())
                print 'Recorded Command Succesfully: ' + self.code
                return True
            except:
                print 'Failed to record'
                return False
        else:
            print 'Couldn\'t find transceiver for device'
            return False

    def runAction(self):
        transceiver = self.getTransceiver()
        if transceiver:
            try:
                ser = serial.Serial('/dev/' + transceiver.usbPort, 9600)
                message = "%04x" % transceiver.id + 'p'.encode("hex") + str(
                    self.code)
                ser.write(message)
                print message
            except:
                print 'Failed to play'
                return False
        else:
            print 'Couldn\'t find transceiver for action'
            return False
Exemplo n.º 11
0
class Example_Devices(Devices):
    brand = models.CharField(max_length=100, blank=True)

    class Meta:
        app_label = 'webmote'