Configuration
Pyscript can be configured using the UI, or via yaml. To use the UI, go to the Configuration -> Integrations page and selection “+” to add
Pyscript Python scripting. After that, you can change the settings anytime by selecting Options under Pyscript in the Configuration page.Alternatively, for yaml configuration, add
pyscript:to<config>/configuration.yaml. Pyscript has three optional configuration parameters that allow any python package to be imported, expose thehassvariable as a global, and temporarily switch back to the legacy decorator subsystem (all three options default tofalse):pyscript: allow_all_imports: true hass_is_global: true legacy_decorators: true
Starting with version
2.0.0, pyscript uses the new decorator subsystem by default. If you run into a problem in the new implementation, you can temporarily setlegacy_decorators: trueto switch back to the legacy subsystem. This setting takes effect only after restarting Home Assistant. If you do that, please also file a bug report in the GitHub issue tracker so the problem can be fixed.Add files with a suffix of
.pyin the folder<config>/pyscript.Restart HASS after installing pyscript.
Whenever you change a script file or app, pyscript will automatically reload the changed files. To reload all files and apps, call the
pyscript.reloadservice with the optionalglobal_ctxparameter to*.Watch the HASS log for
pyscripterrors and logger output from your scripts.