pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

Home Assistant crashed and stopped loading UI after installation Pyscript

Open mspnr opened this issue 10 months ago • 10 comments

Home Assistant crashed and stopped loading UI after installation Pyscript.

Crash happened after activation of the integration and starting the first script.

Installation was performed from HACS, Pyscript version on moment of installation 1.6.1.

The situation was resolved by connecting display and keyboard to Raspberry Pi and surgically disabling integration. Then Home Assistant start load UI.

Be careful! I would consider such behavior as very dangerous.

Home Assistant versions:

Core 2025.2.5 Supervisor 2025.02.1 Operating System 14.2 Frontend 20250221.0

mspnr avatar Feb 26 '25 15:02 mspnr

Hey @mspnr 👋

What script were you running?

IgnusG avatar Feb 26 '25 18:02 IgnusG

Actually it was a couple of days ago. I started with the first script suggested in the tutorial https://hacs-pyscript.readthedocs.io/en/stable/tutorial.html and I think it was all right till the moment I started experiment and may insert some nonsense line, which probably ended up with compilation error.

My point here is no matter what error happens in this script it should not put into risk the whole system stops to not boot up.

mspnr avatar Feb 26 '25 22:02 mspnr

As @IgnusG asked, the most important information you can provide is what script (code) you were running. It is possible to stall the main event loop by writing blocking code in pyscript. So it would be good to know whether that was the case, or whether something else happened. Being able to reproduce an error is the first step is debugging and fixing it.

craigbarratt avatar Feb 26 '25 23:02 craigbarratt

I am not sure if it helps. I copied the line from the original HA python script. So far this is the script:

import os


@service
def hello_world(action=None, id=None):
    """hello_world example using pyscript."""
    # log.info(f"hello world: got action {action} id {id}")
    # if action == "turn_on" and id is not None:
    #     light.turn_on(entity_id=id, brightness=255)
    # elif action == "fire" and id is not None:
    # event.fire(id, param1=12, param2=80)

    os.remove("/config/snapshots/_temp/1.jpg") 
    hass.services.call("camera", "snapshot", { "entity_id": "camera.cam1", "filename": "/config/snapshots/_temp/1.jpg" })

mspnr avatar Feb 26 '25 23:02 mspnr

Same issue here... Troubleshooting from the hell

fdreckmann avatar Mar 20 '25 16:03 fdreckmann

Hi, same issue but after update to the last version of pyscript today. I perform the update and reboot HA as raccomanded. After the reboot HA doesn't start, I had to physically shutdown rasberryPi e restart because doesn't start the UI. After the physical reboot the UI started but doesn't work correctly (no update), only disable pyscript the system works properly. The only integration that uses pyscript is Irrigation unlimited.

Core 2025.3.3 Supervisor 2025.03.3 Operating System 15.0 Frontend 20250306.0

alfonsomolaro avatar Mar 20 '25 17:03 alfonsomolaro

Please anyone can investigate? The only way to resolve is uninstall pyscript.

alfonsomolaro avatar Mar 22 '25 11:03 alfonsomolaro

I don't have access to that type of platform. Is there anything in the log files after you reboot?

craigbarratt avatar Mar 22 '25 18:03 craigbarratt

The first thing to try is to make sure it runs reliably with no scripts present in the pyscript directory. If it runs reliably without any scripts, then the problem is likely due to user code in the scripts. In that case, try adding scripts to figure out which one is the culprit.

craigbarratt avatar Mar 24 '25 18:03 craigbarratt

I tried to reinstall from zero che pyscript integration (no update, but uninstall delete the conf and re-install) and so it's works fine. Something went wrong with the update....

alfonsomolaro avatar Mar 24 '25 21:03 alfonsomolaro