bahamas10 / hueadm

A command line management interface to Philips hue
206 stars 13 forks source link

Allow groups to be specified by name #3

Closed tremby closed 6 years ago

tremby commented 6 years ago

Rather than having to remember which group is which, or refresh my memory by running hueadm groups before changing the state of a group, it would be very nice to be able to specify a group by name. For example:

hueadm group lounge on

You could check to see if the argument is numeric (/^\d+$/ would do it) and treat it as an ID if so, otherwise look up the ID of a group with the same name.

It might then make sense to offer the same feature for lights too, or other commands, though groups are more valuable to me personally.

bahamas10 commented 6 years ago

👍

bahamas10 commented 6 years ago
dave - meka linux ~/dev/hueadm (git:master) $ npm publish
+ hueadm@1.1.0
bahamas10 commented 6 years ago

Example runs. Because group names are not guaranteed to be unique I have made it so an error is thrown if more than 1 group with the same name is found.

$ ./bin/hueadm group foo
error: Error: Multiple groups "foo" found
$ ./bin/hueadm group bar
error: Error: No group "bar" found
$ ./bin/hueadm group 'Garage Inside'
name: 'Garage Inside'
lights:
    - '20'
    - '21'
    - '22'
    - '23'
type: Room
state:
    all_on: false
    any_on: false
class: Carport
action:
    on: false
    bri: 254
    alert: none
tremby commented 6 years ago

Excellent. It's working for me. Thanks! This is a major usability enhancement in my eyes.