dmamelin
dmamelin
Modifying StateVal according to homeassistant.core.State. Useful in complex logic: no need to store and pass entity_id. Simplified example: ```python def func(state): num_seconds_ago = (dt.now(tz=timezone.utc) - state.last_changed).total_seconds() if num_seconds_ago > 10:...
This code causes an error: `RuntimeError: Lock is not acquired.` ```python lock = asyncio.Lock() async with lock: pass ``` Workaround: ```python lock = asyncio.Lock() async with lock as lock_test: pass...
Looking into #787 I found that `Enum` overrides `__dir__`, so [dir(inst)](https://github.com/custom-components/pyscript/compare/master...dmamelin:pyscript:evalfuncvar-descriptor-binding?expand=1#diff-733b200d9ce0361a3582c281043fd548b057e971f927f73aed75bfdc8422f06cL1992) inside `call_func` doesn’t show the method. I went deep into MRO, inspect, etc., but the actual fix turned out...
Explanation: Before this PR, all imported modules were always assigned `auto_start = True`, which caused their triggers to run immediately after the file was loaded: load files from disk →...
Module-level triggers start before Home Assistant reaches the RUNNING state modules/module.py: ```python @time_trigger def module_startup(): log.info(f"Module hass state: {hass.state}") ``` test.py: ```python from module import module_startup @time_trigger def file_startup(): log.info(f"File...