Break functions into separate yaml file for re-useability #323
Replies: 11 comments 36 replies
-
|
Hi, Have you checked this? From 4:57~ or so 😊. Else I'll try and create a sample pack, at some point. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, I can see how you have broken out the views, which is the same as in my code above (well my code is slightly different, but you should be able to see I have some of the cards included in the same way). What I can't see is how to break out the Functions key, because the content of that isn't yaml, it is javascript and the ui editor doesn't seem to like me creating a file with just that content in, and I don't think you can do a include for something that isn't part of a list. interesting video though, because I ought to VS Code for editing, I use it a lot for integration development, but haven't for this work as yet. |
Beta Was this translation helpful? Give feedback.
-
|
hi, Many thanks in advance! So long |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Sorry, no idea |
Beta Was this translation helpful? Give feedback.
-
|
the question is still unanswered: this is not possible in floorplan.yaml: i want to have the rules per room (-> per file) in a folder Many thanks in advance ! |
Beta Was this translation helpful? Give feedback.
-
|
Report: Explanation: This is the content of the 'big' home.yaml named '_home.yaml': and this the content of the testing one, named home.yaml : You see, i did try everything, and after a change i always did restart home assistant... You can see, where i placed the rules folder. Its content, as you can see, only contains one file: The values are the same as in the 'big' yaml-file which works ! So, please, take the time to read every letter. It didn't work, it doesn't work, will it work ? [EDIT] i tried both variants... 1: 2nd: after every adjustment i restarted HA and clear the caches... Many thank in advance ! [EDIT 2] now i have: ... but didn't solve the problem... it does not work ! |
Beta Was this translation helpful? Give feedback.
-
|
It's STILL unanswered... |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Here's a way to separate rules into multiple files. Note that you'd place one rule in each file, in the example. This is not how you're able to break multiple functions, into separate files. I think you're able to adapt below solution, but I've not tested that. Your dashboard needs to be in YAML mode, for this to work. I've loaded case7 with the following yaml: - title: Case7
badges: []
cards:
- !include ../www/floorplan/discussions/case7/case7.yamlAnd here's case7: Here's the content of case7: This is tested on my latest Ha instance in Docker, and HAOS. As you can see, the case7 are located deep within the By opening case7.yaml, you'll find the following: type: vertical-stack
cards:
- type: markdown
content: >-
**Question**: How do I separate YAML files?
[Reference](https://github.com/ExperienceLovelace/ha-floorplan/discussions/323)
title: Case 7
- type: custom:floorplan-card
full_height: false
config:
stylesheet: /local/floorplan/discussions/case7/case7.css
image: /local/floorplan/discussions/case7/case7.svg
console_log_level: debug
defaults:
hover_action: hover-info
tap_action: more-info
rules: !include_dir_list my_floorplan_rulesHere I'm pointing to This is standard YAML handling, but I understand that it can be complex to figure out. So here's a full demo. I hope to find time to walk through this in a video, at some point. See the other answers for more content: #323 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
|
here is the answer i've been waiting for: |
Beta Was this translation helpful? Give feedback.















Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm planning on doing multiple floorplans for different buildings. I don't really want to build that into one massive floorplan on in one Lovelace View. For my first floorplan I've been trying to break out re-useable item into separate yaml files. In the most part I've achieved this using various types of include. The below shows my current structure for a single View.. Ideally I'd like to move the Functions out so they can be re-used. Is this feasible, I can't figure out the correct yaml.
Beta Was this translation helpful? Give feedback.
All reactions