HA: Difference between revisions

From Network Security Wiki
Content added Content deleted
Line 63: Line 63:
docker stop home-assistant
docker stop home-assistant
docker rm home-assistant
docker rm home-assistant
Start the [https://aman.awiki.org/wiki/HA#HomeAssist_Docker_Install Container]
docker run -d --network=host --name home-assistant -v /path/to/local/config:/config homeassistant/home-assistant


* Regenarate SSH Keys
* Regenarate SSH Keys

Revision as of 01:03, 11 May 2024


Installation

HomeAssist Docker Install

Source: home-assistant.io

  • Installation:
sudo docker run -d \
 --name homeassistant \
 --privileged \
 --restart=unless-stopped \
 -e TZ=Europe/Dublin \
 -v /home/pi/homeassist/config:/config \
 -v /run/dbus:/run/dbus:ro \
 --network=host \
 ghcr.io/home-assistant/home-assistant:stable

Install HACS

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

Certificates

Manual

Install Certbot:

sudo apt install certbot

Request Certificate:

sudo certbot certonly -d haos.uk.to


Install Certitficate:

sudo nano configuration.yaml
http:
 ssl_certificate: /ssl/fullchain.pem
 ssl_key: /ssl/privkey.pem

Automatic

        This section is under construction.


Upgrade Docker Instance

Source: home-assistant.io

  • Backup Config
  • Upgrade Instance:

If this returns Image is up-to-date, you can stop here:

docker pull ghcr.io/home-assistant/home-assistant:stable
docker stop home-assistant
docker rm home-assistant
Start the Container
  • Regenarate SSH Keys

Notifications

Telegram

####################################################
#                    Telegram                      #
####################################################

# Telegram Bot
telegram_bot:
  - platform: polling
    api_key: "xxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxx"
    allowed_chat_ids:
      - xxxxxxxx     # Rpiwz Personal Chat
      - -xxxxxxxx     # My Family Group Chat

# Notifier
notify:
  - platform: telegram
    name: "mychat"
    chat_id: xxxxxxxxxxx

  - platform: telegram
    name: "mygroup"
    chat_id: -xxxxxxxxx

Sensors

CPU Temperature

####################################################
#                  Command Line                    #
####################################################
# Pi Temperature
command_line:
  - sensor:
      command: "cat /sys/class/thermal/thermal_zone0/temp"
      name: HA CPU Temperature
      unit_of_measurement: "      C"
      value_template: '{{ value | multiply(0.001) | round(1) }}'



SSH Based Sensor

Goto Docker Container:

sudo docker exec -it homeassistant bash

Enable Keyless SSH Access:

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub pi@192.168.1.2
ssh-copy-id -i ~/.ssh/id_ed25519.pub pi@192.168.1.2

Test SSH Keyless from container:

ssh pi@192.168.1.2

Sensor Config:

command_line:
  - sensor:
      command: "ssh pi@192.168.1.2 '/usr/bin/python3 /home/pi/homeassist/pmm_time_taken.py'"
      name: PMM Time Taken
      unit_of_measurement: "s"
      value_template: '{{ value }}'
      scan_interval: 86400


References





{{#widget:DISQUS |id=networkm |uniqid=HA |url=https://aman.awiki.org/wiki/HA }}