Can't find python

Hi all

I’ve got a simple python script that fetchs data from a remote web source however I’m having some odd problems with getting it to run via python.
When I start an ssh connection (via “Terminal and SSH” add-on) there is no python or python3 on the filesystem.

I then added python via apk add python3 and that worked fine - script executed as expected.
I then added the script as a “shell_command” and in configuration.yaml and restarted the raspberry pi to force it to re-read the yaml (perhaps overkill?).

Anyways, the script doesn’t execute and python has gone from the system! If I didn’t know better I’d say there was some kind of sandbox / container that the “Terminal and SSH” was landing me in, and that this isn’t being persisted on a reboot?

So two questions:

  1. Does “Terminal and SSH” execute in a sandbox (least important question)
  2. How do I persuade a “shell_command” to execute a python script? (most important question)

Thanks!

Not in a sandbox, you arrive in the HA docker container, not the OS.

Don’t know.
For simple scripts, try the python integration

For more advanced scripts, try pyscript :

Or Appdaemon.

Ha runs in python so it’s available in the HA container.
Read here how to access the HA container.
Auswahl_479

Thanks everyone.

Firstly for the confirmation that hass is container-based: that explains the behaviour I was seeing (and now I understand that the key folders like /config are mapped into the container).

Also for the pointer toward appdaemon. I’d looked at this way back when I started researching HomeAssistant (last Monday :smile:) and thought it was overkill for what I needed, however now reading through the documentation I am concluding that AD is what I’m looking for.

I’m really impressed at the simplicity and completeness of the out-of-the-box (including integrations) solution but there’s clearly a bit of a leap jumping from “standard” to building custom solutions. That’s not a problem as I’m a software engineer to trade, and it looks like a lot of clear thought and experience has gone into the architecture of HA.
I’ll now finish reading the documentation before returning to the task at hand!

Cheers

1 Like