2025-01-18 11:44:18 -08:00
|
|
|
# HomeAssistant command line scripts
|
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
|
|
|
This repository contains scripts for the `command_line` integration in HomeAssistant.
|
|
|
|
The scripts access external resources, typically via the Internet, and print various
|
|
|
|
values as elements of `data` in a JSON output. The output can be captured by a
|
|
|
|
HomeAssistant "sensor" and then included into individual sensors.
|
|
|
|
|
|
|
|
Scripts include:
|
|
|
|
|
|
|
|
- `davisconditions.py`: weather conditions from a [Davis WeatherLink Live](https://www.davisinstruments.com/pages/weatherlink-live) (local network)
|
|
|
|
- `riverconditions.py`: river conditions from the [USGS National Water Information System](https://waterdata.usgs.gov/)
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
The scripts can be installed into any directory that HomeAssistant can run scripts from.
|
|
|
|
Make sure they're executable (*e.g.*, `chmod 755 riverconditions.py`).
|
|
|
|
|
|
|
|
The first line of the scripts should be changed to:
|
|
|
|
```
|
|
|
|
#!/path/to/homeassistant/python3
|
|
|
|
```
|
|
|
|
where the path is for the Python executable used by HomeAssistant. This might be
|
|
|
|
`/usr/bin/python3`, or it might be something like `/home/homeassistant/bin/python3`.
|
|
|
|
|
|
|
|
The only non-standard package that's needed is `requests`, though you shouldn't need to
|
|
|
|
install it if you're using HomeAssistant's `python3` executable, since HomeAssistant already
|
|
|
|
installs `requests`.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Running the scripts
|
|
|
|
|
|
|
|
Each script takes a single argument that specifies the resource being accessed. `riverconditions.py`
|
|
|
|
takes the station identifier, which is an 8-digit number. For example, to get statistics for the
|
|
|
|
Rogue River at Raygold near Central Point, OR, you would run:
|
|
|
|
```
|
|
|
|
riverconditions.py 14359000
|
|
|
|
```
|
|
|
|
because the station identifier is 14359000. Note that this identifier is part of the URL for the
|
|
|
|
[(human-readable) station page](https://waterdata.usgs.gov/monitoring-location/14359000/),
|
|
|
|
and is prominently listed on the page as well.
|
|
|
|
|
|
|
|
To get data from a [Davis WeatherLink Live](https://www.davisinstruments.com/pages/weatherlink-live),
|
|
|
|
run `davisconditions.py` as follows:
|
|
|
|
```
|
|
|
|
davisconditions.py 192.168.1.200
|
|
|
|
```
|
|
|
|
where `192.168.1.200` is the address of the WeatherLink Live device. You can use the IP address or,
|
|
|
|
if you've assigned a DNS name to the device, the DNS name. This address must remain constant
|
|
|
|
across reboots of the device and/or router, so you may want to use a static IP address or reserve
|
|
|
|
an address in your DHCP server.
|
|
|
|
|
|
|
|
### HomeAssistant configuration
|
2025-01-16 12:02:12 -08:00
|
|
|
|