Open ildar170975 opened 2 months ago
I'll see if I can support both mechanisms.
I thought I had to do one or the other but that doesn't seem to be the case.
Can you try b14 release. I added this config option to allow the old behaviour to work.
virtual:
yaml_config: True
You may have to delete the imported integration before restarting. Sorry for the awkwardness around this, I assumed you could only have 1 config mechanism or the other. It turns out that is not true.
@twrecked Sorry, I do not understand...
Assume before 0.9 there was this code in some "virtual_trackers.yaml":
device_tracker:
- platform: virtual
devices:
- name: virtual_tracker_1
peristent: True
location: home
which created device_tracker.virtual_tracker_1
.
In 0.9 to add this tracker I need to add a new entry in UI & import some "virtual.yaml" file (can have a diff. name):
version: 1
devices:
virtual_tracker_1:
- platform: device_tracker
name: virtual_tracker_1
Do yo mean that in 0.9 it is possible: -- either use the new way ("add entry" in UI -> import some "virtual.yaml") (and Docs are here) -- or keep using the old way - declaring sensors in yaml? (and Docs are here)
Are there any differences between "new" & "old" ways in terms of features?
I mean - will I still be able to define SAME functionality for light
(as example) if I prefer to use "old way" instead of "new way"?
Here is my test: Added this line in configuration.yaml (into some separate file in fact):
virtual:
yaml_config: True
Rebooted HA - and after reboot all entries became faulty:
and these errors in Log: 2024-08-23 23:44:02.795 ERROR (MainThread) [homeassistant.config] Invalid config for 'virtual' at conf/test/virtual/virtual.yaml, line 3: expected a dictionary for dictionary value 'virtual', got [{'yaml_config': True}], please check the docs at https://github.com/twrecked/hass-virtual/blob/master/README.md 2024-08-23 23:44:02.796 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration 'virtual': Invalid config.
In 0.9 you can mix both ways of defining devices. To clarify, I have the following config and it's working:
configuration.yaml; I just put it straight in this file.
virtual:
yaml_config: True
# later on I include with this...
device_tracker: !include device_trackers.yaml
_devicetrackers.yaml; which I load from configuration.yaml
.
- platform: virtual
devices:
- name: virtual_old_test
- name: virtual_old_test2
virtual-test.yaml; which I add in through the intergrations.
version: 1
devices:
virtual_tracker_1:
- platform: device_tracker
name: virtual_tracker_1
I'm guessing it's not parsing the yaml_config
piece. Can you show me how you include it, I might need to beef that up.
Can you show me how you include it, I might need to beef that up.
Thanks a lot for feedback! Initially this line
virtual:
yaml_config: True
was placed into some file "virtual.yaml" which is located in some "/config/conf" directory. This is a splitting-config configuration - there is a directive in "configuration.yaml":
homeassistant:
...
packages: !include_dir_named conf
But for testing I simply placed these lines into "configuration.yaml":
default_config:
homeassistant:
...
frontend:
...
lovelace: !include lovelace/lovelace.yaml
virtual:
yaml_config: True
And it causes the error:
This code was copy/pasted from Readme - and may be it contains some special char which causes the error? I deleted both lines & inputted everything again - same error.
Also, I re-checked myself - do not have any more occurrences of "virtual" keyword in config:
And one more riddle: added a yaml config for device_tracker
in some separate file:
device_tracker:
- platform: virtual
devices:
- name: virtual_tracker_1
peristent: True
location: home
and see more errors:
In 0.8.x there is a possibility to split a config - keep settings in different packages. For instance, I may keep some
device_tracker
entities in/config/folder_1/file_1.yaml
, otherdevice_tracker
entities - in/config/folder_2/file_2.yaml
. Just installed 0.9.x - and seems that all settings now have to be kept in ONE file. Do not find it convenient. Am I doing smth wrong?Probably I may create one more
virtual_test.yaml
and move there some entries (consider these entries as "test only entries") fromvirtual.yaml
and then ADD one more integration: but that means that I have TWO files which do not belong to any package: each file seems to be only used to import settings on a manual reloading an integration, files cannot be merged as a part of "splitting config".Some clarifications about "splitting config":
configuration.yaml
:conf
folder is located inside a/config
folder and contains a folder structure like:where a subfolder may contain other subfolders & yaml-files dedicated for separate tasks.
Btw, what is a meaning of having same
version
field in all these different yaml files?