https://github.com/mawalu/homeassistant-cli
Control your smart home from the terminal
https://github.com/mawalu/homeassistant-cli
cli home-assistant home-automation nodejs
Last synced: about 1 year ago
JSON representation
Control your smart home from the terminal
- Host: GitHub
- URL: https://github.com/mawalu/homeassistant-cli
- Owner: mawalu
- Created: 2017-09-21T12:56:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-06-04T20:53:47.000Z (about 5 years ago)
- Last Synced: 2024-11-14T13:13:21.847Z (over 1 year ago)
- Topics: cli, home-assistant, home-automation, nodejs
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 13
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# homeassistant-cli
A simple cli tool for [Home Assistant](https://home-assistant.io/) that uses [node-homeassistant](https://github.com/Mawalu/node-homeassistant).
## Installation
```shell
$ npm install -g homeassistant-cli
```
If there is an permission error you have to reconfigure npm or use sudo
## Usage
Call a service
```shell
$ hac call light turn_on
```
Add additional service data
```shell
$ hac call light turn_on --service-data '{"entity_id": "light.komode"}'
```
Query the state
```shell
$ hac state sun.sun
```
Subscribe to state changes
```shell
$ hac state -s sun.sun
```
## Additional parameters
Custom hostname, port and password
```shell
$ hac --ip 10.1.0.166 --port 80 --api-password "hunter4" state sun.sun
```
To find shorthands and some extra parameters use
```shell
$ hac --help
```
## Scripting example
You can use this to access Home Assistant from your scripts
```bash
#!/bin/bash
hac state -s light.komode | while read -r change; do
state=$(echo "$change" | jq ".new_state.state")
echo "Light is now $state"
done
```