Giter VIP home page Giter VIP logo

bond-cli's Introduction

PyPI version

Bond Command Line Interface

EDIT: This project is in a beta state. We released it on the principle of release early & often. It is here just in case it benefits a member of the Bond Home community. Your mileage may vary!

Purpose

This tool exists to make it easy to manipulate a Bond from a command line, for use by:

  • Bond community
  • internal use in engineering and customer support

Installation

Install with

pip install bond-cli

Getting Started

Find Bonds on local network:

bond discover

Select a Bond and set the token so we can go deeper:

bond select <your Bond's ID or a prefix>

If your Bond's token is unlocked, select will retrieve and store it. Otherwise, you have a couple options. You can unlock the token yourself (a power cycle is the easiest way, it'll be unlocked for a period after a reboot), and run the following to automatically retrieve and store it:

bond token

Or, you can manually set the token, which you could find in the Bond Home app in the Bond's settings screen.

bond token <your Bond's token>

Now that you've selected a Bond and stored its token, you're ready to interact with it.

Check its firmware version:

bond version

Device Management

Create a template device:

bond devices create --name "Formidable Fan" --location "Bedroom" --template A1 --addr 101 --freq 300000 --bps 1000 --zero_gap 1234

You can then see the fan on your Bond Home app.

List existing devices:

bond devices list

Delete one or more devices:

bond devices delete <DEVICE1_ID> <DEVICE2_ID>

Device Groups

Create a device group:

bond groups create --name "All Shades" <BOND1_ID>:<DEVICE1_ID> <BOND2_ID>:<DEVICE1_ID> <BOND2_ID>:<DEVICE2_ID> 

List the existing device groups:

bond groups list

List the device groups on a single Bond (may not represent the whole group):

bond groups list --bond-id <BOND_ID>

Live Logging

You can also start a livelog:

bond livelog --level info

Upgrade Your Bond

You can upgrade your selected bond:

bond upgrade beta

Getting Help

Get more help with:

bond -h

or you can get help with any subcommand

bond select -h

Contributing

Bug reports and feature requests in the form of issues and pull requests are strongly encouraged!

To develop locally, you can clone the repository from github, remove the package if already present, then install it to pip in local editable mode:

git clone [email protected]:bondhome/bond-cli.git
cd bond-cli
pip uninstall bond-cli
pip install -e "."

Now all changes made in your local copy of bond-cli will be reflected in the bond executable.

Release Procedure

To make a release, bump the version number in setup.py on trunk, then make an annotated tag

git tag -a "v1.8.7"

with a version matching that in setup.py. You'll be prompted to write some release notes. Alternatively, use the Github repository's releases interface to create a release.

Upon pushing the tag or publishing the release, CI will deploy to PyPi.

bond-cli's People

Contributors

bdraco avatar bradtotaro avatar chrismerck avatar fredericojordan avatar jdlambert avatar marciogranzotto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bond-cli's Issues

Logline needs a refactor, or to go away

  1. It doesn't guarantee in-order prints (as far as I can tell, it prints in the same order as print or logging would)
  2. It doesn't guarantee that your output will even be printed! You have to console_terminate and then join the console thread to flush it...

Consistent crash when requesting more than ~10 devices

To reproduce:

Have 10+ devices on your Bond, select the Bond, make sure the token's right, and python -m bond devices.

... first 10 devices correctly populate the table  ...
|ZZCC65335       |502395a4        |ten             |                |
|ZZCC65335       |09d7c3f4        |?               |?               |
|ZZCC65335       |0cba6a43        |?               |?               |
|ZZCC65335       |4f1b3765        |?               |?               |
|ZZCC65335       |77d0c266        |?               |?               |
---------------------------------------------------------------------
HTTPConnectionPool(host='192.168.2.226', port=80): Max retries exceeded with url: /v2/devices/09d7c3f4 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x10f706cc0>, 'Connection to 192.168.2.226 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='192.168.2.226', port=80): Max retries exceeded with url: /v2/devices/0cba6a43 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x10f731198>, 'Connection to 192.168.2.226 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='192.168.2.226', port=80): Max retries exceeded with url: /v2/devices/4f1b3765 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x10f720748>, 'Connection to 192.168.2.226 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='192.168.2.226', port=80): Max retries exceeded with url: /v2/devices/77d0c266 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x10f7202e8>, 'Connection to 192.168.2.226 timed out. (connect timeout=2)'))

Few small behavior update requests

First of all, thank you for creating this CLI.
It is an enthusiast's dream to have this + local API to experiment with.

A few small behavior modifications for consideration:

  1. When only 1 Bond Bridge exists and no bond is currently selected, running bond discover or bond select (without any params) could subsequently prompt the user to select that lone bridge. If this is not desired, bond list could at least print a small helper message to remind the user about the select command if they have none selected.

  2. Output of bond list should show which Bond is currently selected.

  3. Running bond select without any params causes it to exit without error or any clarifying output. I believe it might be due to this if statement not having an else to handle the case where bond_id is not provided.

Please let me know if these types of items are worth bringing up in issues or not so I don't create noise for your team.

Somfy Blinds

Am considering a Bond hub but I need it to activate Somfy blinds. The Bond App says it does Somfy Blinds. Does the info for Somfy Blinds automatically come into bond-cli somehow. I know they have a rolling code so it seems the database needs to come into bond-cli somehow.
TIA for info.

Running any command throws an error the DB

Running any command throws an error on database.py.

$ python -m bond discover                                                                                                              [15:15:22]
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/marciorodrigues/Documents/Olibra/code/bond-cli/bond/__main__.py", line 6, in <module>
    app.run()
  File "bond/app.py", line 18, in run
    bond.database.load()
  File "bond/database/database.py", line 18, in load
    except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined

Support Python 2.7

Though it's no longer officially supported, it shouldn't be too hard to support Python 2.7 in this project. We aren't working with byte strings or using any exotic library, so I think it'd just be a matter of turning f-strings into the old-style % formatting and getting CI tests running for 2.7.

.

.

Support retrieving token via the API

Currently the only way to add a token is manually. This program should support

  1. GETting the token when unlocked
  2. PATCHing the token to unlocked if not unlocked (via the PIN), then GET the token, then re-locking it. Not possible on Snowbird unfortunately.

Data format

I am trying to do the following but do not understand what the data format is for the somfy sunsetter blinds.
bond signal --data ? --freq 433000.
returns HTTP 400 data does not match specified encoding (this changes depending on what I put in the ? obviously) example
{"put http://192.168.1.235/v2/devices/3c7e2a69/actions/close"}
where do I find the correct encoding format. tried the doc on http formats but I failed with those.

ultimately hoping to integrate bond hub into nymea as a plugin using bond-cli
.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.