Python script integration - what's the development process?

There’s a python script integration in hass. I was trying to write a script, and then I realized I have no idea how to test or even run it. The only way I know how to launch it is to invoke via automation, and then log as a makeshift “print”, so that I can get an idea what script is doing

Needless to say, this is ridiculous. There’s no way plugin authors intended for the integration to be used that way

Can somebody describe to me what is the intended development process to those who are trying to write their own actions using python code? Specifically, I am looking to understand how to:

  • create script (I presume via VSCode in python_scripts?)
  • run script in python (“python python_scripts/my-script.py” will not work, there will be missing objects)
  • run script in integrated vscode, so that I can have breakpoints, variable inspect, etc
  • unit test the script
1 Like

Hi, I am not sure why you have issues. The link you provided gives a clear example and how to run it… (actions)

That same documentation also states that if you need something more advanced than run a script without additional imports from an action, then you might want to take a look at e.g. Appdeamon, which is actively developed, is properly integrated with Home Assistant and has good documentation.
https://appdaemon.readthedocs.io/en/latest/

1 Like

appdeamon is nice indeed :slight_smile: …for import additional libs, using pyscript also works config/pyscript/requirements.txt