From 6765c9510f86a958faa1e671ae683c5ef5277cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Tue, 6 Aug 2019 20:18:22 +0200 Subject: [PATCH] Add readme --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c144330 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# lovelace_gen + +`configuration.yaml` +```yaml +lovelace_gen: +``` + +Regenerate by using the "Refresh" function in lovelace. + +![refresh](https://user-images.githubusercontent.com/1299821/62565489-2e655780-b887-11e9-86a1-2de868a4dc7d.png) + +## Example +`ui_lovelace.yaml` +```yaml +resources: + # When you regenerate, the browser cache for this file will be invalidated + - url: !file /local/card-mod.js + type: module +... + +views: + - ! include lovelace/my_cool_view.yaml +``` + +`lovelace/my_cool_view.yaml` +```yaml +{% set my_lights = ["light.bed_light", "light.kitchen_lights", "light.ceiling_lights"] %} +title: My view +cards: + - type: entities + entities: +{% for light in my_lights %} + - {{ light }} +{% endfor %} + + # Include files with arguments + # NB: JSON format for arguments + # And NO SPACE after the colons! + - !include floorplan.yaml {"lamps":"true", "title":"With Lamps"} + +# Use this if you want lovelace_gen to ignore the jinja +{% raw %} + - type: markdown + content: | + # Coming soon(?) + + A built-inmarkdown card with jinja templating. + So I can tell that my light is {{ states('light.bed_light') }}! +{% endraw %} + + - !include floorplan.yaml {"title":"No lights"} +``` + +`lovelace/floorplan.yaml` +```yaml +{% macro lamp(entity, x, y) -%} +{% if lamps %} +- type: state-icon + entity: {{ entity }} +{% else %} +- type: custom:gap-card +{% endif %} + style: + left: {{ x }}% + top: {{ y }}% +{%- endmacro %} + +type: picture-elements +title: {{ title }} +image: https://placekitten.com/800/600 +elements: + {{ lamp('light.bed_light', 25, 25) }} + {{ lamp('light.kitchen_lights', 50, 25) }} + {{ lamp('light.ceiling_lights', 50, 50) }} +``` + +![lovelace_gen](https://user-images.githubusercontent.com/1299821/62565373-ecd4ac80-b886-11e9-9dcb-c41b43027b2b.png) +