Best scripting way for complex tasks

Hello,

i want to develop a script that analyze many sensors and interact with many actuators in a flexible manner.

For example I have the power coming/going to the network (I have photovoltaic) and I want to set room thermostats, heat pump water temperature, based on read internal/external temperature. I also want to change DWH setpoint, or to start/stop BEV charging according to current photovoltaic production.

The question is regarding your experience with different scripting methods, i’m also focused on debugging methods both with an IDE from a workstations (HA is running in an headless server) and with customizable logs/way to track running variables.

For example i want to try pyscript, i usually use JetBrains PyCharm so I will try with remote debugging but idk if it’s integrable with a pyScript as well as idk if Remote Python Debugger - Home Assistant can be used for that.
I’ve tested a tutorial script, and logs are thrown into the home-assistant.log but I can read it with File Editor (browser) because HA runs in docker. Moreover all logs are put in the same file, that’s not easy to read. It would be easier to read something like espHome project, that opens its own console when it’s needed an inspection. For that reason i’m checking if it makes sense or is feasable to make a py process to easen inspection and logging with external libraries.

I read something about Node-red , appdaemon but i don’t know which one I should start to study first, and their capabilities.

Suggestions are welcome

Thanks

Did you ever find out any more about this? I have used appdaemon for over 5 years and gave pyscript a try for a month or so for some basic stuff. I liked the simple nature of the syntax for pyscript but like the full python environment that appdaemon provides.

Appdaemon:

  • Rock solid for 5 plus years
  • Good dev environment for vs code since it uses pure python
  • Have to use yaml to reference every python app
  • A little more verbose and more code with having to first initialize your listener than use a callback
  • Has its own forum so its a great place to find info and ask the community

Pyscript

  • Simple syntax
  • No yaml
  • The listener is just a decorator with your “action” code write beneath it
  • Difficult dev environment when using vs code, that is if you don’t like syntax errors all over the place
    • The dev seems to prefer to use Jupyter Notebook to create code, then just paste it into your app. I personally prefer just to use vs code which results in no autocomplete, no peeks, no method lists and a lot of syntax errors
  • Little more cumbersome to test as you have less control over the logs, still pretty easy as you just use the home assistants log but appdaemon allows you write to your own log files.
  • Could be me but I’ve had a couple of occasions when my code gets stuck and does not update with changes until I restart home assistant.
  • No dedicated place to ask questions.

If you want the most authentic python with IDE debugging, you can install appdaemon as a package in your venv and develop there then bring your code into the app when finished… see here HA automation in Python from a developer’s POV - Community Guides - Home Assistant Community (home-assistant.io). Pretty sweet if you are good with appdaemon’s framework and syntax.

I guess I am still looking for the python home automation unicorn in home assistant! Right now, I am using both Appdaemon and Pyscritpt and cannot decide which I like better.

2 Likes

The PyScript autocomplete issue was fixed by another user