hass-cli 0.5: Area, Device Registry and event CLI
With Home Assistant 0.87 out we got Areas and Device Registry UI thus
it is time to do a release of hass-cli
that allows you to operate on these in a terminal.
This release adds the following features:
- Area
list
,create
,delete
, andrename
- Device
list
andassign
- Event
watch
To get it run:
$ pip3 install homeassistant-cli
And once you have configured some of the new things you can like:
Create an area:
$ hass-cli area create Attic
- id: 1
type: result
success: true
result:
area_id: 83977bdb16524579a856560925a791a7
name: Attic
List all your areas:
$ hass-cli area list
ID NAME
295afc88012341ecb897cd12d3fbc6b4 Bathroom
9e08d89203804d5db995c3d0d5dbd91b Winter Garden
8816ee92b7b84f54bbb30a68b877e739 Office
e6ebd3e6f6e04b63a0e4a109b4748584 Kitchen
f7f5412a9f47436da669a537e0c0c10f Livingroom
bc98c209249f452f8d074e8384780e15 Hallway
83977bdb16524579a856560925a791a7 Attic
List devices matching a pattern:
$ hass-cli device list "Kitchen.*Light*"
ID NAME MODEL MANUFACTURER AREA
f9cad07069c74d519fbe84811c91f1fb Kitchen Light 2 LCT003 Philips e6ebd3e6f6e04b63a0e4a109b4748584
d02ec64623ae4407a80b903cbc061511 Kitchen Light 3 LCT003 Philips e6ebd3e6f6e04b63a0e4a109b4748584
820c9e511fce42ea92b228c18710aa56 Kitchen Light 1 LCT003 Philips e6ebd3e6f6e04b63a0e4a109b4748584
417dd42c0c764765aa29580d77b8b7ad Kitchen Light 5 LCT003 Philips e6ebd3e6f6e04b63a0e4a109b4748584
Like with entity list
you can filter and pipe results to get interesting things.
How about a inventory count?
$ hass-cli --no-headers --columns manufacturer,model device list | sort | uniq -c | sort -nr
10 IKEA of Sweden TRADFRI bulb GU10 WS 400lm
8 Philips SML001
7 LUMI lumi.sensor_magnet.aq2
6 Sonos Play:1
6 Philips LTW012
6 Philips LCT003
6 Philips Hue color spot
6 Philips Hue ambiance candle
5 Philips LWG001
5 Philips LCT012
5 Philips Hue color candle
5 IKEA of Sweden TRADFRI bulb E14 W op/ch 400lm
4 Sonos One
4 Philips RWL021
4 Philips Hue color lamp
4 IKEA of Sweden TRADFRI remote control
3 Philips Hue lightstrip plus
3 OSRAM Color temperature light
3 LUMI lumi.vibration.aq1
3 IKEA of Sweden TRADFRI transformer 30W
....
And then my favorite feature, assign of area to a device:
$ hass-cli device assign Kitchen "Kitchen Light 2"
or even more powerful, bulk-assign to any entity matching a certain pattern:
$ hass-cli device assign --match "Kitchen" Kitchen
Successfully assigned 'Kitchen' to 'Kitchen'
Successfully assigned 'Kitchen' to 'Kitchen table left'
Successfully assigned 'Kitchen' to 'Kitchen table right'
Successfully assigned 'Kitchen' to 'Kitchen left middle at window'
Successfully assigned 'Kitchen' to 'Kitchen front right at fridge'
Successfully assigned 'Kitchen' to 'Kitchen left back at hub'
Successfully assigned 'Kitchen' to 'Kitchen left back at bar'
Successfully assigned 'Kitchen' to 'Kitchen right back at sink'
Successfully assigned 'Kitchen' to 'Kitchen right middle at oven'
Successfully assigned 'Kitchen' to 'Kitchen Light 2'
Successfully assigned 'Kitchen' to 'Kitchen Light 3'
....
And finally as a little bonus feature you can now watch the event bus from the CLI:
All events:
$ hass-cli event watch
or specific events:
$ hass-cli event watch call_service
At the moment the output is raw JSON, that will improve in a future release.
The full change list including bugfixes from community is as follows:
What’s Changed
New features:
Bug fixes:
- fix(entity): honor –columns in entity get 67397a1
@maxandersen - Fix result reporting from service calls 14fc952
@maxandersen - Remove pyaml and move to ruamel only for yaml df9f8c2
@maxandersen
Minor fixes:
- fix: release 0.5.0 version 200a099
@maxandersen - fix: be pep440 complant 98320f8
@maxandersen - fix: fix lint errors eca26fa
@maxandersen - fix: fix lint errors ffd2369
@maxandersen - enable deploy of git timestamped build 4b27a65
@maxandersen - Merge branch ‘master’ into dev caaf7b1
@maxandersen - add docker reference d3b64e8
@maxandersen - docs: add docs for area, device and event watch ee4f74a
@maxandersen - Make dockerfile build from source + entrypoint b7f8764
@maxandersen - Fix lint issue 8bb0c9e
@fabaff - Fix lint issues 58fdc83
@fabaff - fix bad typing 499b544
@maxandersen - fix editor formatting 86d9bf8
@maxandersen - Fix version 3765a03
@maxandersen - Fix version marker edbe4bf
@maxandersen
Have fun!