Package: brunt
BruntUnofficial python SDK for Brunt, based on the NPM version herehttps://github.com/MattJeanes/brunt-apiThis package allows you to control your Brunt devices from code.Sample scriptThis 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.frombruntimportBruntClient,BruntClientAsyncbapi=BruntClient()# bapi = BruntClientAsync()print("Calling Brunt")bapi.login('username','password')# await bapi.async_login('username', 'password')print("    Logged in, gettings things.")things=bapi.get_things()['things']# things = await bapi.async_get_things()['things']print(f"{len(things)}thing(s) found.")state=bapi.get_state(thing='Blind')['thing']# state = await bapi.async_get_state(thing='Blind')['thing']print(f"    Current status of{state['NAME']}is position{state['currentPosition']}")newPos=100ifint(state['currentPosition'])==100:newPos=90print(f"    Setting{state['NAME']}to position{newPos}")res=bapi.change_request_position(newPos,thing='Blind')# res = await bapi.async_change_request_position(newPos, thing='Blind')print('    Success!'ifreselse'    Fail!')BruntClient & BruntClientAsyncfrombruntimportBruntClientBruntClient(username,password)orfrombruntimportBruntClientAsyncBruntClientAsync(username,password,session)Constructor for the API wrapper.If you supply username and password here, they are stored, but not used.
Auto logging in then does work when calling another method, no explicit login needed.:param username: the username of your Brunt account
:param password: the password of your Brunt accountAsync only :param session: aiohttp.ClientSession objectloginBruntClient.login(self,username,password)awaitBruntClient.async_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 successful
:raises: errors from Requests callget_thingsBruntClient.get_things(self)awaitBruntClient.async_get_things(self)Get the things registered in your account:return: List of Things
:raises: errors from Requests callget_stateBruntClient.get_state(self,thing="Blind")awaitBruntClient.async_get_state(self,thing="Blind")Get the state of a thing, by NAME or thingUri:param thing: a string with the NAME of the thing, which is then checked against the names of all the things.
:param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.:return: a 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.change_request_positionBruntClient.change_request_position(self,request_position,thing="Blind")awaitBruntClient.async_change_request_position(self,request_position,thing="Blind")Changes the position of the thing. Internally calls the changeKey method with key set to
requestPosition and value set to request_position:param request_position: The new position for the slide (0-100)
:param thing: a string with the name of the thing, which is then checked against the names of all the things.
:param thingUri: Uri (string) of the thing you are getting the state from, not checked against getThings.:return: a dict with 'result'.
: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.change_keyBruntClient.change_key(self,key="requestPosition",value="100",thing="Blind")awaitBruntClient.async_change_key(self,key="requestPosition",value="100",thing="Blind")Change a variable of the thing by supplying the key and value. Mostly included for future additions.:param key: The key of the value you want to change
:param value: The new value
: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 'result'.
: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.