ByKaj / homeassistant-config

Home Assistant configuration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Home Assistant Configuration

Maintenance GitHub last commit GitHub

This is my configuration for Home Assistant.

Installation

Steps and information tailored to a Home Assistant installation on HassOS.

Prerequisites

  1. Installed Supervisor add-ons:

SSH & Web Terminal configuration

The RSA key pair used below is created on your local PC. The private key is added to your local ssh-agent, the public key is used on the Home Assistant server.

ssh:
  username: <username>
  password: ''
  authorized_keys: ['ssh-rsa    <key>   <comment>']
  sftp: false
  compatibility_mode: false
  allow_agent_forwarding: false
  allow_remote_port_forwarding: false
  allow_tcp_forwarding: false
zsh: true
share_sessions: false
packages: []
init_commands: []

You can also use an username and password (less secure!) instead of a SSH key. Change the configuration as follows:

ssh:
  username: <username>
  password: <password>
  authorized_keys: []
...

Backup configuration to GitHub

  1. Go to https://github.com/new and create a new repository (eg. homeassistant-config). Initialize with readme: no and .gitignore: none.

  2. Navigate to your config directory. For HassOS it should be in /root/home/config.

  3. Run wget https://raw.githubusercontent.com/<username>/homeassistant-config/main/.gitignore to get the .gitignore file from your repo (replace the link to match your repository). You can add things to your .gitignore file that you do not want to be uploaded.

  4. Next, we need to add SSH keys to your GitHub account.

    • Run ssh-keygen -t rsa -b 4096 -C "<email address>". If you want to enter a passphrase, that's up to you. If you do, you'll have to enter that passphrase any time you want to update your changes to GitHub. If you do not want a passphrase, leave it blank and just hit Enter.
    • Save the key in the default location (press Enter when it prompts for location).
    • When you're finished, run ls -al ~/.ssh to confirm that you have both id_rsa and id_rsa.pub files.
    • Go to https://github.com/settings/keys and click New SSH key button at top right. Title: Home Assistant Server (or whatever you want, really...it's just for you to know which key it is).
    • Run cat id_rsa.pub in the SSH session and copy/paste the output to that GitHub page.
    • Then click Add SSH key button.
  5. Go back to your repo page on GitHub. It'll be something like https://github.com/<username>/homeassistant-config. Click the green Clone or download button, and then click Use SSH.

  6. You should see something like this in the textbox: git@github.com:<username>/homeassistant-config.git. Copy that to your clipboard.

  7. Now you are ready to upload the files to GitHub.

    • Navigate to your configuration files cd ~/config and:
       git init
       git add .
       git commit -m 'Initial commit'
    • If you get an error about *** Please tell me who you are., run git config --global user.email "your@email.here" and git config --global user.name "Your Name"
    • After that commit succeeds, run: git remote add origin git@github.com:<username>/homeassistant-config.git.
    • Just to confirm everything is right, run git remote -v and you should see:
      origin  git@github.com:<username>/homeassistant-config.git (fetch)
      origin  git@github.com:<username>/homeassistant-config.git (push)
    • Finally, run git push origin main.
  8. For subsequent updates:

    git add .
    git commit -m 'Your commit message'
    git push origin main
  9. To manual restore from your GitHub repository:

    git clone git@github.com:<username>/homeassistant-config.git ~/config

Source used: HASS Cheatsheet by @arsaboo

Git Pull configuration

Configuration with auto restart of Home Assistant and auto pulling your GitHub repository for changes enabled.

WARNING: Only activate this add-on when your repository holds your initial commit. Otherwise it'll wipe your configuration and you probably don't want that...

The deployment key is the private key in id_rsa created in the previous backup procedure. Take note of the key format.

deployment_key:
  - '-----BEGIN OPENSSH PRIVATE KEY-----'
  - b3BlbnNzaC1rZXktdjEABBBABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn
  - NhAAAAAwEMAQAAAgEAs+gC1QehlpEymiGPSnhVMwZZJi2nljLlu644G2h9tE7FVn2TG0XR
  - ...
  - KvxjOuF7exeHN2WaW2zkUE9oP6aeaCfSk6XxxAq9YQVQD6BjY83zQPNaB8mk/jmkHH1C6V
  - x/ph2cL0aoo1AAAAE2dpdGh1YkBrYWp2aXNzZXIubkvBAgMEBQYH
  - '-----END OPENSSH PRIVATE KEY-----'
deployment_key_protocol: rsa
deployment_user: ''
deployment_password: ''
git_branch: main
git_command: pull
git_remote: origin
git_prune: false
repository: 'git@github.com:<username>/homeassistant-config.git'
auto_restart: true
restart_ignore:
  - ui-lovelace.yaml
  - .gitignore
  - appdaemon/
  - dashboards/
  - docs/
repeat:
  active: true
  interval: 300

License

MIT

About

Home Assistant configuration.

License:MIT License


Languages

Language:JavaScript 70.6%Language:Python 26.6%Language:HTML 2.5%Language:CSS 0.3%