What does HackerNews think of pyscript?
Pyscript adds rich Python scripting to HASS
An example script:
@state_trigger("security.rear_motion == '1' or security.side_motion == '1'")
@time_active("range(sunset - 20min, sunrise + 20min)")
def motion_light_rear():
"""Turn on rear light for 5 minutes when there is motion and it's dark"""
task.unique("motion_light_rear")
log.info(f"triggered; turning on the light")
if light.outside_rear != "on":
light.turn_on(entity_id="light.outside_rear", brightness=255)
task.sleep(300)
light.turn_off(entity_id="light.outside_rear")
It's what made me ditch node red after going down the same path.The "solution" I found was to poll, and use "choose", and sometimes some helper switches for state, to do what is needed. But, I think at any reasonable level of complexity, you're better off using one of the three python components: the one built into Home Assistant, pyscript, or AppDaemon.
Home Assistant Python: https://www.home-assistant.io/integrations/python_script/ No imports.
pyscript: https://github.com/custom-components/pyscript Full python. Supports Jupyter. Straightforward.
AppDaemon: https://appdaemon.readthedocs.io/en/latest/HASS_TUTORIAL.htm... Full python. A little lower level. Allows the creation of dashboards.
Related, the Matter protocol is on its way. I'm waiting for these devices before I redo my house, or put much more effort into any of this: https://en.wikipedia.org/wiki/Matter_(standard)