4 ms·
For folks here I strongly recommend installing the appdaemon integration and just writing python scripts. The downside is there is a good bit of learning curve
by gregable 5y ago
For folks here I strongly recommend installing the appdaemon integration and just writing python scripts. The downside is there is a good bit of learning curve and time investment just to get the hello world going (turn on a light at sunset?).
Once you are there, you can write shared libraries, abstract away whatever you want, have legit tests, and just do anything you would normally want in your coding environment (vscode, auto-formatters, source control, etc). Obviously not the right recommendation for a consumer system, but if you are like me and feel more comfortable with a programming language, it's the way to go.
- rcarmo 5y agoI can do that with homebridge-mqtt (I just stopped doing it in Python because Node-RED did what I needed and gave me a dead easy chart for temperature sensors).
- ornornor 5y agoFully agree. Interested about the tests though. I’m not a professional python developer but would love automated tests for my appdaemon code. How did you set it up, and how do you run the tests?
- gregable 5y agoI used https://pypi.org/project/appdaemon-testing/ https://pypi.org/project/appdaemon-testing/. You can write a simple test file which does things like sets a device state, then asserts that services were called or whatnot. It doesn't test that the service calls are correctly written, just that they were made. So, very useful for unit testing syntax / logic, but not a full end-to-end integration test solution. Still, with python being an interpreted language, this is super useful. I don't want to have to wait for it actually to be sunset to determine I have a syntax error in that branch of the code, for example. I don't actually have the tests running on the HA device. I have them on my desktop where I develop the appdaemon scripts, and then I copy only the scripts over to HA. I'm sure there are multiple ways to do it.
- ornornor 5y agoThank you, that’s helpful.