So, I do know how to write stuff in Python without AI. What I don’t know is all the “devops stuff”, like build tools and stuff plus most of the devops lingo.
Has anybody ever written something like a “HA integration dev for Dummies” which provides an entry route for people like me?
Hi,
As with most things in tech, “it depends” is the most complete, but least helpful answer!
-
HA can be run in a container, but the drive is more to make the platform accessible to non-tech folks. This means the “supported” way to run it is HAOS, especially as it adds extras like the supervisor and Add-ons.
HAOS can (and often is) run in a container itself. -
HA is trying to be an “appliance”, with AppArmor security - it is possible to get root access to the core container, but only really for development and not for production use.
The advanced terminal add-on can apparently give easier access to the core.
Linux credentials (root user) - #3 by FloatingBoater -
Whilst you can use Python to access the HA API or create your own integrations, I’ve not had to use it - the graphical automations editor (and if needed, the YAML underneath) have been enough.
Coming from openHAB, this was a big change. 40-lines of code collapsed to 5 with a different event-model!
The most I’ve needed is the odd Linux script for integration or MQTT testing. -
The dev docs do include an add-on tutorial, which may be useful:
Tutorial: Making your first add-on | Home Assistant Developer DocsSet up development environment | Home Assistant Developer Docs
I’d suggest an Integration may be a better start than a full-blown Add-On.
-
I think there is a means to run Python code locally against HA, but I’ve not used it. Look in HACS?
The docs are reasonable, but not perfect - searching here, or perhaps asking in Discord can fill in the gaps…
The discussion thread about depreciating containers had a better architecture diagram, but I can’t find that now.
If this helps,
this post!
You haven’t told us why you want to write Python for HA.
- If you want to do automations and you think it is easier because you already know Python: resist the urge and learn how HA works.
- If you want to write an integration that does not exist yet: what kind of interface? If it is rest, you might also not need to. If not, look at the previous post.
- If you still want to automate stuff in Python look at the appdeamon addon. You don’t need to develop an integration for automating stuff.
If you’re looking for a nice way to have a containerized way to develop a custom integration, I haven’t found one. I also haven’t really looked. Typically what I do is copy files over to my dev container and do my development there. I have to do this because I dev on windows through dev container. I’m also not really interested in setting up and working through a VM just to avoid dev container. So it’s just a trade off I chose.
If you dev on linux, you can just setup a core dev env and go from there. Still not sure how you’d set up the folder for development though. Maybe some others who have custom integrations can tell you what they do.
Ah, that’s the Python-thingy I couldn’t remember- thanks!
@FloatingBoater
Thanks! That will do nicely!
@Edwin_D
Mostly because I want to know how it’s done. It’s kinda my way to get a better understanding of how stuff works internally. Plus some things can’t be easily done externally, such as geolocation entities. I do a lot of stuff with the TAK situational awareness ecosystem, so maybe I’ll hack together some kind of TAK client for HA.
@petro
Absolutely Linux. I use Linux since 1995, it’s my primary desktop since 1996 and I’m officially Windows-free since 2001.
I’m quite familiar with docker, so yeah, it’s gonna be a HA container for development.
If you mean device trackers: those are easy to create. Either dynamically by device_tracker.see or as an MQTT entity. But it does indeed sound like creating an integration is what you have in mind.
I mean geolocation entities like those created e.g.by the Blitzortung integration.
There’s some forum posts on displaying lightening data on HA dashboards, but not seen C3 platforms (what I knew them as) linked probably due to the different use-cases.
HA geospatial is more about displaying family location or triggering reminders when you enter a shop zone.
A quick hack script with mosquitto_pub to inject single asset location data into HA via MQTT might be a start, or display more complex geo-data as flat images on dashboards.
(*nix greybeard and geospatial OpenStreetMap contributor)