Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
djw4 committed Nov 18, 2021
1 parent 73bd3ea commit de745de
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 9 deletions.
78 changes: 69 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,70 @@ and returns the metrics in a format suitable for consumption by

This is the recommended way to launch the service as it takes care of the dependencies for you.

First, update the `config/hubitat2prom.yml` file with the URL and access token for your MakerAPI. This can be found
in the MakerAPI settings on your Hubitat device.
First, retrieve your API token and API path from your Hubitat device. These will look something like;

- HE_URI: `http://<hubitat_hostname>/apps/api/26/devices`
- HE_TOKEN: `f4a20ab3-..-670f559be5a6`

Put these values into a new file named `.env` as below:

```
HE_URI=http://<hubitat_hostname>/apps/api/26/devices
HE_TOKEN=f4a20ab3-..-670f559be5a6
```

Next, run the following command to start the container:

`docker run --privileged -v "$(pwd)"/config:/app/config -p 5000:5000 ghcr.io/budgetsmarthome/hubitat2prom:sha-dba43ca`
```bash
docker run --rm --env-file .env -p 5000:5000 ghcr.io/budgetsmarthome/hubitat2prom:latest
```

You can also use docker-compose if you prefer:

```bash
$ cat <<EOF >docker-compose.yaml
---
version: '3'
services:
hubitat2prom:
image: ghcr.io/budgetsmarthome/hubitat2prom:latest
env_file:
- '.env'
ports:
- 5000:5000
EOF

$ docker-compose run --rm hubitat2prom
```

This will start the container listening on your local machine on port 5000, and you can visit
[http://localhost:5000/metrics](http://localhost:5000/metrics) to confirm that the metrics are coming through.

You can additionally visit
[http://localhost:5000/info](http://localhost:5000/info) to view basic
configuration infomation and check the connection status with the Hubitat API.

Once you've confirmed this, you can move on to configuring Prometheus.

## Local Installation

If you want to run this service without installing from Docker, then the steps are as follows:
If you want to run this service without installing from Docker, then the steps
are as follows:

1. Install `pipenv` for python3; `python3 -m pip install pipenv`.
2. Create the `.env` file as per the instructions above.
3. Run the following command: `pipenv run app`

1. Configure `config/hubitat2prom.yml` as documented in the `Docker` section of this readme.
2. Install the requirements from `requirements.txt` into an appropriate virtual environment
3. Run the following command: `export FLASK_APP=app;export HEPROM_CFG_FILE="path/to/config/file" && flask run`
A Python virtual environment will be created automatically, if the service has
never run before and then pipenv will also automatically install all of the
dependencies that the service requires to run. After this is completed the
application will start. If you stop and start the application, the dependencies
will persist unless otherwise removed.

As with the docker container, your service will now be exposed on port 5000, and you can test it is working
by visiting [http://localhost:5000/metrics](http://localhost:5000/metrics) in a browser.
As with the docker container, your service will now be exposed on port 5000, and
you can test it is working by visiting
[http://localhost:5000/metrics](http://localhost:5000/metrics) in a browser.

## Prometheus

Expand All @@ -49,6 +91,24 @@ Add the following to the bottom of your Prometheus Outputs:

Prometheus will now scrape your web service every 30 seconds to update the metrics in the data store.

## InfluxDB

Configuring InfluxDB is equally as simple.

Visit the InfluxDB admin console, then navigate to;
`Data --> Scrapers --> 'Create Scraper'`

Provide a name to your scraper, assign a bucket where the data should be stored,
then provide the path to the metrics path as listed above, substituting your
localhost address with the IP address/hostname of the server running the
container.

![InfluxDB - Create Scraper](/screenshots/influxdb-scraper.jpg)

Metrics data from your new scraper is now available to be queried:

![InfluxDB - Query Metrics](/screenshots/influxdb-query.jpg)

# Collected Metrics

Hubitat2Prom is capable of collecting any of the metrics that Hubitat exposes via the MakerAPI.
Expand Down
Binary file added screenshots/influxdb-query.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/influxdb-scraper.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de745de

Please sign in to comment.