Update 2019-02-04: 0.4 was released last week that changes the command structure and make output default to tables so the video and some of the commands have changed. See https://github.com/home-assistant/home-assistant-cli for updated docs.

When I started using Home Assistant I quickly got really frustrated having to wait for the browser to connect, click through and do operations - I really could use a command line tool; I couldn’t find one so I made one!

While working on it I found out that @fabaff had done early work in https://github.com/home-assistant/home-assistant-cli and he was so friendly to give commit acces thus this is now being actively developed next to Home Assistant itself.

Its under heavy development, thus its still considered Alpha (things will change/break), but we are looking for early feedback!

To try out latest release:

$ pip install homeassistant-cli

After this hass-cli should be available to you. Make sure hass-cli is at least 0.2 or above as 0.1 does not work with recent Home Assistant versions.

$ hass-cli --version hass-cli, version 0.2.0.dev0

Setup environment with autocompletion:

$ export HASS_SERVER=https://hassio.local:8123 $ export HASS_TOKEN=<long lasting token from /profile> $ source <(hass-cli completion bash)

And then off you go.

There are more complete examples at https://github.com/home-assistant/home-assistant-cli, but a few highlights are:

Browse your entities with TAB completion:

$ hass-cli entity get light.<TAB> light.kitchen_light_5 light.office_light light.basement_light_4 light.basement_light_9 light.dinner_table_light_4 light.winter_garden_light_2 light.kitchen_light_2 light.kitchen_table_light_1 light.hallroom_light_2 light.basement_light_5 light.basement_light_10 light.dinner_table_wall_light light.winter_garden_light_4

Open a Map for your location:

$ hass-cli map

Toggle entites:

$ hass-cli --output=table entity toggle light.office_light ENTITY DESCRIPTION STATE ------------------------------ ------------- ------- group.office_lights_motionview office lights on light.office_light Office Light on group.all_lights all lights on

and a bunch more - see https://github.com/home-assistant/home-assistant-cli for details.

I got a lot more ideas I want to add, some/most of them listed at https://github.com/home-assistant/home-assistant-cli/issues.

If you have additional ideas or find bugs do go there and let me know.

Thanks to @fabaff for help, @flowolf for initial feedback and for @frenck being courageous and already included early version of hass-cli in the Hass.io SSH addon - so you can try it out there too (but it will be a few releases behind).