Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active September 20, 2024 18:40
Show Gist options
  • Save lupyuen/01cff0d4ca225984ca8fd0d999d7c76d to your computer and use it in GitHub Desktop.
Save lupyuen/01cff0d4ca225984ca8fd0d999d7c76d to your computer and use it in GitHub Desktop.
Installing Home Assistant to control Google Home (via Google Assistant SDK)

Home Assistant controls Google Home (via Google Assistant SDK)

Installing Home Assistant to control Google Home (via Google Assistant SDK)

These are the (messy) steps to install Home Assistant (on Linux) to control Google Home (via Google Assistant SDK)...

  1. We begin with a rather old Debian Linux...

    $ neofetch
            #####           pi@rak-gateway 
           #######          -------------- 
           ##O#O##          OS: Linux (Unknown) armv7l 
           #######          Host: Raspberry Pi 4 Model B Rev 1.4 
         ###########        Kernel: 5.10.103-v7l+ 
        #############       Uptime: 14 hours, 52 mins 
       ###############      Packages: 912 (dpkg) 
       ################     Shell: bash 5.1.4 
      #################     Terminal: /dev/pts/0 
    #####################   CPU: BCM2711 (4) @ 1.500GHz 
    #####################   Memory: 116MiB / 3839MiB 
      #################
    
  2. WARNING: This step might break apt upgrade later...

    Upgrade Python to 3.11: Follow these steps

    If we don't do this: pip3 install will fail to find homeassistant==2023.7.2

  3. Upgrade SQLite to 3.34.1: Follow these steps

    If we don't do this: hass will say "SQLite 3.27.2 not supported"

  4. Because we upgraded Python, apt upgrade might break and "keep back" a whole bunch of packages.

    Not sure why, but this worked: Revert to old version of Python, apt upgrade, switch back to new version of Python, then apt install --only-upgrade gcc-8-base...

    ## Revert to old version of Python
    sudo rm /etc/alternatives/python
    sudo ln -s /usr/bin/python3.7 /etc/alternatives/python
    sudo rm /etc/alternatives/python3
    sudo ln -s /usr/bin/python3.7 /etc/alternatives/python3
    
    ## Upgrade will show "kept back" packages
    sudo apt upgrade
    
    ## Switch back to new version of Python
    sudo rm /etc/alternatives/python
    sudo ln -s /usr/local/bin/python3.11 /etc/alternatives/python
    sudo rm /etc/alternatives/python3
    sudo ln -s /usr/local/bin/python3.11 /etc/alternatives/python3
    
    ## Magically fixes the "kept back" packages
    sudo apt install --only-upgrade gcc-8-base
    sudo apt upgrade
  5. Install Home Assistant Core: Follow these steps

    If pip3 install fails to find homeassistant==2023.7.2: Upgrade Python to 3.11 (see above)

    If pip3 install fails to find rustc: Install Rust (see below)

    If hass says "SQLite 3.27.2 not supported": Upgrade SQLite to 3.34.1 (see above)

  6. Install Rust as homeassistant user: Follow these steps

    If we don't do this: pip3 install will fail to find rustc

  7. Install Integration for Google Assistant SDK: Follow these steps

    If it fails with "google_assistant_sdk: gRPC is not installed, please install the grpcio package to use the gRPC transport", check whether it's a GLIBC problem...

    $ python3
    >>> import grpc
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/srv/homeassistant/lib/python3.10/site-packages/grpc/__init__.py", line 22, in <module>
        from grpc import _compression
      File "/srv/homeassistant/lib/python3.10/site-packages/grpc/_compression.py", line 20, in <module>
        from grpc._cython import cygrpc
    ImportError: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.33' not found (required by /srv/homeassistant/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-arm-linux-gnueabihf.so)    
    

    If so, then recompile and reinstall grpcio (will take a while)...

    pip install --upgrade --force-reinstall --no-binary=grpcio grpcio

    And restart hass.

  8. Go to the Home Assistant Web UI and chat with Google Assistant.

    We will be able to control our lights in Google Home (pic above)...

    switch off bedroom light
    switch on bedroom light
    

Why are we doing this?

We might use Home Assistant API and Google Home with a Smart Power Plug (IKEA TRÅDFRI and DIRIGERA) to power-cycle our Star64 SBC for Automated Testing of Apache NuttX RTOS...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment