|
Embedded /
Home Assistant
OvervievHow 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
\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.
\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
see :
# 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)
# systemctl reboot
# 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
# bluetoothctl list
Controller 3C:21:9C:46:1F:C1 sd-ha [default]
# bluetoothctl show
# 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
# hcitool dev
Devices: hci0 3C:21:9C:46:1F:C1
/opt/docker-compose.yaml
homeassistant:
volumes:
- /run/dbus:/run/dbus:ro
# 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 - DockerCommon 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
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 - ESPhomehttp://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)
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
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)Links :
ESPhome - on windows
pip3 install wheel
pip3 install esphome
ESPHome - ADDING NEW DEVICE
HomeAssistant - adding new Integration
DEVICES
|