Hass.io Tips & Tricks

Hass.io Install


Standard install

Prepare SD Card (16G) with Etcher. Use wired LAN for initial boot up’s.
Setup router’s DHCP to staticly assign same IP for RPI on wired connection.
Now, monitor progress at page: Preparing Hass.io for 20 mins

WiFi Setup

Bitno! Hassio instalaltion Wifi configuration - Hass.io - Home Assistant Community

You can now create a folder “CONFIG” on the boot partition instead of using a USB stick. Then, create the folder “network”, and place the “my-network” file inside of that.


Sve objašnjeno hassos/configuration.md at dev · cschroeter/hassos hassos/network.md at dev · cschroeter/hassos

As it will be used mostly on WiFi, setup static address to

You can do it via SD-Card boot partition during boot procedurte, as explained above, or later with USB via Import procedure, but in that case you must boot with wired LAN first.

USB drive must be labeled “CONFIG” with folder “network” and any filename without extension (mine was: network-settings). The file content must be with Linux line endings and such.





Sources: here and hassos/network

Zigbee Pairing problems

Device can be in some way “partially” paired to the coordinator.

When you have pairing problems: Pairing RTCGQ11LM: adding modelId to database fixes sensor, but why? · Issue #1223 · Koenkk/zigbee2mqtt Try: (1) Stop zigbee2mqtt, (2) Remove all entries from database.db, (3) Start zigbee2mqtt You can also rress the reset button on the zigbee2mqtt stick (the one closest to the USB) and start again.

Best procedure is explained here: MCCGQ01LM: Device with modelID ‘undefined’ is not supported. · Issue #934 · Koenkk/zigbee2mqtt Error: Timed out after 10000 ms · Issue #936 · Koenkk/zigbee2mqtt

Or here (model lumi.sensor_86sw1\u0000lu): Xiaomi Zigbee switches working with zigbee-shepherd · Issue #26 · zigbeer/zigbee-shepherd

Explore mtqq Tools

Woow: MQTT Explorer | Tool to visualize your MQTT topics, a MQTT swiss-army knife A savrđeno takođe: Tasmota Device Manager jziolkowski/tdm: GUI application to discover and monitor devices flashed with https://github.com/arendst/Sonoff-Tasmota ali teško to ide na Windows

Old devices

Q: Remove old devices on hass.io A: Probably mqtt

If this is about clearing retained messages, this is what i always do (have some mileage here unfortunately…)

first check for the messages to show their exact origin and syntax:

mosquitto_sub -h -p 1883 -u upravitelj -P upravitelj4mosquitto -v -t -d -R ‘#’

then clear these with:

End random “ghost switching” for good by fixing your retain settings in tasmota and home assistant. – The Fix Random Switching in Tasmota by Adjusting Retain Settings - YouTube

How to clear retained messages in mosquitto?

At the end: PowerOnState Configuration · arendst/Sonoff-Tasmota Wiki

Clearing MQTT retained messages - Tutorials & Examples - openHAB Community

Deleting Mosquitto MQTT retained messages | Making the Puzzle Pieces Fit

CLI: mosquitto_pub -h -p 1883 -u upravitelj -P upravitelj4mosquitto -t “homeassistant/device/whatevercomesnext” -r -n

-n = Send a null (zero length) message -r = Retain the message as a “last known good” value on the broker

From UI: service: mqtt.publish data: {“topic”:“topic/to/clear”, “retain”: true}

Može i ovo da se podesi: clear-mqtt-from-HA

How to unregister entity

You will need to do the following.

  1. First stop Home Assistant. Do that in ssh with hassio ha stop or via GUI: Configuration > General > Server management: Stop
  2. Manually edit the .storage/core.entity_registry file to remove the entities
  3. Start Hass again from shh with hassio ha start

I think that sometimes you need to clean something in .storage/core.device_registry also

Maybe: Go to Configuration-> Entity Registry, edit the old devices and click on remove to get rid of the old entity.

Lovelace UI

If editing Dashboard UI (lovelace) and wants to revert it to automatic, just remove file config/.storage/lovelace

Misc errors

Pi-Hole: Failed Host Check

Set virtual_host in configuration to your domain hassio-penthouse.duckdns.org. And restart Pi-hole.

Custom Components

Go to the directory where your configuration.yaml is and create a new directory called custom_components as explained in dev docs. Make sure the permissions of the folder and component are correct.

Most of interesting components are already listed here, but I’ve found some not mentioned there:

IR Remotes

Custom component smartHomeHub/SmartIR is better than integrated Broadlink component and also supports Xiaomi IR Remote. Can be installed and maintained using HACS as a custom repository, but then you must disable self-update in configuration, see here).

Tools to learn IR codes

I’ve used online tool that is simple and works: Broadlink Tools by Keite Trần with the following parameters:

Hass Address: https://hassio-penthouse.duckdns.org:8123

Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwMzlmZDQxZWEzZDc0YWJmYjI1ZjQzMThiMGE2MGFhMSIsImlhdCI6MTU1NDA3ODcyNywiZXhwIjoxODY5NDM4NzI3fQ.Kpoxsj4chO9RmK-N1xmG7MSB1c6Cd19CJOMhC-eGJ1c
Broadlink service: broadlink_learn_command_192_168_0_75

As for desktop Windows tools, the recommended one for learning IR codes is Broadlink Manager

You can also use default android app and then convert codes to YAML for Hassio with Broadlink e-control to yaml 143

Sonoff Setup

Set timer on Tasmota & Sonoff

ARM means Enabled (“Armed”). Really misleading terminology. Da bi proverio da li je dobro podešeno trenutno vreme, kucaj Console > Status 7.

:::warning Latency was simply unacceptable 😞 :::

There is nice project that uses Ewelink Cloud so there is no need to flash firmware

First, mount network from Hass.io in my WSL:

sudo su -
mkdir -p /mnt/hassio/config
mount -t drvfs '\\\config' /mnt/hassio/config
cd /mnt/hassio/config

mkdir -p custom_components
cd custom_components

wget -O master.zip https://github.com/$REPO/archive/master.zip
unzip master.zip
rm master.zip

mkdir -p sensor switch
mv *-master/sonoff.py .
mv *-master/sensor/sonoff.py sensor
mv *-master/switch/sonoff.py switch
rm -rf *-master

# and then the folder structure changed
mkdir sonoff
cp sonoff.py sonoff/__init__.py
cp sensor/sonoff.py sonoff/sensor.py
cp switch/sonoff.py sonoff/switch.py
rm -rf switch/
rm -rf sensor/
rm -rf sonoff.py 

To use it, enter the following into HA’s configuration.yaml:

# Sonoff support
  username: !secret sonoff_user
  password: !secret sonoff_pass

Sonoff Local LAN Mode

:::warning I’ve never made this one work 😞 :::

What is LAN mode, officialy explained from eWeLink site

Custom component that is using only stock firmware, without flashing by exploiting local Sonoff’s LAN Mode.

Just one file: custom_components\sonoff_lan_mode\switch.py

beveradb/sonoff-lan-mode-homeassistant: Home Assistant platform to control Sonoff switches running the latest Itead firmware, locally (LAN mode).

Raspberry Pi Power Supply

If you have other things plugged in to USB that are drawing power like keyboard, wifi, bluetooth, etc you should use 2.4A-2.5A, but otherwise 2A is fine.

I was measuring power usage on my Xiaomi Smart Power Strip, and it is at max drawing 3.1W, and that is 3.1W/5V ~ 0.6A, so I have a lot of room left.

No need to buy special power supply.


Xiaomi Device Token

How to discover Xiaomi API key also called Token?

Newest (2021) and finally always-working tool: PiotrMachowski/Xiaomi-cloud-tokens-extractor

Past solutions follow…

miio tool on RPi3

For that, we need to install the tool. On normal Linux, it is as easy as typing sudo npm install -g miio. But on Hass.io on Raspberry Pi, we must use Docker plus specific for RPi3 builds.

More about this utility: aholstenson/miio

So to start, we need to disable protecton mode on SSL add-on.

The simplest way to make it work, as it doesn’t work on WSL Docker. Then login to SSH and execute:

docker run --name miio --network host --rm -it --entrypoint=/bin/bash defozo/miio-cli-docker-armv71
miio discover
docker ps -a

Debug version of miio: DEBUG=miio\*,thing\* miio discover

docker run --privileged --network host --rm -it --entrypoint=/bin/bash defozo/miio-cli-docker-armv71

Device can not be discovered · Issue #92 · aholstenson/miio

Using Packet Sniffing

Quite reliable way to obtain token is by using packet sniffing with Packet Sender (com.xiaomi-miio/obtain_token.md). Take HEX result packet and get last 32 chars (16 pairs), for example:

# HEX: 21 31 00 20 00 00 00 00 02 E5 23 A8 00 00 00 76 E2 B4 E3 3F 77 C2 B8 D2 E4 91 F2 E2 36 3B 80 2D

Xiaomi Motion Sensor Timeot

There are some real problems.

  • Motion is detected and reported only every 2 minutes / 120 seconds
  • The humidity sometimes can blin the sensor

Hardware modification

This can even modded using using graphite pencil (you can use a 4B pencil).

Xiaomi motion sensor is detected every two minutes (or maybe one minute), by hardware. But by connecting just two points, you can change that time to 5 seconds. Not a real problem for the battery as modified Xiaomi motion sensors lasted at least 369 days.

If you press the reset button on the side of motion sensor, it will report at intervals of 5 seconds for several hours. But in a few hours, Xiaomi Motion will report every two minutes.

Making Xiaomi Motion Sensor a Super Motion Sensor

This mod triggers the “calibration/position mode” of the sensor (always). It’s normally used once to find a good position for the motion sensor.

For hardware modified sensor, you must also change occupancy_timeout: 10 in zigbee2mqtt, as mentioned here


Xiaomi Wall Switch Decoupled mode

Decoupled mode allows to turn wired switch into wireless button with separately controlled relay.


Google Assistant

I’m using free setup explained here: Configure Google Assistant for Home Assistant: Paid and Free Options

:::danger At some point, you’ll need to authorize access on phone. For that, ensure there is no Hass.io shortcut created on home screen, as that will prevent valid authorisation. :::

Database problems

Delete database

If database gets too big, yes, it’s safe to delete home-assistant_v2.db and after that restart Hass. Deleting it fixes a multitude of problems with the downside only that you lose your history. Its a good idea to stop HA before deleting the database. HAss creates a new database on start.

HAss cannot restore the last states with a new database, so check that.

Automatic purge

Configuration options on Recorder

  purge_interval: 1
  purge_keep_days: 28

Automatic purge function of the db sometimes takes 24 hours to run. So if Hass is restarted anytime within that 24 hours it restarts the 24 hours timer.

I can also call a service recorder.purge with repack set to true, with this payload:

{“keep_days”:“2”, “repack”:“true”}

Maybe the best way is to create an automation like this one:

- alias: Database Purge
    platform: time
    at: '12:00:00'
    - service: recorder.purge
        keep_days: 10
        repack: true

The key is the repack option being set to true, otherwise, file size won’t be reduced.

Moving the database

This guy moved to external MySQL instance, but setting up local MariaDB with add-on was trivial.

We can even move to another SQLite file on network drive.

Entity & Device Registry

It happened to me couple of times that autmations wouldn’t work without any valid debug or explanation. It was so that somehow the Entity Registry was having some ‘stale’ values.

I solved those problems by deleting this file config\.storage\core.entity_registry as it gets recreated on host restart. After that, automations started working as expected. I’ve lost some naming customizations, that I wasn’t using anyway.

ip mac model name token 7C:49:EB:5A:1B:30 chuangmi.remote.v2 Mi Remote 36e5f85fe76480d7050b8d8f53f76ab6 F0:B4:29:BB:36:F4 zhimi.airpurifier.m1 Air Purifier ea266b3e9b6598365528fceb0d16c44d 28:6C:07:15:24:43 zimi.powerstrip.v2 Mi Smart Power Strip e2b4e33f77c2b8d2e491f2e2363b802d 34:CE:00:E9:63:88 rockrobo.vacuum.v1 Vacuum 6f706649665378665248737455463777 34:CE:00:13:E9:A6 xiaomi.repeater.v2 Mi WiFi Repeater 2 845b55ffbedf84b57b2742e4f6407a1a 7C:49:EB:7F:F4:EA lumi.acpartner.v3 Hub b665c3b67f7a313dd39762bc51011670

How I soldiered Xiaomi motion sensors to make them better

Making Xiaomi Motion Sensor a Super Motion Sensor - Devices & Integrations / Connected Things - SmartThings Community 내가 원하는데로 :: 샤오미 모션센서 슈퍼센서 만들기

Xiaomi Human / Body / Motion Sensor - Timeout - Configuration - Home Assistant Community Xiaomi Human / Body / Motion Sensor - Timeout - Configuration - Home Assistant Community

Detekcija Aqara senzora

do not recognize Aqara Human Body sensor RTCGQ11LM · Issue #885 · Koenkk/zigbee2mqtt · GitHub Unable to pair RTCGQ11LM · Issue #839 · Koenkk/zigbee2mqtt · GitHub

Details about every device Supported devices | zigbee2mqtt.io zigbee-shepherd-converters/fromZigbee.js at master · Koenkk/zigbee-shepherd-converters · GitHub

Hassio razno What can be reloaded without restarting? - Configuration - Home Assistant Community

Zigbee & Wifi

ZigBee and WiFi Coexistence — MetaGeek

Hassio Lovelace

Welcome! - community edition of example cards for Lovelace Lovelace UI - Home Assistant How to set up Lovelace on Home Assistant • JuanMTech custom-lovelace/monster-card at master · ciotlosm/custom-lovelace

Lovelace on Home Assistant - A simple guide to trying it out? : homeassistant ciotlosm/custom-lovelace: Custom cards for Lovelace UI in Home Assistant lovelace custom cards - Google Search

Example Hass configurations

https://git.ethitter.com/open-source/Home-Assistant-Config/tree/master GitHub - stanvx/Home-Assistant-Configuration: 🏡 My Home Assistant Configuration Files. Be sure to ⭐️ my repo! GitHub - CCOSTAN/Home-AssistantConfig: Home Assistant configuration & Documentation for my Smart House. Part list below. Be sure to it. Home-Assistant-Config/config/packages at master · JamesMcCarthy79/Home-Assistant-Config · GitHub

Nginx Proxy napraviti za Hassio

Set up Hass.io with secure remote access using DuckDNS and Nginx proxy: Konnected Help & Support DuckDNS/Lets Encrypt with NGINX Proxy Server: homeassistant

SSH into Hass.io host

  1. Copy public key to the server
  2. Login with ssh -vvvv root@ -p 22222 -i ~/.ssh/cvladan.ppk

Hass.io Configuration Under Git Version Control

Access using normal ssh or install hassio-addons/addon-ssh add-on and log into SSH.

cd /root/config

Follow this Community Guide: Sharing your configuration on GitHub

# warning: stored as plain-text in `~/.git-credentials` 
git config --global credential.helper store
date 19. Oct 2018 | modified 17. Jan 2023
filename: Hass.io Tips & Tricks