コード例 #1
0
ファイル: _scene.py プロジェクト: allanbunch/beautifulhue
    def create(self, resource, debug=False):

        request = Request()
        path = 'api/{username}/scenes'.format(username=self.user['name'])
        url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'],
                                                 path=path)
        resource['data']['name'] = resource['which']
        status, content = request.post(url, resource['data'])
        if debug:
            return dict(info=status, resource=content)
        else:
            return dict(resource=content)
コード例 #2
0
    def create(self, resource, debug=False):

        request = Request()
        path = 'api/{username}/scenes'.format(username=self.user['name'])
        url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'],
                                                 path=path)
        resource['data']['name'] = resource['which']
        status, content = request.post(url, resource['data'])
        if debug:
            return dict(info=status, resource=content)
        else:
            return dict(resource=content)
コード例 #3
0
    def create(self, resource, debug=False):
        """

        """

        request = Request()
        url = 'http://{bridge_ip}/api'.format(bridge_ip=self.bridge['ip'])
        if 'user' in resource:
            resource['user']['username'] = resource['user'].pop('name')
            status, content = request.post(url, resource['user'])
        if debug:
            return dict(info=status, resource=content)
        else:
            return dict(resource=content)
コード例 #4
0
ファイル: _schedule.py プロジェクト: Edinunzio/beautifulhue
    def create(self, resource, debug=False):
        """

        """

        request = Request()
        path = "api/{username}/schedules".format(username=self.user["name"])
        url = "http://{bridge_ip}/{path}".format(bridge_ip=self.bridge["ip"], path=path)
        resource["data"]["name"] = resource["which"]
        status, content = request.post(url, resource["data"])
        if debug:
            return dict(info=status, resource=content)
        else:
            return dict(resource=content)
コード例 #5
0
ファイル: _config.py プロジェクト: Edinunzio/beautifulhue
    def create(self, resource, debug=False):
        """

        """

        request = Request()
        url = 'http://{bridge_ip}/api'.format(bridge_ip=self.bridge['ip'])
        if resource.has_key('user'):
            resource['user']['username'] = resource['user'].pop('name')
            status, content = request.post(url, resource['user'])
        if debug:
            return dict(info=status, resource=content)
        else:
            return dict(resource=content)
コード例 #6
0
    def find(self, resource, debug=False):
        """
        @summary: Search for new lights.
        """

        request = Request()

        services = {'new': {'service': 'lights'}}

        service = services[resource['which']]['service']
        path = 'api/{username}/{service}'.format(username=self.user['name'],
                                                 service=service)
        url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'],
                                                 path=path)

        status, content = request.post(url)
        if debug:
            return dict(info=status, resource=content)
        else:
            return dict(resource=content)
コード例 #7
0
ファイル: _light.py プロジェクト: allanbunch/beautifulhue
    def find(self, resource, debug=False):
        """
        @summary: Search for new lights.
        """
        
        request = Request()
        
        services = {
            'new':{'service':'lights'}
        }
        
        service = services[resource['which']]['service']
        path = 'api/{username}/{service}'.format(
                                               username=self.user['name'],
                                               service=service
                                           )
        url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'],
                                                 path=path)

        status, content = request.post(url)
        if debug:
            return dict(info=status, resource=content)
        else:
            return dict(resource=content)