Make ESPHome data dir configurable (#5417)

This commit is contained in:
Andrew Garrett 2023-09-24 19:34:37 +10:00 committed by GitHub
parent 518ecb4cc4
commit 3c7c4e1dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,7 @@ from esphome.coroutine import FakeEventLoop as _FakeEventLoop
# pylint: disable=unused-import
from esphome.coroutine import coroutine, coroutine_with_priority # noqa
from esphome.helpers import ensure_unique_string, is_ha_addon
from esphome.helpers import ensure_unique_string, get_str_env, is_ha_addon
from esphome.util import OrderedDict
if TYPE_CHECKING:
@ -558,6 +558,8 @@ class EsphomeCore:
def data_dir(self):
if is_ha_addon():
return os.path.join("/data")
if get_str_env("ESPHOME_DATA_DIR", None) is not None:
return get_str_env("ESPHOME_DATA_DIR", None)
return self.relative_config_path(".esphome")
@property