What does HackerNews think of pyscript?

Pyscript adds rich Python scripting to HASS

Language: Python

Pyscript adds rich Python scripting to HASS : https://github.com/custom-components/pyscript

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.
> ... for the off->on transition and another for the on->off. It'd be nice to set a rule that defines a level rather than an edge and have it internally do the transformation

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)

You can try pyscript (https://github.com/custom-components/pyscript), which allows you to write automations in plain Python.