forked from platypush/platypush
README.
- Added/restyled badges. - Added sections on the scripts directory and YAML `include` directive.
This commit is contained in:
parent
6de0b2e041
commit
baee33b88f
1 changed files with 74 additions and 8 deletions
82
README.md
82
README.md
|
@ -1,20 +1,22 @@
|
|||

|
||||
|
||||
[](https://ci-cd.platypush.tech/platypush/platypush)
|
||||
[](https://pypi.python.org/pypi/platypush/)
|
||||
[](https://git.platypush.tech/platypush/platypush/src/branch/master/LICENSE.txt)
|
||||
[](https://git.platypush.tech/platypush/platypush/issues)
|
||||
[](https://github.com/blacklight/platypush)
|
||||
[](https://github.com/blacklight/platypush)
|
||||
[](https://git.platypush.tech/platypush/platypush/commits/branch/master)
|
||||
[](https://git.platypush.tech/platypush/platypush/src/branch/master/CONTRIBUTING.md)
|
||||
[](https://matrix.to/#/#platypush:matrix.platypush.tech)
|
||||
[](https://lemmy.platypush.tech/c/platypush)
|
||||
[](https://matrix.to/#/#platypush:matrix.platypush.tech)
|
||||
|
||||
[](https://pypi.python.org/pypi/platypush/)
|
||||
[](https://git.platypush.tech/platypush/platypush/src/branch/master/CONTRIBUTING.md)
|
||||
[](https://git.platypush.tech/platypush/platypush/src/branch/master/LICENSE.txt)
|
||||
[](https://github.com/sponsors/blacklight)
|
||||
[](https://blog.platypush.tech)
|
||||
[](https://docs.platypush.tech)
|
||||
[](https://git.platypush.tech/platypush/platypush/wiki)
|
||||
[](https://git.platypush.tech/platypush/platypush/issues)
|
||||
[](https://github.com/sponsors/blacklight)
|
||||
[](https://paypal.me/fabiomanganiello)
|
||||
[](irc://platypush@irc.platypush.tech:6697)
|
||||
[](https://matrix.to/#/#platypush:matrix.platypush.tech)
|
||||
[](https://paypal.me/fabiomanganiello)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
|
@ -52,6 +54,8 @@
|
|||
* [Manual installation](#manual-installation-1)
|
||||
- [Post-installation](#post-installation)
|
||||
* [Configuration file](#configuration-file)
|
||||
+ [Scripts directory](#scripts-directory)
|
||||
+ [Splitting configuration on multiple files](#splitting-configuration-on-multiple-files)
|
||||
* [systemd service](#systemd-service)
|
||||
* [Redis](#redis)
|
||||
* [nginx](#nginx)
|
||||
|
@ -1011,6 +1015,68 @@ in the following way:
|
|||
virtual environment, `$XDG_CONFIG_HOME/platypush/config.yaml` will be used
|
||||
(defaults to `~/.config/platypush/config.yaml`).
|
||||
|
||||
#### Scripts directory
|
||||
|
||||
By default, any custom Python scripts will be searched under
|
||||
`<CONFDIR>/scripts`, where `<CONFDIR>` is the path to your `config.yaml`.
|
||||
|
||||
You can override it in your `config.yaml`:
|
||||
|
||||
```yaml
|
||||
scripts_dir: /path/to/custom/scripts
|
||||
```
|
||||
|
||||
Since everything under the scripts directory will be imported as a submodule,
|
||||
you can create your own libraries of scripts that can import other scripts:
|
||||
|
||||
```python
|
||||
# Content of scripts/music.py
|
||||
|
||||
from platypush import run
|
||||
|
||||
def music_play(plugin='music.mopidy', resource=None):
|
||||
run(f'{plugin}.play', resource)
|
||||
|
||||
# Content of scripts/lights.py
|
||||
|
||||
from platypush import run
|
||||
|
||||
def lights_toggle(plugin='light.hue', groups=('Living Room',)):
|
||||
run(f'{plugin}.toggle', groups=groups)
|
||||
|
||||
# Content of scripts/home.py
|
||||
|
||||
from platypush import procedure
|
||||
|
||||
from scripts.music import music_play
|
||||
from scripts.lights import lights_toggle
|
||||
|
||||
@procedure
|
||||
def at_home():
|
||||
music_play()
|
||||
lights_toggle()
|
||||
```
|
||||
|
||||
#### Splitting configuration on multiple files
|
||||
|
||||
The `config.yaml` file can become very complex, especially if you embed many
|
||||
hooks and procedures in it in YAML format.
|
||||
|
||||
To make the configuration more maintainable, and also to isolate modules that
|
||||
you can reuse across multiple instances, you can leverage the `include`
|
||||
directive:
|
||||
|
||||
```yaml
|
||||
# All paths are relative to config.yaml, or to the location of the current file
|
||||
include:
|
||||
- assistant.yaml
|
||||
- db.yaml
|
||||
- media.yaml
|
||||
- mqtt.yaml
|
||||
- sensors.yaml
|
||||
# ...
|
||||
```
|
||||
|
||||
### systemd service
|
||||
|
||||
If you installed Platypush from a system package manager then you'll also have
|
||||
|
|
Loading…
Add table
Reference in a new issue