Unofficial API for Brunt
Project description
Brunt
Unofficial python SDK for Brunt, based on the npm version here https://github.com/MattJeanes/brunt-api
This package allows you to control your Brunt devices from code.
Sample script
This script shows the usage and how to use the output of the calls, off course if you already know the name of your device you do not need to call getThings.
This script checks the current position of a blind called 'Blind' and if that is 100 (fully open), sets it to 90 and vice versa.
from brunt.brunt import BruntAPI
bapi = BruntAPI()
print("Calling Brunt")
bapi.login('username', 'password')
print(" Logged in, gettings things.")
things = bapi.getThings()['things']
print(f" { len(things) } thing(s) found.")
state = bapi.getState(thing='Blind')['thing']
print(f" Current status of { state['NAME'] } is position { state['currentPosition'] }")
newPos = 100
if int(state['currentPosition']) == 100:
newPos = 90
print(f" Setting { state['NAME'] } to position { newPos }")
res = bapi.changePosition(thing='Blind', newPos)
print(' Success!' if res else ' Fail!')
BruntAPI
BruntAPI()
login
BruntAPI.login(self, username, password)
Login method using username and password
:param username: the username of your Brunt account :param password: the password of your Brunt account
:return: True if successfull :raises: errors from Requests call
getThings
BruntAPI.getThings(self)
Get the things registered in your account
:return: dict with things registered in the logged in account and API call status :raises: errors from Requests call
getState
BruntAPI.getState(self, **kwargs)
Get the state of a thing
:param thing: a string with the name of the thing, which is then checked using getThings. :param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.
:return: a dict with the state of the Thing. :raises: ValueError if the requested thing does not exists. NameError if not logged in. SyntaxError when not exactly one of the params is given.
changePosition
BruntAPI.changePosition(self, position, **kwargs)
Changes the position of the thing.
:param position: The new position for the slide (0-100) :param thing: a string with the name of the thing, which is then checked using getThings. :param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.
:return: a dict with the state of the Thing. :raises: ValueError if the requested thing does not exists or the position is not between 0 and 100. NameError if not logged in. SyntaxError when not exactly one of the params is given.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file brunt-0.1.1.tar.gz
.
File metadata
- Download URL: brunt-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d9db08ce70b8ff371c47907ecd6044ad07bc92db511af100cd29c6792f3b051 |
|
MD5 | 5bb6d66b8f1d7768996c9ca3b9ca1f28 |
|
BLAKE2b-256 | 7ad81d3289da10a4aa18e86a1e1516b16ceb6815269149bddb991cee23a5d4fb |
File details
Details for the file brunt-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: brunt-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40a1c69e8032202876aa8fd67ec03aad2cbd154dcaef2c9fdcba6eb17addccf2 |
|
MD5 | e9133529e69ed260ce1c2fa50fd7b2ad |
|
BLAKE2b-256 | 7a0915cc80eb97ac1c009670edc03928c1c07e543cc1be81d2971fcf125fcb36 |