Pyscript 1.1.0 release
The 1.1.0 release contains some cool new features and some bug fixes.
New features:
- New decorator
@mqtt_triggersupports triggering off mqtt events, including an optional trigger expression, by @dlashua (#98, #105). - All
.pyfiles below thepyscript/scriptsdirectory are autoloaded, recursively, allowing you to arrange your scripts in sub-directories (or deeper) (#97). pyscript.reloadonly 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_ctxservice 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=Noneoptional period in seconds to@state_trigger()andtask.wait_until(). This requires the trigger expression to beFalsefor at least that period (including 0) before a successful trigger. Setting this optional parameter makes state triggers edge triggered (ie, triggers only on transition fromFalsetoTrue), instead of the default level trigger (ie, only has to evaluate toTrue). Proposed by @tchef69 (#89), with suggestions from @dlashua (#95). @time_triggernow 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.uniquenow 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.deland a new functionstate.delete()can delete state variables and state variable attributes.- Updated versions in
tests/requirements_test.txt.
Breaking changes:
- The
pyscript.reloadservice only reloads changed files; prior behavior of reloading all files can be requested by setting the optionalglobal_ctxservice parameter to*. - The
trigger_timetrigger function argument is now set to"startup"for a startup trigger, rather thanNone. This was done to be consistent with the newshutdowntrigger, which calls the trigger function withtrigger_time="shutdown". If you usetrigger_time is Noneto 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
MappingProxyTyperecursion error inside HASS; reported by @github392 (#87). - The deprecated function
state.get_attrwas missing anawait, which causes an exception; it now works correctly, but please usestate.getattrsince the old function will be removed in a future release; reported and fixed by @dlashua (#88). - The
packagingmodule 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!