Closed Tony763 closed 9 months ago
Changing def setup(...
to async def async_setup(....
allow integration to start without error. But no configuration from configuration.yaml
is added. HA only complain about non supported configuration entries in platforms (light, switch,..)
Was this seen on an upgrade?
edit: just checking the code, it had to have been...
Yes.
Note: I use it as cloned repository so upgrade was done by git pull
and ha restart.
Thanks for the confirmation. I'll look into this.
The def setup
call is just used to trigger the upgrade, subsequent starts will not get to the async_create_task
code which is why I'm not seeing it here. I'll revert here and fix it.
It also explains why none of your config made it in the upgrade.
I just merged in your fix.
If you didn't delete your old config and you want to try the upgrade again you should be able to:
Settings -> Integrations
custom_components
and restart HAcustom_components
and restart HAJust tried. Integration starts, but virtual.yaml
was not created and no components were moved.
I'll give it a go here.
It worked here for me. Assuming you currently have the latest virtual component installed, these are the steps I took:
custom_components/virtual
directory and copied over the previous version but HACS should work as wellSettings -> Integration
pagevirtual.yaml
and .storage/virtual.meta.json
custom_components/virtual
directory and copied over the new version but HACS should work as wellAnd virtual.yaml
was created.
I recommend turning on debug for the virtual component before doing this, that way you can poke around in the logs and make sure it's doing the work we expect it to.
logger:
default: info
logs:
custom_components.virtual: debug
You should see lines like this appearing in the log:
2024-02-03 15:02:16.367 DEBUG (MainThread) [custom_components.virtual] importing a YAML setup
..
2024-02-03 15:02:16.396 INFO (MainThread) [custom_components.virtual.cfg] devices={..your devices here...}]}
2024-02-03 15:02:16.396 DEBUG (MainThread) [custom_components.virtual.cfg] uid=steve_presence
2024-02-03 15:02:16.396 DEBUG (MainThread) [custom_components.virtual.cfg] eid=binary_sensor.virtual_steve_presence
... more devices here
Hopefully that brings your config in.
Found it:
2024-02-04 00:28:36.515 DEBUG (MainThread) [custom_components.virtual.cfg] couldn't save user data [Errno 2] No such file or directory: '/config/virtual.yaml'
2024-02-04 00:28:36.516 DEBUG (MainThread) [custom_components.virtual.cfg] no meta data yet [Errno 2] No such file or directory: '/config/.storage/virtual.meta.json'
These two should be ERROR
not DEBUG
:slightly_smiling_face:
Configuration try to write to nonexist directory /config
as my HA configuration is inside /home/homeassistant/.homeassistant/
directory.
btw, isn't aarlo
typo in _LOGGER.debug(f"importing aarlo YAML {import_data}")
?
I see, they are hardcoded:
IMPORTED_YAML_FILE = "/config/virtual.yaml"
META_JSON_FILE = "/config/.storage/virtual.meta.json"
To get actual config path, You could use hass.config.path())
function in setup
:
async def async_setup(......
_LOGGER.error(hass.config.path())
_LOGGER.error(hass.config.path(".storage"))
Returns:
I was just going to say this was down to my naivety!
I'll update them later this evening.
Sorry this is a bit of pain but can you try again?
I've tested this on my set up but I just have everything under /config
.
No problem, last change works. virtual.yaml
was created and everything was importet. Thank You
Hi @twrecked, just started to try new 0.9.x version (current master). Following error occurred immediately at begging. Configuration is from pre-0.8.x version. Hass version 2024.1.5