-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined variable when running as standalone in 0.8.2 #225
Comments
You need to pass the environment variable |
This is interesting. Standalone should not be asking for options file at all. I'll see if I can check this today. |
From the code if not using the |
I think this Is an error of mine from the last commit. (The data path commit) |
if __name__ == "__main__":
# Parsing arguments
parser = argparse.ArgumentParser()
parser.add_argument('--url', type=str, help='The URL to your Home Assistant instance, ex the external_url in your hass configuration')
parser.add_argument('--key', type=str, help='Your access key. If using EMHASS in standalone this should be a Long-Lived Access Token')
parser.add_argument('--addon', type=strtobool, default='False', help='Define if we are usinng EMHASS with the add-on or in standalone mode')
parser.add_argument('--no_response', type=strtobool, default='False', help='This is set if json response errors occur')
args = parser.parse_args()
use_options = os.getenv('USE_OPTIONS', default=False)
options = None
#Obtain url and key from ENV or ARG (if any)
hass_url = os.getenv("EMHASS_URL", default=args.url)
key = os.getenv("SUPERVISOR_TOKEN", default=args.key)
if hass_url != "http://supervisor/core/api":
key = os.getenv("EMHASS_KEY", key)
#If url or key is None, Set as empty string to reduce NoneType errors bellow
if key is None: key = ""
if hass_url is None: hass_url = ""
# Define the paths
if args.addon==1:
OPTIONS_PATH = os.getenv('OPTIONS_PATH', default="/app/options.json")
options_json = Path(OPTIONS_PATH)
CONFIG_PATH = os.getenv("CONFIG_PATH", default="/app/config_emhass.yaml")
DATA_PATH = os.getenv("DATA_PATH", default="/app/data/")
# Read options info
if options_json.exists():
with options_json.open('r') as data:
options = json.load(data)
else:
app.logger.error("options.json does not exists")
else:
if use_options:
OPTIONS_PATH = os.getenv('OPTIONS_PATH', default="/app/options.json")
options_json = Path(OPTIONS_PATH)
# Read options info
if options_json.exists():
with options_json.open('r') as data:
options = json.load(data)
else:
app.logger.error("options.json does not exists")
else:
options = None
#if data path specified by options.json
if options is not None:
if options.get('data_path', None) != None and options.get('data_path', None) != "default":
DATA_PATH = options.get('data_path', None); This may work better. Testing now. |
Ok we could release a quick patch. I've just released the new version. |
That solution seems good. |
Solved with latest patch |
Describe the bug
Log filled with:
To Reproduce
Pull latest version (0.8.2) into your docker environment and launch
Home Assistant installation type
Your hardware
EMHASS installation type
The text was updated successfully, but these errors were encountered: