I know you can customize entities in a package. Can packages also place an entity in a card and in a view (tab)? It seem it would be very useful (in some cases) to have packages be more “all inclusive” to include UI placement.
Has anyone done something similar and can point me to an example? otherwise I would like to know if others are interested in such a thing and I will write an issue in GitHub for this.
Read here:
and
That was some time ago, and i don’t think that packages will get some improvements.
If you want to file an issue, good luck!
No. Putting the lovelace yaml file in the packages dir does not work. When HA checks the configuration it parses all files as components and states invalid configuration.
This would be awesome for creating self contained subfolders for sharing (that the end user could then override if desired). Plus it just makes organize sense (to me).
And I think it could be done fairly easy. I see 2 things that would need to be done. Make the packages check function ignore any files beginning with “ui_” and 2) have a routine that modifies the ui_lovelace.yaml file to add and remove !include lines for item under the /config/packages dir.
No need to name them *.yaml.
views:
- !include packages/covers/ui_test.ui
ui_test.ui
title: Example
cards:
# The markdown card will render markdown text.
- type: markdown
title: Lovelace
content: >
Welcome to your **Lovelace UI**.
Awesome. That works. Very nice. Thanks
since the ui / package theory was proven to work, I wrote a python script to do the second part I mentioned before which scans the packages directory and automatically update the ui-lovelace.yaml file. Put this as triggered from home assistant startup and never have to worry about updating ui from packages again
import os
configDir = 'config'
packageDir = 'packages'
uiFileType = '.ui'
foundFiles = []
# Scan packages directory for ui files as defined
for root, subdirs, files in os.walk(packageDir):
for aFile in files:
if aFile.endswith(uiFileType):
foundFiles.append(' - !include \'/' + configDir + '/' + os.path.join(root, aFile) + '\'\n')
foundFiles.sort()
# Parse lovelace file, insert found packages files, remove old ones
with open('ui-lovelace.yaml') as file_in:
with open('ui-lovelace.tmp', 'w') as file_out:
for line in file_in:
if line.startswith('views:'):
# dump found packages here
file_out.write(line)
for item in foundFiles:
file_out.write(item)
elif line.startswith(' - !include \'/' + configDir + '/' + packageDir):
# ignore line
pass
else:
file_out.write(line)
os.remove('ui-lovelace.yaml')
os.rename('ui-lovelace.tmp', 'ui-lovelace.yaml')
I tried to make it fairly simple for someone to change the packages directory and ui file extension they might prefer. Also needs to be run from same dir as ui-lovelace.yaml or change path location as needed.
Enjoy!