smarthome

Install Home Assistant on Raspberry Pi

Install Home Assistant on Raspberry Pi
https://www.home-assistant.io/installation/raspberrypi/

# Install rpi-imager
sudo apt install rpi-imager
 
# Create Homeassistant SD-Card
# Other specific-purpose OS > Home assistants and home Automation > Home Assistant OS
 
# Connect to HA
http://YOUR_HOME_ASSISTANT_IP:8123/
 
# Create Home Assistant account
 
# Install SSH plugin in Add-on-Store
http://YOUR_HOME_ASSISTANT_IP:8123/hassio/addon/core_ssh/info
 
# Open SSH Web CLI
http://YOUR_HOME_ASSISTANT_IP:8123/hassio/ingress/core_ssh
 
# get wifi data from workstation
WIFI_SSID="$(nmcli dev wifi show-password | grep SSID | cut -d' ' -f2-)" 
WIFI_PASS="$(nmcli dev wifi show-password | grep Pass | cut -d' ' -f2-)"
echo ha network update wlan0 \
  --ipv4-method auto \
  --wifi-auth wpa-psk \
  --wifi-mode infrastructure \
  --wifi-ssid \'${WIFI_SSID}\' \
  --wifi-psk \'${WIFI_PASS}\'
 
# paste output to SSH online console 
 
# debug
ha network info

Enable SSH key to hypervisor (Raspberry Pi)
https://community.home-assistant.io/t/howto-how-to-access-the-home-assistant-os-host-itself-over-ssh/263352/6

Home Assistant MQTT

Install MQTT broker (server) on Anroid
https://apkpure.com/mqtt-broker-app/server.com.mqtt/download

Create MQTT sensor
https://www.home-assistant.io/integrations/sensor.mqtt/

# ~/.homeassistant/configuration.yam
# /mnt/data/supervisor/homeassistant/configuration.yaml (on Raspery PI)
...
mqtt: !include inverter.yaml
 
# inverter.yaml
  sensor:
    - name: "Inverter AC Power"
      unique_id: "inverter_ac"
      state_topic: "inverter/HM/ch0/P_AC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter DC Power"
      unique_id: "inverter_dc"
      state_topic: "inverter/HM/ch0/P_DC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter DC Power CH1"
      unique_id: "inverter_dc_ch1"
      state_topic: "inverter/HM/ch1/P_DC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter DC Power CH2"
      unique_id: "inverter_dc_ch2"
      state_topic: "inverter/HM/ch2/P_DC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter Yield Day"
      unique_id: "inverter_yield_day"
      state_topic: "inverter/HM/ch0/YieldDay"
      unit_of_measurement: "Wh"
    - name: "Inverter Yield Total"
      unique_id: "inverter_yield_total"
      state_topic: "inverter/HM/ch0/YieldTotal"
      unit_of_measurement: "kWh"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter Temperature"
      unique_id: "inverter_temperature"
      state_topic: "inverter/HM/ch0/Temp"
      unit_of_measurement: "°C"
      icon: "mdi:thermometer"

Install mosquitto (MQTT broker) on Raspery PI OS as docker container

Node-RED

https://nodered.org/

Termux (run Node-RED on Android)
https://nodered.org/docs/getting-started/android
https://github.com/termux/termux-app

# Install termux
https://github.com/termux/termux-app/releases/download/v0.118.0/termux-app_v0.118.0+github-debug_armeabi-v7a.apk

pkg upgrade
pkg install openssh
whoami
passwd
 
ssh u0_a114@192.168.178.222 -p 8022
~ $ echo  "ssh-rsa xxxxx" >> ~/.ssh/authorized_keys 
 
apt update
apt dist-upgrade
apt install -y vim
apt install -y coreutils
#apt install -y nodejs
#apt install -y termux-api
npm install -g node-red
 
node-red &
 
npm i node-red-node-ui-table node-red-dashboard

http://192.168.178.222:1880/

Links
https://nodered.org/docs/getting-started/android

Home Assistant

Install Home Assistant as Docker container
https://www.home-assistant.io/installation/linux#platform-installation

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Berlin \
  -v homeassistant:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable
 
# volume path
# /var/lib/docker/volumes/homeassistant

Configure
http://127.0.0.1:8123

Install HACS

sudo docker exec -it homeassistant bash
wget -O - https://get.hacs.xyz | bash -

Addons / Plugins
LocaTuya: https://github.com/rospogrigio/localtuya/

custom_zha_quirks
https://smarthomescene.com/reviews/tuya-zigbee-single-clamp-energy-meter-review/

Zigbee / SmartHome

homebridge

cat <<EOF> docker-compose.yml 
version: '2'
services:
  homebridge:
    image: oznu/homebridge:latest
    restart: always
    network_mode: host
    volumes:
      - ./volumes/homebridge:/homebridge
    logging:
      driver: json-file
      options:
        max-size: "10mb"
        max-file: "1"
EOF
 
sudo docker-compose up -d

Setup
http://localhost:8581

Tuya
https://github.com/0x5e/homebridge-tuya-platform

npm install @0x5e/homebridge-tuya-platform

Yamaha
https://github.com/cgierke/homebridge-musiccast

Links
https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Docker