zenware / huehue

Python API Client for controlling a Philips Hue Bridge/Lights
MIT License
2 stars 0 forks source link

What should the CLI Interface on this look like? #1

Open zenware opened 4 years ago

zenware commented 4 years ago

Mainly this is for me to have any tool at all that lets me play with the Hue API in a convenient way but I figured why not also include a CLI to control the lights, should be fun.

My initial thoughts are something like the following

huehue list lights, huehue light 1 set color <X>, huehue light 1 set brightness 50; or huehue lights set {'bri': 100, 'hue': 65000}

Commentary from ssh.chat

๐Ÿฎ shazow: zenware: looks ok but -1 to json in cli args
๐Ÿฎ shazow: you prolly want more flags too
๐Ÿฎ shazow: or something like `huehue set light=1 brightness=50`
 * biglad left. (After 2.2 hours)
๐Ÿฎ shazow: or maybe a bulk filter interface would be more useful...
๐Ÿฎ shazow: something like "set all lights with brightness <50 to 75"
๐Ÿฎ shazow: but from a cli interface
๐Ÿฎ shazow: huehue COMMAND FILTER VALUES...
๐Ÿฎ shazow: huehue get 'brightness<50'
๐Ÿฎ shazow: huehue set 'brightness<50' brightness=100
๐Ÿฎ shazow: huehue set 'room==living room' brightness==50 'color=#aabbcc'
๐Ÿฎ shazow: basically comparisons (>, ==, etc) are filters, assignments are values
๐Ÿฎ shazow: i guess at that point you want a little logic dsl
๐Ÿฎ shazow: to do operators
๐Ÿฎ shazow: wonder what a good fit for that would be
shazow commented 4 years ago

Thanks for transcribing my :custard: lol

zenware commented 4 years ago

Something possibly helpful is that lights have groups

Unfortunately the API docs require login: https://developers.meethue.com/develop/hue-api/

GET Requests to /api/<username>/groups return a response like

{
  "1": {
    "name": "Living Room",
    "lights": [1, 2, 5],
    ...
   },
  "..n": {...}
}

So for actions, state-set, and transitions that affect multiple lights at a time you could reference groups by name.

$ huehue light list # Does listing out lights make sense? Is there anything useful other than number to present here?
1, 2, 3, 4, 5, 6, 7
$ huehue group list
There are currently no groups.
$ huehue group add "Living Room" 1,2,5
Added group 1, Living Room with lights 1, 2, and 5
$ huehue group "Living Room" set color=red # There is no built in color DB, this would be some user configured thing in a file.
zenware commented 4 years ago

I suppose I should mention, complete control isn't really required in the CLI, that's what the "library" is for, but I also want a little bit of control in the CLI for playing around a bit and testing some conceptual things. Really the full extent of the CLI power that I care about is being able to address individual lights or light groups/zones and supply state options to those individual lights, groups, zones, or "all lights". Doing things like turning on colorloop mode on and off, setting hue/sat/brightness values, maybe "scene triggering", turning lights on and off, and choosing the transition time between states. Perhaps also shortlist of custom modes like "party mode" or something similar.

Anything more sophisticated, such as schedules, sensors, rules, should be relegated to manual control and further development projects.

zenware commented 4 years ago

I think for now I'm going to try and implement listing lights and some details about their state, bridges, and groups, and allow some flag-based control of properties on the lights.

I may also try to add a color database, probably in the config file for this project.

zenware commented 4 years ago

Example Usage:

    huehue OBJECT COMMAND [IDENTIFIER] [OPTION...]

    Object type are [light, group, bridge, color]
    Commands are [list, add, delete, set, help]
    Identifiers are either the ID or a User friendly name of the object in question
    Options are any attribute on that object or that can affect the behavior of the command.

    huehue light set 2 hue=25000
    huehue light set "Master Bedroom Lamp" bri=40