Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

How To Upgrade HomeAssistant In A Python Venv

  1. Home

By Khalid on 2022/06/15 - 17:51, last updated 2023/11/20 - 14:36

Home Assistant is an open source home automation platform, written in Python. I have been running it for several years for various tasks.

However, I am running it using a less common Home Assistant Core installation method, consciously deciding not to run the custom Raspberry Pi image for Home Assistant, nor the docker container version for many reasons.

These reasons include:

  • running custom shell scripts that are called by Home Assistant for notifications and such,
  • running other programs on the Raspberry Pi (e.g. RTL-SDR for weather station, InfluxDB for a weather panel, ...),
  • having access to Ubuntu's vast repository of applications easily installable using apt,
  • retaining sysadmin control over the Raspberry Pi.

Instead, I chose to run it as a Python Virtual Environment (venv). This allows me to run Home Assistant on the ARM 64 bit of Ubuntu 20.04 LTS, which runs very well on the Raspberry Pi 4 that I have.

One annoying thing though: the Home Assistant development team do not stick with a certain Python version for long enough. You see, one main reason for using Ubuntu is the Long Term Release (LTS) versions, which are supported for 5 years. That helps a lot in not having to keep upgrading things too often, so less time for maintenance, and less disruptions.

Disappointingly, the Home Assistant team decided in late 2021 to abandon Python 3.8 and mandate Python 3.9 instead.

Luckily, Ubuntu 20.04 LTS supports Python 3.9 (in the focal-updates repository), but that requires upgrading the venv that you have from 3.8 to 3.9.

The upgrade process for a Home Assistant venv is not too hard though, despite many posts on the web claiming otherwise.

Here are the steps in case you are in a similar situation:

Prepare For The Upgrade

First, set the location where you have Home Assistant's venv in. The first line should be the directory that has the two files pyvenv.cfg and requirements.txt.

HA_DIR="$HOME/ha/homeassistant"
CONF_DIR="$HOME_DIR/ha/conf"

Install The New Python Version

Then, using apt, install the required Python packages for the new version.

sudo apt install python3.9-venv python3.9-dev

Upgrade The Venv

python3.9 -m venv --upgrade $HA_DIR

Install PyMySQL

Next, if you are using MariaDB or MySQL for the recorder and history integrations in Home Assistnat, then you need again install pymysql:

. $HA_DIR/bin/activate
pip3 install pymysql

Upgrade Home Assistant

pip3 install --upgrade homeassistant

Check The Configuration File Syntax

Now, make sure that your configuration files are compatible with the new syntax changes of the new version.

$HA_DIR/bin/hass -c $CONF_DIR --script check_config

If you see errors or deprecated warnings, you need to fix them now.

Restart Home Assistant

Kill the running hass process, then start a new one

$HA_DIR/bin/hass -c $CONF_DIR 

There you go, that is all you need to get your Home Assistant venv upgraded. That is, until the Home Assistant team decides to jump to a newer Python version. Hopefully, not too soon ...

Contents: 
Linux
Software
Tags: 
Home Assistant
Python
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.