Pyscript 1.1.0 release
The 1.1.0 release contains some cool new features and some bug fixes.
New features:
- New decorator
@mqtt_trigger
supports triggering off mqtt events, including an optional trigger expression, by @dlashua (#98, #105). - All
.py
files below thepyscript/scripts
directory are autoloaded, recursively, allowing you to arrange your scripts in sub-directories (or deeper) (#97). pyscript.reload
only reloads changed files (changed contents, mtime, or an app's yaml configuration). All files in an app or module are reloaded if any one has changed, and any script, app or module that imports a changed modules (directly or indirectly) is also reloaded. Setting the optionalglobal_ctx
service parameter to*
forces reloading all files (which is the behavior in 1.0.0 and earlier). See #106.- Any script file name or directory name starting with
#
is skipped, which is an in-place way of disabling a specific script, app or directory tree; think of this as "commenting" the script or directory (#97). - Added
state_hold_false=None
optional period in seconds to@state_trigger()
andtask.wait_until()
. This requires the trigger expression to beFalse
for at least that period (including 0) before a successful trigger. Setting this optional parameter makes state triggers edge triggered (ie, triggers only on transition fromFalse
toTrue
), instead of the default level trigger (ie, only has to evaluate toTrue
). Proposed by @tchef69 (#89), with suggestions from @dlashua (#95). @time_trigger
now supports a"shutdown"
trigger, which occurs on HASS shutdown or whenever the trigger function is no longer referenced (eg: during reload, or redefinition in Jupyter), proposed by @dlashua (#103).task.unique
now allows multiple names to be "owned" by each task to support cases where you need to be exclusive against multiple other functions; provided by @dlashua.del
and a new functionstate.delete()
can delete state variables and state variable attributes.- Updated versions in
tests/requirements_test.txt
.
Breaking changes:
- The
pyscript.reload
service only reloads changed files; prior behavior of reloading all files can be requested by setting the optionalglobal_ctx
service parameter to*
. - The
trigger_time
trigger function argument is now set to"startup"
for a startup trigger, rather thanNone
. This was done to be consistent with the newshutdown
trigger, which calls the trigger function withtrigger_time="shutdown"
. If you usetrigger_time is None
to detect a startup trigger, you'll need to change that totrigger_time == "startup"
(see #103).
The bug fixes include:
- State setting now copies the attributes, to avoid a strange
MappingProxyType
recursion error inside HASS; reported by @github392 (#87). - The deprecated function
state.get_attr
was missing anawait
, which causes an exception; it now works correctly, but please usestate.getattr
since the old function will be removed in a future release; reported and fixed by @dlashua (#88). - The
packaging
module is installed if not found, since certain HASS configurations might not include it; fixed by @raman325 (#90, #91).
Thanks to @dlashua for adding @mqtt_trigger
and multiple names in task.unique()
, proposing several new features, as well as bug fixes and testing, and @raman325 for some bug fixes.
Enjoy!