1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 07:12:21 +01:00

Read string of bool env and match against well known values (#5232)

This commit is contained in:
Jesse Hills
2023-08-11 16:20:58 +12:00
committed by GitHub
parent db9dc11022
commit a84365659b
2 changed files with 12 additions and 1 deletions

View File

@@ -144,7 +144,14 @@ def resolve_ip_address(host):
def get_bool_env(var, default=False):
return bool(os.getenv(var, default))
value = os.getenv(var, default)
if isinstance(value, str):
value = value.lower()
if value in ["1", "true"]:
return True
if value in ["0", "false"]:
return False
return bool(value)
def get_str_env(var, default=None):