Recent Changes - Search:

Photo gallery home

Home Assistant

Overviev

How to instal Home Assistant on Intel NUC-7CJYH ..

Links


shell help

    sudo shutdown -h now
    sudo systemctl poweroff
    sudo systemctl reboot

APT

    su   apt install sudo                    ##  sudo is not standard component of Debian - so install it
    sudo apt update && sudo apt upgrade -y   ## to udate cached packages
    sudo apt install curl                    ##  resp. sudo apt-get install curl
    sudo apt install network-manager

LOCATE

    locate wpa_supplicant.conf               ## the locate command is fine, just update the locatedb first, using command updatedb
    sudo updatedb

NETWORK

    ip -c ad                                 ## debinan ipconfig-like dump of network interfaces (IP,MAC, ...)
    ls -l /sys/class/tty/*/device/driver     ## list [ttyS0 .. ttyUSB0] devices and drivers

    sudo apt update && sudo apt upgrade -y   
    sudo apt install lshw                    ## lshw
    sudo apt install iw                      ## iw - https://manpages.ubuntu.com/manpages/jammy/en/man8/iw.8.html
    sudo apt install network-manager         ## network-manager
    sudo apt install wireless-tools          ## iwspy

    sudo lshw -C network                     ## show available network hardware 

    sudo iw ...                              ## Understanding IW command / options - https://ubuntuforums.org/showthread.php?t=1949531
    sudo iw dev wlo2 info
    sudo iw dev wlo2 start                   ## ???

    # SSID and PSK password(s)
    sudo nano /etc/netplan/00-installer-config-wifi.yaml
    sudo nano /etc/wpa_supplicant/wpa_supplicant.conf      ## INSTALL DAEMON :  sudo wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlo2

    sudo networkctl                          ## short list of status
    sudo networkctl status                   ## more detailed list of status
    sudo networkctl up wlo2                  ## bring UP wifi interface 'wlo2'
    sudo networkctl down wlo2                ## bring DOWN

    sudo iwlist wlo2 scanning                ## scan available Access points

    ## systemd[1]: Failed to start Wait for Network to be Configured.
    sudo systemctl disable systemd-networkd-wait-online.service  

    sudo nmcli device show                   ## Network Manager Client - s klienmi sa mozem trtkat az ked vsetok low level funguje
    sudo nmcli d wifi list                   ## IN-USE  BSSID  SSID  MODE  CHAN  RATE  SIGNAL  BARS  SECURITY
    sudo nmcli radio wifi off
    sudo nmcli radio wifi on

Debian - install on Intel NUC

  • download Debian ISO - Small CDs or USB sticks - (ex. debian-11.6.0-amd64-netinst.iso)
  • Flash ISO to USB stick via Etcher Portable
  • in NUC BIOS : check [x] Boot from USB Device first
  • plug USB stick to NUC
  • plug NUC to Router via ethernet cable
  • restart NUC
  • folow installer steps (booted from USB stick) ...
    • LVM Enabled (Logical Volume Management)
    • UEFI boot enabled (when single partition not shared with other OS)
    • hostname : sd-ha
    • root :
    • user :
    • ip :
  • WinSCP
                \etc\ssh\sshd_config       # CHANGE TO : PermitRootLogin yes
                # sudo \usr\sbin\sshd -t   # to test config before daemon restart
                # \etc\init.d\ssh restart  # OR "systemctl ssh reload"   # [ ok ] Restarting ssh (via systemctl): ssh.service.
  • PermitRootLogin with PubkeyAuthentication ONLY
                \etc\ssh\sshd_config
                    PermitRootLogin without-password
                    PubkeyAuthentication yes
                # sudo \usr\sbin\sshd -t   # to test config before daemon restart
                # \etc\init.d\ssh restart  # OR "systemctl ssh reload"   # [ ok ] Restarting ssh (via systemctl): ssh.service.

Debian - Bluetooth on Intel NUC

    # sudo apt install lshw                    ##  resp. sudo apt-get install lshw - utility to list available hardware 
                                               ##    ex. lshw -class communication | grep -i blue
    # sudo apt install bluez                   ##  bluetoothctl 

    # lshw -short |grep -i blue
        /0/100/15                           bus            Celeron/Pentium Silver Processor USB 3.0 xHCI Controller
        /0/100/15/0        usb1             bus            xHCI Host Controller
        /0/100/15/0/9                       communication  Bluetooth 9460/9560 Jefferson Peak (JfP)
        /0/100/15/1        usb2             bus            xHCI Host Controller

    # lspci -knn | grep Net -A3; lsusb; dmesg | grep -i blu
    or 
    # dmesg | grep -i blue
            [    5.132502] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
            [    5.132599] bluetooth hci0:  firmware: failed to load intel/ibt-17-16-1.sfi (-2) 
            [    5.132623] bluetooth hci0: Direct firmware load for intel/ibt-17-16-1.sfi failed with error -2
            [    5.132627] Bluetooth: hci0: Failed to load Intel firmware file (-2)

Debian - Bluetooth - Install Intel non-free firmware drivers

  • /etc/apt/sources.list ..
    add to all lines "contrib non-free" ... ex : deb http://deb.debian.org/debian/ bullseye main contrib non-free
  • Install firmware-iwlwifi
            see :  https://wiki.debian.org/iwlwifi 
            # apt-get update && apt-get install firmware-iwlwifi
  • Check installed drivers
        # apt-cache show firmware-iwlwifi | grep '9460\|ibt-17'
            Intel Wireless 9460/9650 (var 0 rev 1) Bluetooth configuration,
            version 20.10 (intel/ibt-17-0-1.ddc)
            Intel Wireless 9460/9650 (var 0 rev 1) Bluetooth firmware, version
            20.30.0.1 (intel/ibt-17-0-1.sfi)
            Intel Wireless 9460/9650 (var 16 rev 1) Bluetooth configuration,
            version 20.60.0.2 (intel/ibt-17-16-1.ddc)
            Intel Wireless 9460/9650 (var 16 rev 1) Bluetooth firmware, version
            21.30.0.4 (intel/ibt-17-16-1.sfi)
  • Restart system
            # systemctl reboot
  • Check system messages
            # dmesg | grep -i blue
             bluetooth hci0: firmware: direct-loading firmware intel/ibt-17-16-1.sfi 
             Bluetooth: hci0: Found device firmware: intel/ibt-17-16-1.sfi 
  • Check bluetooth
            # bluetoothctl list
             Controller 3C:21:9C:46:1F:C1 sd-ha [default] 
            # bluetoothctl show
  • Bring hci0 UP
            # hciconfig hci0 up
            # hciconfig
            hci0:   Type: Primary  Bus: USB
                    BD Address: 3C:21:9C:46:1F:C1  ACL MTU: 1021:4  SCO MTU: 96:6
                    UP RUNNING
                    RX bytes:17264 acl:0 sco:0 events:2796 errors:0
                    TX bytes:687859 acl:0 sco:0 commands:2793 errors:0
  • HCI tool
            # hcitool dev
            Devices:  hci0    3C:21:9C:46:1F:C1
  • Map bluetooth to homeassistant docker
            /opt/docker-compose.yaml
              homeassistant:
                volumes:
                  - /run/dbus:/run/dbus:ro
  • Install and activate dbus-broker and reboot
            # apt update && apt install dbus-broker
            # systemctl --global enable dbus-broker.service
            # systemctl reboot  # or shutdown -h now

Alternative manual download:

Debian - Tools help

    dmesg | grep -i blue

    /run/dbus:/run/dbus:ro
    /sys/class/bluetooth/hci0

    service bluetooth restart

    lsusb
    lsmod | grep bt
    lsusb -v


    bluetoothctl --version  # Docker : 5.65
    bluetoothctl        #Agent registered [CHG] Controller 3C:21:9C:46:1F:C1 Pairable: yes
    bluetoothctl list   #Controller 3C:21:9C:46:1F:C1 sd-ha [default]
                        # in DOCKER
                        #   Waiting to connect to bluetoothd...dbus[138]: arguments to dbus_connection_get_object_path_data() were incorrect,
                        #   assertion "connection != NULL" failed in file dbus-connection.c line 5921.
                        #   This is normally a bug in some application using the D-Bus library.
                        #   D-Bus not compiled with backtrace support so unable to print a backtrace

    hciconfig hci0 up
    hciconfig           #hci0:  Type: Primary  Bus: USB
                        #       BD Address: 3C:21:9C:46:1F:C1  ACL MTU: 1021:4  SCO MTU: 96:6
                        #       UP RUNNING

    hcitool dev             #Devices: hci0    3C:21:9C:46:1F:C1
    hcitool scan

    rfkill block bluetooth
    rfkill unblock bluetooth

Debian - Docker

Common Commands:

      run         # Create and run a new container from an image
      exec        # Execute a command in a running container
      ps          # List containers
      build       # Build an image from a Dockerfile
      pull        # Download an image from a registry
      push        # Upload an image to a registry
      images      # List images
      login       # Log in to a registry
      logout      # Log out from a registry
      search      # Search Docker Hub for images
      version     # Show the Docker version information
      info        # Display system-wide information


  sudo docker ps -a                                                                        # to list available containers
     NAMES
        homeassistant
        esphome
        mosquitto
        portainer

  sudo docker exec -it homeassistant /bin/bash                                             # to run command in container
  sudo docker exec -it mosquitto /bin/sh                                                   # to run interactive shell in command in container (bash/ksh don't work)
  sudo docker exec -it mosquitto [mosquitto_passwd] /mosquitto/config/mqttuser [username]  # to run command in container

/opt/docker-compose.yaml

  homeassistant:
    volumes:
      - /run/dbus:/run/dbus:ro     # to map bluetooth to HA docker
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0  # to map ttyUSB0 to HA docker
  esphome:
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0  # to map ttyUSB0 to ESPhome docker

Docker CMD

    sudo docker-compose -f /opt/docker-compose.yaml config                    # check config
    sudo docker-compose -f /opt/docker-compose.yaml restart                   # RESTART ALL
    sudo docker-compose -f /opt/docker-compose.yaml stop    homeassistant     # STOP one container
    sudo docker-compose -f /opt/docker-compose.yaml up -d   homeassistant     # START one container
    sudo docker-compose -f /opt/docker-compose.yaml restart homeassistant     # RESTART one container
    sudo docker-compose -f /opt/docker-compose.yaml rm      homeassistant     # DELETE one container

    sudo docker exec -it homeassistant /bin/bash  # to run bash in context of docker
    sudo docker exec -it esphome /bin/bash        # to run bash in context of docker

   PULL 
      sudo docker-compose -f /opt/docker-compose.yaml pull                    # Update all images
      sudo docker-compose -f /opt/docker-compose.yaml up -d                   # Update all containers
      sudo docker-compose -f /opt/docker-compose.yaml pull  homeassistant     # Update single image
      sudo docker-compose -f /opt/docker-compose.yaml up -d homeassistant     # Update single containers

    sudo docker pull ghcr.io/home-assistant/home-assistant:stable  # doesnot restart container - use Portainer to restart
    sudo docker pull ghcr.io/esphome/esphome:stable                # doesnot restart container - use Portainer to restart

   PRUNE
      # The Docker prune command automatically removes the resources not associated with a container. 
      # This is a quick way to get rid of old images, containers, volumes, and networks.
      # You can use additional indicators with this command:
      #     Add -a to display all resources, 
      #     And -q to display only ID
      #     Add -f to bypass confirmation dialog
      # See: https://hub.docker.com/r/linuxserver/homeassistant
      #
      sudo docker images                                              # list images (all - including unused images)
      sudo docker-compose -f /opt/docker-compose.yaml images          # list images (active images only)
      sudo docker system prune                                        # do cleanup
      sudo docker-compose -f /opt/docker-compose.yaml system prune    # do cleanup ??

Docker - Portainer

    http://IP:9000
    https://IP:9443

Docker - HomeAssistant

    http://IP:8123
    sudo chmod g+w /opt/homeassistant/config/configuration.yaml   #add write permission for group

Docker - mosquitto - MQTTRed

    docker exec -it mosquitto mosquitto_passwd /mosquitto/config/mqttuser homeassistant  ## to generate new user/password entry in existing file
    docker compose restart mosquitto
  • IP :
  • USER :
  • passwords file : /opt/mosquitto/config/mqttuser
    mosquitto_passwd # is a tool for managing password files for mosquitto.
       Usage: mosquitto_passwd [-H sha512 | -H sha512-pbkdf2] [-c | -D] passwordfile username
              mosquitto_passwd [-H sha512 | -H sha512-pbkdf2] [-c] -b passwordfile username password
              mosquitto_passwd -U passwordfile
         -b : run in batch mode to allow passing passwords on the command line.
         -c : create a new password file. This will overwrite existing files.
         -D : delete the username rather than adding/updating its password.
         -H : specify the hashing algorithm. Defaults to sha512-pbkdf2, which is recommended. Mosquitto 1.6 and earlier defaulted to sha512.
         -U : update a plain text password file to use hashed passwords.
         See https://mosquitto.org/ for more information.
     Example:
         >./mosquitto_passwd -c -b /mosquitto/config/mqttuser NEW_USER_NAME NEW_PASSWORD

Docker - ESPhome

    http://IP:6052

    -----------------------------------
    ESPHome SECRETS FILE : /opt/esphome/config/secrets.yaml
    -----------------------------------
        wifi_ssid: "ssid_name_1"
        wifi_password: "psk_pwd_1"
        wifi_ssid_bolesov_c6: "ssid_name_2"
        wifi_password_bolesov_c6: "psk_pwd_2"
        fallback_ap_default_password: "ap_pwd"
        ota_password: "ota_pwd"

    -----------------------------------
    ESPHome device configulation file :
    -----------------------------------
        ota:
          # https://esphome.io/components/ota/esphome
          # At least one platform must be specified for 'ota'; add 'platform: esphome' for original OTA functionality
          - platform: esphome
            password: !secret ota_password

        wifi:
          # MULTIPLE WIFI accessspoint(-s) : 
          # see : https://community.home-assistant.io/t/wifi-multiple-networks-specific-ssid/537202
          # defines : /opt/esphome/config/secrets.yaml
          networks:
            - ssid: !secret wifi_ssid
              password: !secret wifi_password
            - ssid: !secret wifi_ssid_2
              password: !secret wifi_password_2

        wifi:
          # Enable fallback hotspot (captive portal) in case wifi connection fails
          # defines : /opt/esphome/config/secrets.yaml
          ap:
            ssid: "xxxxxxxx"
            password: !secret fallback_ap_default_password

Ubuntu - install on NUC

        10.10.10.105 - ETH 
        10.10.10.106 - WIFI (4C-44-5B-E0-CF-72)
  • install
        sudo apt update && sudo apt upgrade

        sudo apt install iputils-ping        ## PING
        sudo apt install network-manager

        # https://cockpit-project.org/ 
          /etc/os-release
          sudo apt install -t ${VERSION_CODENAME}-backports cockpit
          sudo apt install -t jammy-backports cockpit  # substitudted,  URL:(https://10.10.10.106:9090)


        ## https://askubuntu.com/questions/1214225/can-i-install-ubuntu-server-package-in-ubuntu-desktop
        sudo apt update && sudo apt upgrade
        sudo apt install ubuntu-desktop    
        sudo apt install ubuntu-server      ## unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
        # PREPARE 

        # Add Docker's official GPG key:
        sudo apt-get update
        sudo apt-get install ca-certificates curl gnupg
        sudo install -m 0755 -d /etc/apt/keyrings
        curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
        sudo chmod a+r /etc/apt/keyrings/docker.gpg


        # Add the repository to Apt sources:
        echo           "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu 
          $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | 
          sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

        # check file contents for (/etc/apt/sources.list.d/docker.list) : 
        #deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu   jammy stable          

        sudo apt-get update

        # DOCKER INSTALL :
        sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  • Enable/Disable SSH - TOOD
  • Enable/Disable WiFi - TOOD
  • Enable/Disable mDNS - TOOD
  • .profile
            if [ $SHELL = '/bin/ksh' ] 
            then 
                export HOSTNAME=$(hostname)
                #PS1=$(print '\033[33m[$HOSTNAME]\033[32m${PWD}\033[35m>\033[00m')
                PS1=$(printf '\033[32m${PWD}\n\033[33m[$HOSTNAME]\033[35m>\033[00m')
            fi

            if [ $SHELL = '/bin/sh' ] 
            then 
                export HOSTNAME=$(hostname)
            fi

            # '\033[32m' green
            # '\033[33m' yellow
            # '\033[35m' magenta
            # '\033[00m' white
            PS1=$(printf '\033[32m[$SHELL - $LOGNAME] ${PWD}\n\033[35m>>\033[00m')

HA - bluetooth_le_tracker

# -------------
# https://www.home-assistant.io/integrations/bluetooth_tracker/
# -------------
# In some cases it can be that your device is not discovered. 
# In that case let your phone scan for Bluetooth devices while you restart Home Assistant. 
# Just hit Scan on your phone all the time (or keep the Bluetooth device view open on an iOS device) 
# until Home Assistant is fully restarted and the device should appear in '''known_devices.yaml'''
#
#bluetooth_tracker.update service
# The bluetooth_tracker.update service can be used to manually trigger a Bluetooth scan. 
# An example of when this service can be useful is to trigger scans based on other events like doors being opened, 
# beacons are in range or buttons are pressed.

device_tracker:
  - platform: bluetooth_tracker
    device_id: 1                     # integer (Optional) - The ID of the Bluetooth adapter to be used by the tracker, 
                                     # e.g., use 0 for hci0, 1 for hci1, and so on. Default: -1 (The first available Bluetooth adapter)
    interval_seconds: 35
    request_rssi : true              # boolean (Optional, default: false) 
                                     #  - Performs a request for the “Received signal strength indication” (RSSI) of each tracked device.
    consider_home: 120
    new_device_defaults:
      track_new_devices: false

# -------------
# https://www.home-assistant.io/integrations/bluetooth_le_tracker/
# https://community.home-assistant.io/t/bluetooth-le-tracker-tons-of-discovered-devices/510751/4
# -------------
device_tracker:
  - platform: bluetooth_le_tracker
    interval_seconds: 25                #integer (Optional, default: 12) - Seconds between each scan for new devices.
    #track_battery : true                # boolean (Optional, default: false) 
                                         #    - Whether the integration should try to read the battery status for tracked devices.
    #    track_battery_interval : 1day   # time (Optional, default: 1 day) - Minimum interval to ask the device for its battery status. 
                                         # The battery status will be checked at most once every interval. 
                                         #    If track_battery is false, this will be ignored.
    consider_home: 120
    new_device_defaults:
      track_new_devices: true           # boolean (Optional, default: false) - If new discovered devices are tracked by default.

Home Assistant - Windows Portable (HassWP)


ESPhome - on windows

                pip3 install wheel
                pip3 install esphome

ESPHome - ADDING NEW DEVICE

  • basic firmware flashing : https://web.esphome.io - doesnot work in FF, but in EDGE is able to detect devices on COMx ports
  • disconnect from noebook USB port and provide external 5V power supply
  • Connect to default device WiFi AP (ex. from mobile phone) and connect to home wifi network (SSID and PASSWORD)
  • in HomeAssistant >> ESPHome - device (ex. esphome-web-5e59c0) appears as DISCOVERED
  • in HomeAssistant >> ESPHome - click ADOPT
  • DISCOVERED >> ellipsis >> Rename hostname - provide new hostname (ex. device-name)
    • this will compile and upload new firmware to device
  • DISCOVERED >> LOGS - to discover device parameters (ex. MAC, IP, dallas addresses [0xed000004b65dce28], ...)
  • in HomeAssistant >> ESPHome >> [device-name] >> (ellipsis) >> Rename hostname ==> "device-name" ... this will recompile and install via OTA
  • in HomeAssistant >> ESPHome >> [device-name] >> EDIT - rename in (wifi:ap:ssid:) ==> "device-name"

HomeAssistant - adding new Integration

  • prerequsities : device congigured in ESPHome (see logs)
  • in HomeAssistant >> Settings >> Devices & Services >> tab Integrations - is DISCOVEDED device (ex. my-esp32-cam)
    • on DISCOVEDED device BOX - press CONFIGURE button - and paste Encryption key (from /opt/esphome/config/my-esp32-cam.yaml) ==> device is moved to ESPHome BOX
  • in HomeAssistant >> Settings >> Devices & Services >> tab Integrations >> ESPHome BOX >> my-esp32-cam - click 1 device - and then click ADD TO DASHBOARD

DEVICES

  • for logged users only ...
Edit - History - Print - Recent Changes - Search
Page last modified on 2024-09-12 18:42