Pyscript adds rich Python scripting to HASS
The 0.32 release contains a couple of new features and one important bug fix.
New features:
@state_trigger
now supports just a state variable name string argument, which triggers on any change. This replaces the old confusing "True or domain.entity_id"
form, although that still works.@state_trigger
can now take multiple arguments, and any argument can be a list of string expressions or string state variable names (trigger on any change). All the conditions are logically or
ed together.allow_all_imports
now take effect on reload.The bug fix is to clean up a task to avoid a stall during HASS restart.
Thanks to @raman325 for supporting config changes on reload and improved error reporting in config flow.
Enjoy!
The 0.31 release contains one significant new feature and several bug fixes.
The new feature is config flow support, which allows setup of pyscript (including allow_all_imports
) from the UI, while still allowing optional app configuration via yaml
. Also, __name__
is now supported so modules, packages or apps can know their name.
On the infrastructure side, pylint
is now included in the pre-commit, push and PR flows, and all tests now use pytest_homeassistant_custom_component
instead of pytest_homeassistant
.
Bug fixes include:
task.unique()
doesn't kill itself if the same task previously called itThanks to @raman325 for developing the config flow support, and to @dlashua for discovering and reporting all those bugs and providing concise failing examples.
Enjoy!
The 0.30 release contains a number of new features, and several bug fixes.
The main new features are:
<config>/pyscript
directorypyscript.config
that allows access to yaml
configuration settingstask.executor()
for functions that block (eg, doing I/O) or have long running timeswith
, async for
, lambda
and named expressionscroniter
package for cron functionsBreaking changes:
task.unique()
now only applies within the current global context; the same name used in other global contexts will not be affectedNameError
exception, instead of returning None
, except in @state_trigger
or @state_active
, where undefined state variables, attributes or the .old
value will still evaluate to None
if not definedInfrastructure:
black
, isort
, flake8
and pytest
black
/flake8
/isort
pytest
setupBug fixes include:
del
works correctly for non-locally scoped variablesThanks to @fleXible for several PRs (adding croniter
, fixing sunset/sunrise, revamping test infrastructure, refactoring and precommits, among others) and @dlashua for extensive testing, various bug reports and feature requests.
Enjoy!
The 0.21 release contains a number of new features, and several bug fixes.
The main new features are:
allow_all_imports
can be set to true
to allow any package to be imported (thanks to @basnijholt, #8)@time_trigger
time_spec
, which allows a function to be called on startup and at additional specified times (#7)@task_unique
is a new decorator with the same arguments as task.unique()
(#1)state.names()
to get a list of all entity ids for a given domain, or all if a domain is not specified (#12)state.get_attr()
to get all the attributes (in a dict
) for a state variableprint()
as an alias for log.debug()
; it currently only supports a single argumentOne breaking change is that assigning to a state variable (HASS entity id) now preserves its existing attributes (previously, setting a state variable would delete its attributes). The state.set()
function can be used to optionally overwrite or remove all attributes, or to set specific attributes while preserving others.
Bug fixes include:
Enjoy!
Pyscript 0.20 is a significant release that supports the Jupyter frontends (eg, notebook, console, lab). This allows fully interactive development and testing of pyscript functions, services, triggers and automation logic. Auto-completion with TAB
is supported. See this README.md for more information.
To use Jupyter with pyscript you need to install a kernel shim from the hass-pyscript-jupyter repository.
Other new pyscript features include support for eval()
, exec()
, globals()
, locals()
and exceptions (try
, except
and raise
). Error reporting and handling have been improved.
One small change that isn't backward compatible is that the logger path for pyscript has changed from homeassistant.components.pyscript
to custom_components.pyscript
. Also, the sub-path for pyscript functions has changed. To specify the logging level of a pyscript function FUNCNAME
in a pyscript file FILE
(without the .py
extension), the logger path used in the logger
configuration is now:
custom_components.pyscript.file.FILENAME.FUNCNAME
(In 0.11 it was homeassistant.components.pyscript.func.FUNCNAME
, which is ambiguous if the same function name is used in different pyscript files.)
There are also a few bug fixes, including an issue that caused task.unique()
to not terminate the specified task after the first time.
Enjoy!
Fixed incorrect filename key in hacs.json that prevented download.
Initial release of pyscript as a custom component in HACS. Thanks to @ludeeus for HACS and the help in setting up this repository.
This release is broken. Please use >= 0.11 instead.