Lovelace UI module and migration tool for Python
- pip3
- PyYAML
- requests
On Raspbian Stretch pip3 is not installed by default. To install pip3, run:
$ sudo apt-get install python3-pipAfter you clone this repository, you can run:
$ pip3 install -r requirements.txtTo install without the requirements.txt file:
$ pip3 install "requests>=2.14.2" "pyyaml>=3.11,<4"$ python3 lovelace_migrate.py [-h] [-o <file>] [-p [<password>]] [-t <title>]
[--debug] [--dry-run]
[<api-url|file>]If you're running Hass.io, you can run the script with the Community SSH add-on.
$ python3 lovelace_migrate.py -o /config/ui-lovelace.yamlYou will be prompted to enter your API password if you use -p
without specifying a password.
$ python3 lovelace_migrate.py -p http://192.168.1.100:8123/apiThe migration script can use a remote URL to pull the entity configuration. It is only recommended to use this option if your server has HTTPS enabled.
$ python3 lovelace_migrate.py -p https://your.domain.com/apiIt is not recommended to enter your password into the command because it is possible that it will be stored in your command history.
$ python3 lovelace_migrate.py -p YOUR_API_PASSWORD http://192.168.1.100:8123/apiThis will attempt to connect to your Home Assistant server without a password, and if it requires authentication you will be prompted to enter your password.
$ python3 lovelace_migrate.py -p YOUR_API_PASSWORD http://192.168.1.100:8123/apiNote: If you have login_attempts_threshold set to a
low number, it is possible that you might ban yourself by using the password
detection method.
A local JSON file can be used as the configuration input.
$ python3 lovelace_migrate.py -t Home states.jsonYou can even use the contents of stdin as the configuration for the script:
$ cat entities.json | python3 lovelace_migrate.py -t Home -$ curl -sSL -X GET \
-H "x-ha-access: YOUR_PASSWORD" \
-H "content-type: application/json" \
http://192.168.1.100:8123/api/states \
| python3 lovelace_migrate.py -| Short | Long | Default | Description |
|---|---|---|---|
-h |
--help |
show this help message and exit | |
-o |
--output |
ui-lovelace.yaml |
write output to <file> |
-p |
--password |
Detect/Prompt | Home Assistant API password |
-t |
--title |
Home |
title of the Lovelace UI |
--debug |
set log level to DEBUG | ||
--dry-run |
do not write to output file | ||
<api-url> |
Home Assistant API URL (ending with /api) |
||
<file> |
local JSON file containing dump from /api/states |
This argument will show the usage help and immediately exit.
The Lovelace UI YAML output will be written to this file. A backup will automatically be created.
Home Assistant API password. If this argument is enabled without specifying a password, you will be prompted to enter your password.
This is the title that you wish to be set for the Lovelace UI. The default is Home.
Enabling this allows you to see more specific logging output.
No files are written to/moved when this argument is enabled. Instead, the Lovelace UI YAML is output to the console.
It is recommended to use your API URL as the input when migrating to Lovelace
UI. This URL usually ends with /api, and commonly looks something like:
http://192.168.1.100:8123/apihttps://your.domain.com/apihttps://my-domain.duckdns.org/api
You can also load your configuration from a local file. This file must contain
the same format as the data from /api/states.
*Note: Use - as the <api-url|file> to load configuration from stdin.