1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-16 00:33:54 +01:00

Use /data directory for .esphome folder when running as HA add-on (#5374)

This commit is contained in:
Jesse Hills
2023-09-12 09:26:48 +12:00
committed by GitHub
parent 10eee47b6b
commit fe81bcc003
11 changed files with 53 additions and 43 deletions

View File

@@ -554,6 +554,12 @@ class EsphomeCore:
def config_dir(self):
return os.path.dirname(self.config_path)
@property
def data_dir(self):
if is_ha_addon():
return os.path.join("/data")
return self.relative_config_path(".esphome")
@property
def config_filename(self):
return os.path.basename(self.config_path)
@@ -563,7 +569,7 @@ class EsphomeCore:
return os.path.join(self.config_dir, path_)
def relative_internal_path(self, *path: str) -> str:
return self.relative_config_path(".esphome", *path)
return os.path.join(self.data_dir, *path)
def relative_build_path(self, *path):
path_ = os.path.expanduser(os.path.join(*path))
@@ -573,13 +579,9 @@ class EsphomeCore:
return self.relative_build_path("src", *path)
def relative_pioenvs_path(self, *path):
if is_ha_addon():
return os.path.join("/data", self.name, ".pioenvs", *path)
return self.relative_build_path(".pioenvs", *path)
def relative_piolibdeps_path(self, *path):
if is_ha_addon():
return os.path.join("/data", self.name, ".piolibdeps", *path)
return self.relative_build_path(".piolibdeps", *path)
@property