Hass.io Tips & Tricks

Hass.io Tips & Tricks

Hass.io Install

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 http://192.168.0.110:8123/ 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.

/CONFIG/network/my-network

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 192.168.0.111

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.

[connection]
id=my-network
uuid=72111c67-4a5d-4d5c-925e-f8ee26efb3c3
type=802-11-wireless

[wifi]
mode=infrastructure
ssid=<WIFI_SSID>

[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=<WIFI_PASS>

[ipv4]
method=manual
address1=192.168.0.111/24,192.168.0.1
dns=1.1.1.1;1.0.0.1;

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 press 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

This ultimately helped with MCCGQ11LM - remove the battery and hold the reset button while inserting the battery, with the suggestion found here: Unable to repair aqara door sensor.

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 192.168.0.111 -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 192.168.0.111 -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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
sudo su -
mkdir -p /mnt/hassio/config
mount -t drvfs '\\192.168.0.111\config' /mnt/hassio/config
cd /mnt/hassio/config

mkdir -p custom_components
cd custom_components

REPO=peterbuga/HASS-sonoff-ewelink
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
#
sonoff:
  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

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 Timeout

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

Sources:

Xiaomi Wall Switch Decoupled mode

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

zigbee2mqtt.io

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 SQLite 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

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
  trigger:
    platform: time
    at: '12:00:00'
  action:
    - service: recorder.purge
      data:
        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
192.168.0.76 7C:49:EB:5A:1B:30 chuangmi.remote.v2 Mi Remote 36e5f85fe76480d7050b8d8f53f76ab6
192.168.0.74 F0:B4:29:BB:36:F4 zhimi.airpurifier.m1 Air Purifier ea266b3e9b6598365528fceb0d16c44d
192.168.0.73 28:6C:07:15:24:43 zimi.powerstrip.v2 Mi Smart Power Strip e2b4e33f77c2b8d2e491f2e2363b802d
192.168.0.72 34:CE:00:E9:63:88 rockrobo.vacuum.v1 Vacuum 6f706649665378665248737455463777
192.168.0.200 34:CE:00:13:E9:A6 xiaomi.repeater.v2 Mi WiFi Repeater 2 845b55ffbedf84b57b2742e4f6407a1a
192.168.0.148 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@192.168.0.111 -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

Zigbee2MQTT fails to start sometimes (CC2531 only)

The problem can occur with CC2531, and although this situation is explained in the official documentation Zigbee2MQTT fails to start | Zigbee2MQTT, it took me some time to find it.

The solution is to reset the CC2531 - by pressing the reset button on the device!

When you plug the CC2531 into your computer, the green LED should turn on. By pressing the reset button on the CC2531, the green LED should turn off. The CC2531 has 2 buttons on it, the reset button is the one closest to the USB port. Now, try starting Zigbee2MQTT again.


Flashing ConBee II or deCONZ firmware

When flashing the firmware on ConBee, it is necessary to have ConBee first, in the first USB slot, and then Zigbee CC2531 second, only because of ConBee. Otherwise, the firmware flash tool will not detect it.


Moj USB dongle is

ZB-GW04 V1.2 ZigBee 3.0 USB Dangle Model: ZYZBP008 CPU: EFR32MG21A020F768IM32 Zigbee and Thread EFR32MG21 SoCs (Series 2) https://www.silabs.com/wireless/zigbee/efr32mg21-series-2-socs/device.efr32mg21a020f768im32

Ovde piše: ZBDongle-E and ZB-GW04 v1.1 do not support hardware flow control. Yellow, SkyConnect and ZB-GW04 v1.2 are built with hardware flow control. Various baudrates are available as listed at end of filename.

Easyiot ZB-GW04 Revision v1.2 - IMA Hardware flow control

Isto se vidi i ovde: https://github.com/skgsergio/silabs-multiprotocol-firmware-zbgw04-usb da je v1.2 (With Hardware Flow Control) ali u svakom slučaju, Firmware with hardware flow control WON’T work in dongles that doesn’t support it.

Flashing

Flashing from browser:

Silabs Firmware Flasher | Web based flasher will install latest builds from darkxst/silabs-firmware-builder

Flashing from CLI:

NabuCasa/universal-silabs-flasher: Flashes Silicon Labs radios running EmberZNet or CPC multi-pan firmware


on mac:

pip install universal-silabs-flasher
ls /dev/tty.usbserial*
universal-silabs-flasher --device /dev/tty.usbserial-10 flash --allow-cross-flashing --firmware ncp-uart-hw-v7.3.2.0-zb-gw04-1v2-115200.gbl --force

postoji podešavanje u Zigbee2mqtt vezano za baudrate, ali ne filozofiraj i koristi default od 115200 Update-ovao sam na

Zigbee (EZSP) 7.3.2.0 build 212 ZB-GW04 v1.2

Na kraju sam odlučio da podesim pažljivo adapter i pređem na

adapter: ezsp baudrate: 230400 rtscts: true

kad tako radiš, universal-silabs-flasher ima još parametara da bi prepoznao

Firmware-ove možeš naći na:

Set the baudrate parameter to the baudrate of the current firmware in the USB Dongle, from factory it comes with a 115200 baudrate firmware and here I build firmwares with 115200 or 230400, it is specified in the firmware file name.

If the wrong baudrate is used the flasher will fail with the message: Error: Failed to probe running application type.


easyiot EFR32MG21 Zigbee 3.0 USB Dongle ZB-GW04 Zigbee compatibility

How to interpret RSSI and LQI values


universal-silabs-flasher –device /dev/tty.usbserial-10 –ezsp-baudrate 230400 –probe-method ezsp probe


Ovako sam skinuo na:

universal-silabs-flasher –bootloader-baudrate 115200 –probe-method ezsp –ezsp-baudrate 230400 –device /dev/tty.usbserial-10 flash –allow-cross-flashing –force –firmware ncp-uart-hw-v7.3.2.0-zb-gw04-1v2-115200.gbl

universal-silabs-flasher –device /dev/tty.usbserial-10 probe

mi daje: Version ‘7.3.2.0 build 212’ (7.3.2.0.212) at 115200 baudrate (bootloader baudrate None)

date 19. Oct 2018 | modified 16. Dec 2024
filename: Hass.io » Tips & Tricks