Closed rohrsh closed 4 months ago
Hey, there! What is home assistant?
It looks like you are trying to run Python scripts within the Home Assistant environment, and you've encountered some challenges. Let's address the issues you mentioned and discuss the best approach.
Default Terminal Add-on:
Advanced Terminal & SSH Add-on:
requests
and beautifulsoup4
) using pip
. This is typical for installing Python packages in Home Assistant.Python Scripts Module:
Pyscript:
Given your requirements, here are some recommendations:
Continue Using Advanced Terminal & SSH Add-on:
pip
.Explore AppDaemon:
Evaluate the Home Assistant Container:
Remember to carefully consider the security implications of running scripts within your Home Assistant environment. Always follow best practices to minimize potential risks.
If you provide more details about the specific requirements of your Python scripts, I can offer more targeted advice.
Thank you ChatGPT
Hey @rohrsh sorry for the delay - I'll update the readme tonight with more specific instructions
Hey, there! What is home assistant?
- I tried with the default Terminal add-on, but that is locked down and doesn't include python
Ah, good to know. I haven't tried that add-on!
- I installed the advanced Terminal & SSH add-on. This had python but I had to pip install requests and beautifulsoup4 in order to run populate-configuration.py
Ah, since i only needed to run this once, I just ran it locally on my laptop.
- For the regular solarhtml2json.py automation script, I first tried the Python Scripts module, but it doesn't allow imports
- Next I tried pyscripts, but I think that is expecting modules instead of scripts? https://hacs-pyscript.readthedocs.io/en/stable/overview.html
Error executing script: __import__ not found Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute exec(compiled.code, restricted_globals) # noqa: S102 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "solarhtml2json.py", line 1, in <module> import requests ImportError: __import__ not found
I am also using the official Home Assistant OS. My understanding is that the terminal add-ons and modules all run as containers in the OS and don't share any library version. I used the File Editor add-on to just put the solarhtml2json.py file in /config/
which is a path shared with the main HAOS system.
HAOS ships with compatible versions of the python libraries I used in the script, so there should be nothing else to add.
Please try that and let me know if it works!
Can you share the shell_command.convert_solar_data please?
shell_command:
convert_solar_data: python solarhtml2json.py
@rohrsh
In the configuration.yaml file add the above line to register the shell script for convert_solar_data
BAM
Thank you
Glad it worked!
Hey buddy,
Thanks for putting this together. I've been hoping to find a local method for these old ECU-3 for a while.
What is best way to run python in the Home Assistant situation? I'm using the official Home Assistant OS installation.