Skip to main content

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.

Methods

There are four methods:

  1. login
    • requires username and password
    • this method always needs to be called at the start of a session because it pulls in a sessionid from the server
    • returns True when completed
  2. getThings
    • no parameters
    • returns the response body as a json dict from the Brunt server, which has details about all your things
  3. getState
    • name of the thing
    • returns the details of the state as a json dict from the Brunt server
  4. changePosition
    • name of the thing and the requested position
    • returns True if the return status code was 200 (success)

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()
print(f"    { len(things) } thing(s) found.")

state = bapi.getState('Blind')
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('Blind', newPos)
print('    Success!' if res else '    Fail!')
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brunt-0.0.3.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file brunt-0.0.3.tar.gz.

File metadata

  • Download URL: brunt-0.0.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for brunt-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f4a60660b366328853c7127a7f2f4ef883aaf69f62eed2c642aae99cbe7db499
MD5 eac52a80ed6f03f640bcf51a2cbfd246
BLAKE2b-256 e4005edb0edb580a8305e0db0a38bdd0654291ac76ab9806314146522c1a7599

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page