Home Assistant
Is an Home automation platform, runs on Python
Setup¶
Proxmox¶
- This scrip helps to set up a VM:
bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/vm/haos-vm.sh)"
Raspberry Pi¶
- Raspberry Pi 2 images are still present in GitHub releases
Ubuntu KVM¶
- Download the image here
- Decompress
xz --decompress FILE
- Move somewhere like
/var/lib/libvirt/images/hassos.qcow2
- Create the VM
sudo virt-install --name hassos --graphics vnc,listen=0.0.0.0 --memory=2048 --vcpus=2 --disk=/var/lib/libvirt/images/hassos.qcow2,format=qcow2 --boot uefi --import --os-variant=debian9 --network=bridge=br0
- Login in http://homeassistant.local:8123
TrueNAS SCALE¶
Source
1. Download the image here
2. Unzip it
3. Convert the image using VirtualBox: VBoxManage clonehd source/hassos_vm.vdi destination/hassos_vm.img --format raw
4. Copy the image to TrueNAS
5. Create a zvol
with ≥ 32 Gb
6. Create a VM
- Navigate to Virtual Machines add Virtual Machine (VM)
- Set Guest OS as Linux and Boot Method as UEFI
- Add number of Virtual CPUs and Memory size accessible to the VM (this can be modified later)
- Select Use existing disk image and select the Zvol created above
- Modify Network Adapter if needed (ie. in order to easily locate the NIC when router leases its IP)
- Don’t add installation image
7. Burn the image to the zvol
: dd if=/mnt/pool_name/dataset_name/location_of_hassos_vm/hassos_vm.img of=/dev/zvol/pool_name/zvol_name
HTTPS Setup¶
- Install Let's Encrypt add-on and follow the documentation
- Go to Configuration > General and define External URL and Internal URL
- Configure
configuration.yaml
yaml http: ssl_certificate: /ssl/fullchain.pem ssl_key: /ssl/privkey.pem
- Restart the server
Migrate to another server¶
- Set up the new Home Assistant server
- In the old one, go to backups and do a full one
- In the new one, import before creating a user (OS) or copy backup in
/config/
Enable reverse proxy like Cloudflared¶
Set up the HTTP Integration.
SMS Gateway via 3G/4G USB Modem Stick¶
- Official SMS integration which uses Gammu
- Device to use
- Send an SMS via the service:
- Receive SMS via the Event
sms.incoming_sms
- ⚠️ Listening to the event make the integration to switch to
Unavailable
- ⚠️ Listening to the event make the integration to switch to
- I used Huawei E3272 that needed to be reflashed to work with
Configuration¶
Lovelace¶
- Display an entity attribute:
type: entities
entities:
- type: attribute
entity: media_player.abc
attribute: sound_mode
Mobile app¶
- Reinstall the mobile app on a reset phone - source
- remove app from phone
- remove integration in HA via the UI
- redownload app and do onboarding
- after onboarding restart HA and keep your app alive (so screen on)
Integrations¶
Calendar from Nextcloud¶
- Useful to silence notification: just use a calendar to set "Silence" days
- Relevant integration page
- Events must have a name
- Configuration to show full days:
```yaml
calendar:
- platform: caldav
username: nextcloud_username
password: nextcloud_pass
url: https://nextcloud.com
custom_calendars:
- name: "Name for HA" calendar: "Nextcloud Name" search: ".*" ```
- platform: caldav
username: nextcloud_username
password: nextcloud_pass
url: https://nextcloud.com
custom_calendars:
Send SSH commands¶
Guide
- Setup SSH keys for passwordless authentication
- Store the keys
- NOT in ~/.ssh/
as it's not shared across containers
- In /config/.ssh/
so it get preserved across updates
- Set the known host in /config/.ssh/
for the same reason than keys
- Call the command with ssh HOST_CLIENT@HOST_IP -i /config/.ssh/HOST_privkey -o UserKnownHostsFile=/config/.ssh/HOST_known_hosts 'command'
- -i
to specify the private key (without .pub
)
- -o UserKnownHostsFile=/config/.ssh/HOST_known_hosts
to approve the hos
- If inexistent, it will be populated
- This can be used in Command Line integration or Shell Command integration
Receive sensors data from other systems¶
- Webhooks Template sensors can be set
```yml
template:
- trigger:
- platform: webhook
webhook_id: my-super-secret-webhook-id
allowed_methods:
- POST local_only: true sensor:
- name: "Webhook Temperature" state: "{{ trigger.json.temperature }}" unit_of_measurement: °C ```
- platform: webhook
webhook_id: my-super-secret-webhook-id
allowed_methods:
- trigger:
- A device can do a POST
Automations¶
Notifications¶
- Build Actionable notification
- Get an attribute value with a space: use
{{ states.sensor.abc.attributes["X Y Z"] }}
- Use Developer Tools → Services and Template to try out
Statistics¶
Clean the Statistics/Recorder database¶
Using the SSH add-on:
cd ~/config
sqlite3 home-assistant_v2.db
.header on
.mode column
.width 50, 10,
SELECT states_meta.entity_id as Entity, count(states.metadata_id) as Count FROM states INNER JOIN states_meta ON states.metadata_id = states_meta.metadata_id GROUP BY states.metadata_id ORDER BY count(states.metadata_id) DESC LIMIT 30;
Templates¶
"allows creating entities which derive their values from other data." - Templating documentation - Integration documentation
Monitor for broken automation¶
- Names can changes when updating Home Assistant
- The Watchman create reports to identify broken things
Development¶
Verbose logging¶
- The Logger integration can help understanding what's going on in Home Assistant or a custom component
- The Log Viewer Add-on can helps to monitor logs in realtime
Debugger¶
- The debugpy integration can connect to a Visual Studio Code instance remotely to see what's going on
- You need to clone the Home Assistant Core first to the used VSC folder
Documentation¶
- Home Assistant Developers wiki
- HACS - Home Assistant Community Store
- Ressources
- Repository of examples
- Icons: Material Design Icons - use it like
mdi:home
- Unit of Measurement list - const.py
Dev Setup¶
- Follow setup guide here
- Install Docker - Guide for Ubuntu and don't forget to give right
sudo usermod -a -G docker $USER
- Install Git
sudo apt install git -y
- Install Visual Studio Code: snap or
sudo snap install code --classic
- Install Docker - Guide for Ubuntu and don't forget to give right
- Then don't forget to check out a separate branch
- Start Home Assistant
hass -c config