Can I use Python with Hass.io?

Among the three standard installation options, Hass.io seems to be the easiest, but also the most hands off/locked down option. I would like to learn Python and was thinking of using Home Assistant as a “learn by making” project on a RPI 3B+, but if one of the two other options is better suited for utilising Python, which other competencies do I need to handle them, e.g. Linux, Docker, etc.

Ok, you are confused. Home Assistant is a Python module.

  1. Home Assistant can be installed in a Python venv (virtual environment) by using pip

  2. Hassbian which is the venv installation packaged with some managed scripts and the Raspbian OS for the Raspberry Pi hardware

  3. Home Assistant can be installed as a prebuilt Docker container.

  4. Hassio is the Home Assistant Docker Container along with a Supervisor container. It can be installed 2 different ways. It is designed to permit addons that are in their own Docker containers.

Hassio can be installed on Linux, usually a Debian based OS. There are also prebuilt Hassio images using their HassOs minimal hypervisor.

To learn Python I recommend one of the first 2. They can be installed in a VirtualBox VM with a bridged NIC if you are using Windows.

Thanks!

Are addons usually also available as code to be installed on the first two options?

I don’t want to discourage anyone from learning python, but I started out thinking the same thing you are. “Let’s do some home automation and learn python on the way.” If you’re like me and want to automate using pre built components and don’t have a lot of experience with other languages, most of what you learn is how to format a yaml file. If you have some other language background and want to dive into making new libraries, etc then disregard everything else below and jump right in.

If you really want to learn python then I’d say you don’t want to use any of the prebuilt options like Hass.io, you need to start from a fresh install of your favorite OS, make sure it has Python3, and pip install your way to an automated home. A big part of Python is environment management and you won’t get that using any other method.

Using the Anaconda distribution of Python gives you the option of using the conda environment/package manager which has its benefits and drawbacks, I think it’s easier to start with than virtual environments. Using Anaconda may result in multiple copies of python on your machine, but again, this is an important thing to understand and learn to manage.

The functionality is usually available through either the code the addon is based on or another custom component. For example, the Configurator addon is available as HASS Configurator with much the same functionality.
I recently moved from Hassio to HA in a venv. I found replacements for all the addons I wanted. I also, this past year, self-taught myself to work in Python, Ansible, & YAML to improve my scripts at work.

Thanks! That helped!

I understand automations are scripted using YAML in Hassbian, and that is probably most of the work I need to do for controlling my devices.

What would I typically use Python for?

And totally unsupported by the Home Assistant developers. Just keep that in mind of you choose this path…

If you wanted to expand the Home assistant capabilities to add things not already provided elsewhere, then Python can be useful with Home Assistant. It may also help in troubleshooting to determine why something is not working as expected.

Thanks guys!

This helped me decide on Hass.io to start with on the RPI 3B+.
So, I will look for another “learn by making” Python project.

Just because it’s not supported doesn’t make it not work or even make it a bad idea. Home assistant on Anaconda was the first install I did and I had practically zero experience in python. Depends on what you want more, learn python or automate your home. Without any personal details on other language history or ultimate goals installing any form of home assistant and learning how to turn lights on and off, open doors and have nice Lovelace cards doesn’t really require learning any python.

Don’t get me wrong, you will learn something either way, and learning is what this is all about, I just wanted to share the perspective of someone who came into home assistant saying the same thing. I’ve learned very little python from doing basic home automation. I have learned a lot about Docker, virtual machines, and a whole suite of IoT technologies like InfluxDB, Grafana, and so on.

FWIW I very quickly moved from Home assistant on Anaconda to Docker as its way easier to keep home assistant updated that way, but when I do want to write python code I have to drop back to my OS installed (or Anaconda) version of python and use my favorite IDE there.

I recommend installing Raspbian Lite & then Hass.io. That gives you more OS capabilities and is more stable, in my opinion.
The easiest way is to install NOOBS Lite from the Raspberry Pi site & then follow the Hass.io instructions for a generic Linux installation.

If you want home automation related “learn by making” projects and don’t mind a little hardware hacking I’d highly recommend picking one of the various projects that Adafruit has on their web site.

https://learn.adafruit.com/category/circuitpython

These projects typically include connecting some hardware sensors to a processor and then writing code to interact with it. The difficulty of the projects varies, but the instructions are typically very good and all the hardware can be obtained from a single source. Adafruit isn’t the cheapest, but their documentation and support is fantastic and for a one off project it’s a great place to start.

I chose this project: https://learn.adafruit.com/adafruit-io-air-quality-monitor

I first built it on a breadboard with a RaspberryPi 3b+ (not the zero) and played around with the python code to learn the methods being used. Because I wanted to learn both python and home assistant I updated the example code that Adafruit provided to log the data to the Influxdb database instance on my home assistant server. I then used Grafana to integrate the measurements into the Lovelace UI.

There is a lot of learning, and not all of it python related, but doing this you will touch some simple python code, and if you choose, learn how to tie it in with which ever version of home assistant you elect to set up. Think of this as a beginners version of a full stack approach to python and home automation.

Thanks again!

I will check out the Raspbian Lite and Hass.io alternative.

I also thought about the Adafruit or similar makers projects for the Raspberry PI. There are many such projects relating to sensors and IoT which ties into my work.

Also for teaching kids code, there is the micro:bit SBC which can run microPython.

If I use a bootable high volume USB SSD, like 500 GB, would it be better to install Hass.io on the full Raspbian version, or would Hass.io not be compatible running in this environment?

Personally I would install it on Raspbian Lite because you generally do not need the load of a graphical desktop on a server, especially one with limited resources.
I am running Raspbian Lite on a 240GB SSD now. You can run Hassio on that if you choose. The detailed instructions are a little scattered, If you wish to do this I can post the instructions here. I used Balena Etcher to flash my SSD. It complained about a 240GB SD Card but it works.

I just found my instructions in a different thread. :wink:

$ sudo -i
# apt-get update
# apt-get upgrade -y
# apt-get install software-properties-common
# apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat
# curl -fsSL get.docker.com | sh
# curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s -- -m raspberrypi3

Super! :smiley:

Would you recommend two or more SSD partitions for Rasbian Lite, HA and perhaps sensordata?

I personally prefer everything on one partition (except, I think /boot) I fond there is generally no need to partition a Linux disk. If you partition an area for data, for instance. it can cause problems if that partition fills up even tough there is space elsewhere.
Unix-like systems and applications get very unpredictable when space runs out. In fact, Unix-like systems stop letting applications add data before 100% in order to permit the root user to actually resolve the issue.

If you have something like camera data that may fill up space, giving it a separate partition would stop it from impacting the rest of the system & services.

What do you actually recommend, one partition for all, OR one bootable OS partition and one data partition?