Default to recorder db for SQL integration (#85436)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
2f4e9c8ef3
commit
afa58b80bd
9 changed files with 120 additions and 54 deletions
12
homeassistant/components/sql/util.py
Normal file
12
homeassistant/components/sql/util.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
"""Utils for sql."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.recorder import get_instance
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
def resolve_db_url(hass: HomeAssistant, db_url: str | None) -> str:
|
||||
"""Return the db_url provided if not empty, otherwise return the recorder db_url."""
|
||||
if db_url and not db_url.isspace():
|
||||
return db_url
|
||||
return get_instance(hass).db_url
|
Loading…
Add table
Add a link
Reference in a new issue