====== Home automation ======
* [[https://www.technicallywizardry.com/100-home-automation-ideas-tutorials/|100+ Home Automation Ideas with Tutorials: from Simple to Amazing]]
* [[https://geektimes.ru/post/257630/|Умный дом на базе Z-Wave]]
* [[https://sprut.ai/client/article/236|Умный Дом. С чего начать? Куда податься?]]
* [[https://sprut.ai/client/article/294|Как построить умный дом. Основные принципы.]]
* [[youtube>n0dfuj60aaI|Ranking All My Smart Home Products and Projects. Smart home tour.]]
* [[habrahabr>233723|Первый шаг к умному дому или удалённое управление домашней техникой]]
* [[habrahabr>237589|Сверхбыстрое распознавание речи без серверов]] для управления "умным" домом
* [[http://apptractor.ru/info/articles/api-ai-uproshhaet-golosovoe-upravlenie-dlya-prilozheniy.html|Api.ai упрощает голосовое управление для приложений]]
* [[youtube>RVQfJQ5fIC8|Control Your Home with NFC Tags + HomeKit in iOS 13]] and [[hass>hass-nfc-control-home-assistant-with-nfc-tags/54227|Hass NFC]] -- Android app to control Home Assistant.
* [[https://sprut.ai/client/article/1546|Open Source - бесплатный умный дом]] -- обзор [[hassweb>|Home Assistant]], [[https://homebridge.io/|Homebridge]], [[https://majordomohome.com/d|MajorDoMo]], [[https://www.iobroker.net/|ioBroker]], [[https://www.domoticz.com/|Domoticz]], [[https://www.openhab.org/|OpenHab]].
* [[habrahabr>232969|open Home Automation Bus — стань программистом собственного жилища]]
* [[https://sprut.ai/client/news/1489|Рейтинг голосовых ассистентов и систем управления умным домом]]
* [[youtube>PK_NYA-XbsA|5 things to know about wall mounted home automation tablets]]
* [[youtube>f5jNJDaztqk|What's On My Home Server? Storage, OS, Media, Provisioning, Automation]]
* [[youtube>8ufP6hs9uwg|Собрал щит умного дома с AliExpress и системой ectoControl]]
* [[youtube>RfrqHxXq4Ao|Умный дом. О чём подумать заранее!? (Или провода в Умном доме)]]
* [[youtube>GeZYX_0uUSE|Проводка – что заложить пока есть возможность?]]
* [[youtube>ATxPxESvpkI|Электромонтаж. Самый сложный проект 2019]]
Node-RED:
* [[youtube>SuoSXVqjyfc|Node-RED + Home Assistant How-To]]
* [[https://sprut.ai/client/guide/?tag=Node+RED|Статьи с меткой NodeRED]]
MQTT:
* [[https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/|ESP32 MQTT – Publish and Subscribe with Arduino IDE]]
* [[youtube>NjKK5ab0-Kk|Understanding MQTT]]
* [[habrahabr>255404|Как подружить OpenHAB и Arduino через MQTT]] (смотри также ссылки в разделе //Похожие публикации//)
Zigbee vs Z-wave vs WiFi:
{{ https://wattle.com/ea/wp-content/uploads/2020/02/channel_interference_dark.png?1000|WiFi vs Zigbee channels}}
* [[youtube>pUk96iOBAzg&t=34|Smart Lighting Buyers Guide 2019]]
* [[youtube>v8-VNIQQiQE|Z-Wave vs. Zigbee vs. Wi-Fi! Smart Home Basics: How To Pick The Right Protocol]]
* [[https://smart-life.online/smart-home/lifehack/zigbee-vs-wi-fi/|ZIGBEE vs. WI-FI или как настроить зигби сеть в условиях многоквартирного дома]]
* [[habrahabr>535658|Zigbee 101: руководство для начинающих]]
Domoticz:
* [[https://www.domoticz.com/|Domoticz]]
* [[https://www.domoticz.com/wiki/Linux|Installation on Linux]]
* [[https://www.domoticz.com/wiki/Hardware#Zigbee|Supported hardware]]
===== [[wp>Zigbee]] =====
* [[youtube>m-Y8p5-otlw|Сети Zigbee для начинающих]] -- выступление Егора Литвинова (@Xarlan) на RuCTF 2019
* [[https://xakep.ru/2019/09/30/zigbee-exploits/|Полёт пчелы. Как работают сети Zigbee и как искать уязвимости в них]] (@Xarlan) -- рассказывает о структуре и безопасности сети, ключах и софте для работы, а также примеры оборудования ([[https://yadi.sk/i/fXlf7Ezc-EhT_A|slides]] / {{zigbee_security.pdf|local copy}})
* [[https://docplayer.ru/68169695-Besprovodnye-sistemy-pd-lekciya-05-protokol-zigbee.html|Беспроводные системы ПД. Протокол Zigbee (Данила Астахов)]] ({{wireless_networks_lection_05_zigbee.pdf|local copy}})
* [[youtube>GVIwb02X--U|Пример умного дома Xiaomi]]
* [[https://www.reddit.com/r/homeassistant/comments/eym1h8/comment/fgisfu3|Problems with ZigBee network and their solutions]]
* [[https://community.hubitat.com/t/xiaomi-aqara-devices-pairing-keeping-them-connected/623|Xiaomi & Aqara devices - pairing & incompatibility with most Zigbee repeaters]]
==== Hubs ====
[[https://sprut.ai/client/projects/105|Проект SprutHub]]
* [[youtube>Dd5ffPW6XwM|Xiaomi, Aqara, Philips hue, IKEA Trådfri, MegaFon lifecontrol - Apple HomeKit Siri умный дом Zigbee]]
* [[youtube>Jzr9QW48-lg|Умный дом 2018 для Apple HomeKit, Google Home, Amazon Alexa]]
* [[https://elelabs.com/products/elelabs-usb-adapter.html|Elelabs Zigbee USB Adapter]] -- based on EFR32MG13P732 chip from SiliconLabs that supports EZSP (EmberZNet Serial Protocol) and is directly supported by [[https://www.home-assistant.io/integrations/zha/|HomeAssistant]].
----
[[github>nfarina/homebridge|Homebridge]] emulates the [[https://developer.apple.com/homekit/|iOS HomeKit API]] to expose e.g. [[github>itsmepetrov/homebridge-zigbee|Zigbee devices]] to [[https://www.apple.com/lae/ios/home/|HomeKit]].
----
[[aliexpress>32860088703|{{https://geardo.com.au/image/cache/catalog/wysiwyg/Xiaomi%20Mijia%20Multi%20functional%20Gateway/Xiaomi-Mijia-Multifunctional-Gateway-1-700x700.jpg?200|Xiaomi Mijia gateway – $26.33 (€23.30)}}]]
----
[[aliexpress>32911694012|{{https://cdn.shopify.com/s/files/1/2654/9742/products/Xiaomi-Aqara-Gateway_640x.jpg?v=1544413176?200|Xiaomi Aqara Hub – $37.44 (€32.60)}}]]
:YES:
* Integrates with Apple HomeKit
----
* [[https://koenkk.github.io/zigbee2mqtt/|Zigbee to MQTT bridge project page]], [[github>Koenkk/Z-Stack-firmware/tree/master/coordinator|firmware]]
* [[https://gadget-freakz.com/diy-zigbee-gateway/|DoItYourself Zigbee Gateway with zigbee2mqtt]]
Coordinator sticks:
[[aliexpress>32948935250|{{https://www.element14.com/community/dtss-images/uploads/devtool/diagram/large/CC2531+USB+Evaluation+Module+Kit+5511ec179dc41.png?300|CC2531 USB sniffer – $8.25 (€7.25)}}]]
[[https://modkam.ru/?p=1017|{{https://i1.wp.com/modkam.ru/wp-content/uploads/2019/04/photo_2019-04-16_15-23-25.jpg?300|Zigbee V2 (СС2530 + CH340G)}}]]
[[https://modkam.ru/?p=1112|{{https://i1.wp.com/modkam.ru/wp-content/uploads/2019/08/%D0%A0%D0%B0%D0%B1%D0%BE%D1%87%D0%B8%D0%B9-%D1%81%D1%82%D0%BE%D0%BB-2019-08-07-14.29.48.jpg?300|Zigbee V3 (CC2538 + CC2592)}}]]
[[aliexpress>32880588264|{{https://ae01.alicdn.com/kf/HTB1mJW2myOYBuNjSsD4q6zSkFXaW/CC2538-CC2592-PA-Zigbee.jpg_640x640q70.jpg?300|CC2538+CC2592 Zigbee module – $9 (€8.25)}}]]
[[aliexpress>32737589263|{{https://ae01.alicdn.com/kf/HTB1VbCJNpXXXXawaXXXq6xXFXXXR/CC2538Dongle-CC2538SF53-USB-Zigbee.jpg?300|CC2538 Dongle, CC2538SF53, USB – $33.99 (€31.38)}}]]
[[aliexpress>4001273243772|{{https://ae01.alicdn.com/kf/H5860b2b29f624ffabbcd09c96a6542caV/ZigBee-Dongle-CC2538USB-Dongel.jpg?300|ZigBee Dongle CC2538 – $39.60 (€33.83)}}]]
[[github>uzsito/zigbeebox|{{https://github.com/uzsito/zigbeebox/raw/master/graphics/render2.jpg?300|CC2538+CC2592 zigbeebox}}]]
[[aliexpress>32836343416|{{https://ae01.alicdn.com/kf/HTB1a2Itf2NZWeJjSZFpq6xjBFXaT/CC2538-CC2592-Contiki-6LOWPAN-learning.jpg?300|CC2538+CC2592 development board – $39.99 (€36.92)}}]]
[[github>egony/MODKAM-STICK-V3/wiki#%D0%9C%D0%BE%D0%B4%D0%B8%D1%84%D0%B8%D0%BA%D0%B0%D1%86%D0%B8%D1%8F-%D1%81%D1%82%D0%B8%D0%BA%D0%B0-%D1%81%D0%BE-%D0%B2%D1%81%D1%82%D1%80%D0%BE%D0%B5%D0%BD%D0%BD%D1%8B%D0%BC-usb-uart|{{https://raw.githubusercontent.com/egony/MODKAM-STICK-V3/master/images/v3_universal.jpg?300|CC2538+CC2592 Egony mod with USB-UART adapter}}]]
[[github>egony/cc2652p_E72-2G4M20S1E/wiki|{{https://raw.githubusercontent.com/egony/cc2652p_E72-2G4M20S1E/master/images/cc2652p_E72-2G4M20S1E_rev.1.5.jpg?300|CC2652P / Ebyte E72-2G4M20S1E Stick}}]]
[[https://electrolama.com/projects/zig-a-zig-ah/|{{https://cdn.tindiemedia.com/images/resize/FKQjXC6g0OvXok5M80cDLBlsK_g=/p/full-fit-in/1200x800/i/365381/products/2020-05-05T13%3A47%3A27.727Z-01-pcba.jpg?300|CC2652R Stick – €25.30 + €13.49}}]]
[[https://zig-star.com/projects/zigbee-gw-lan/|{{https://zig-star.com/images/zigbee-gw-lan/Default.png?300|ZigStar LAN Gateway (Zigbee LAN Coordinator based on CC2652P) – €30 (only shield) / €42 (shield + case)}}]]
:YES:
* A lot of [[https://koenkk.github.io/zigbee2mqtt/information/supported_devices.html|supported devices]] (including IKEA Trådfri)
* Opensource firmware
* [[github>Koenkk/zigbee2mqtt/issues/52|Extend range of zigbee network using CC2531/CC2530 routers]] e.g. [[github>Koenkk/zigbee2mqtt/blob/dev/docs/how_tos/how_to_create_a_cc2530_router.md|how to create a CC2530 router]]
(check also [[https://myzigbee.ru/books/%D1%88%D0%BB%D1%8E%D0%B7%D1%8B-%D0%B8-%D0%BA%D0%BE%D0%BE%D1%80%D0%B4%D0%B8%D0%BD%D0%B0%D1%82%D0%BE%D1%80%D1%8B/page/%D1%83%D1%81%D1%82%D1%80%D0%BE%D0%B9%D1%81%D1%82%D0%B2%D0%B0-%D0%BD%D0%B0-%D1%87%D0%B8%D0%BF%D0%B0%D1%85-ti-cc253x|Устройства на чипах TI CC253x]])
:NO:
* CC2531 supports only 20 direct sibling devices ([[github>Koenkk/zigbee2mqtt/issues/26|48 with alternative firmware]]). \\
:WARN: No limitation when [[hass>zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/327|some devices are working as routers]] or there are additional routers in the network, see [[github>Koenkk/zigbee2mqtt/issues/481|share life experience with 15++ devices]].
* CC2531 has limited coverage (no external antenna). External antenna modifications:
* [[hass>buy-a-ready2use-zigbee2mqtt-stick-flashed-antenna-mod-and-printed-case/111743|Ready2use antenna mod stick in printed case]]
* [[hass>zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/968|SMA socket is manually mounted]]
* [[https://hackaday.io/project/163505-cc2531-usb-adapter-antenna-mod|CC2531 USB Adapter Antenna mod]]
[[https://www.reddit.com/r/homeassistant/comments/8qq4h4/hassio_addon_zigbee2mqtt_hassio/e0m5mxb/|Advantages / disadvantages of CC2531-based solutions]]:
* Requires flashing of custom firmware on the stick (extra cables and debugger)
* [[https://myzigbee.ru/books/%D0%BF%D1%80%D0%BE%D1%88%D0%B8%D0%B2%D0%BA%D0%B8/page/vlk-diy-multi-flasher|СС2530/СС2531 flasher for ATmega328 / ESP32]] -- позволяет прошить Zigbee модули с чипом СС2530/СС2531, а так же BLE CC2540/CC2541 с помощью Arduino
* Requires running MQTT broker which is an extra component (however could be used by other IoT devices)
{{ https://raw.githubusercontent.com/antst/CC2538-ZNP-Coordinator-firmware/master/60423818-46deb400-9bef-11e9-8f71-8024a5a03d4e.png|J-Link to CC2538 connection scheme}}
Installation:
* Use [[github>Koenkk/Z-Stack-firmware/tree/master/coordinator|firmware]] [[github>Koenkk/Z-Stack-firmware/blob/master/coordinator/Z-Stack_3.0.x/bin/CC2531_20190425.zip|Z-Stack_3.0.x]].
* Run
# apt-get install nodejs npm
$ mkdir zigbee2mqtt
$ git clone https://github.com/Koenkk/zigbee2mqtt.git zigbee2mqtt/
$ cd zigbee2mqtt/
$ npm install
# cat <<'EOF' > /etc/systemd/system/zigbee2mqtt.service
[Unit]
Description=zigbee2mqtt
After=network.target
[Service]
User=homeassistant
UMask=0027
ExecStart=/usr/bin/npm start
WorkingDirectory=/var/lib/homeassistant/zigbee2mqtt
# Don't log output to syslog:
StandardOutput=null
# Below will restart the service StartLimitBurst times. For that set StartLimitInterval=RestartSec*StartLimitBurst+small_delta
Restart=always
RestartSec=30
StartLimitInterval=320
StartLimitBurst=10
[Install]
WantedBy=multi-user.target
EOF
# systemctl daemon-reload
# systemctl enable zigbee2mqtt
Other:
* [[youtube>bLlLU9YaCKk|Координатор Zigbee V3. Собираем, пробуем]]
* [[youtube>KvI-IyWw4so|Home Assistant. Урок 5, часть 2 Стик CC2538, замена на лету стика CC2531, аддон Zigbee2MqttAssistant]]
* [[youtube>9InA6kc6r9s|Home Assistant. Урок 5 Zigbee, USB стик CC2531, Zigbee2mqtt, Aqara decoupled mode]]
* [[https://t.me/zigbeer/86927|Gerber CC2538+2592 v4.zip]]
* [[github>Koenkk/Z-Stack-firmware/tree/master/coordinator/Z-Stack_3.0.x/bin|CC2538 February firmware from 2020-02]]
* [[github>reverieline/CC2538-CC2592-ZNP|CC2538 latest firmware]]
* [[github>antst/CC2538-ZNP-Coordinator-firmware|CC2538 alternative firmware from 2019-09]]
* [[github>jethome-ru/zigbee-firmware/tree/master/ti/coordinator/cc2538_cc2592|Firmware for TI CC2538 based devices]]
У многих возникали вопросы про построение mesh-сети и почему устройство упорно не цепляются к устройствам-роутерам? До недавнего времени возможность подключения устройства к роутеру определялась положением звёзд, скоростью ветра и порядком выпадения карт... В прошивке 20201010 поправлен основной момент, разрешающий подключение устройств через роутеры.* [[github>zigpy/open-coordinator-backup|Open ZigBee Coordinator Backup Format]] -- standardizing this format will allowing users to backup, restore, and migrate their networks between coordinator hardware. * [[youtube>ql58ZfXso1M&t=236s|Backup and Migrate Your Home Assistant Zigbee Network]] * [[https://www.segger.com/products/debug-probes/j-link/models/other-j-links/st-link-on-board/|Converting ST-LINK board into a J-Link]] Flashing via UART: * [[https://mysku.ru/blog/aliexpress/79984.html|Как сохранить режим Serial Bootloader (SBL)]] * [[https://modkam.ru/?p=1112#comment-2999|Как прошивать CC2538 с помощью USB-UART конвертера]] * [[github>jethome-ru/zigbee-firmware/tree/master/ti/coordinator/cc2538_cc2592#flashing-with-uart-sbl|Software to flash with UART (SBL)]] * [[github>egony/MODKAM-STICK-V3/blob/master/files/readme_cc2538-2652-1353_flash_windows.txt|Flash README]] ---- {{https://mjdm.ru/forum/download/file.php?id=15379?.jpg?200}} * [[https://mjdm.ru/forum/viewtopic.php?f=22&t=6700|ESP32 + CC2530 to MQTT bridge (Smart Logic System / SLSYS)]] Similar projects are: * [[github>arendst/Tasmota/wiki/Zigbee|Zigbee to Tasmota (Z2T)]] -- a lightweight Zigbee to MQTT solution running on an ESP82xx WiFi chip. * [[https://myzigbee.ru/books/%D1%88%D0%BB%D1%8E%D0%B7%D1%8B-%D0%B8-%D0%BA%D0%BE%D0%BE%D1%80%D0%B4%D0%B8%D0%BD%D0%B0%D1%82%D0%BE%D1%80%D1%8B/page/zesp|ZESP]] * [[github>hwhw/zigbee-lua/|Zigbee-Lua]] -- Zigbee control framework written in Lua which supports ZCL/ZLL protocol extensions and has build-in HTTP server and MQTT client. * [[https://sprut.ai/client/article/1881|Дайджест по CC2538, nRF52x, ZESP32, SLS Zigbee Gateway и новым Zigbee DIY устройствам]] ---- [[https://www.dresden-elektronik.de/funktechnik/solutions/wireless-light-control/conbee/?L=1|{{https://images-na.ssl-images-amazon.com/images/I/41pHSh3soLL._SY400_.jpg?300|Conbee – €39.95}}]] * The onboard placed [[https://fccid.io/png.php?id=3049926&page=6|radio module deRFmega256-23M12]] contains an 8-bit AVR microcontroller with an integrated low-power 2.4 GHz transceiver for Zigbee / IEEE 802.15.4 applications. :YES: * [[https://www.dresden-elektronik.de/funktechnik/solutions/wireless-light-control/compatibility/?L=1|Supported devices (compatible with IKEA Trådfri)]] * [[https://www.dresden-elektronik.de/funktechnik/products/software/zshark/?L=1|ZSHARK for Wireshark]] can be used to sniff Zigbee network :NO: * [[github>Koenkk/zigbee2mqtt/issues/481#issuecomment-430889639|From here]]: One needs to have [[https://www.dresden-elektronik.de/funktechnik/products/software/pc-software/deconz/?L=1|deConz]] running which is a full blown GUI application. There is a beta version out there which can be run headless but you still need the X.org libs though. * not opensource ---- [[https://zigate.fr/boutique/|{{https://i1.wp.com/zigate.fr/wp-content/uploads/2017/10/IMG_20171014_103802.jpg?200|ZiGate – €49}}]] * Is based on [[http://www.nxp.com/docs/en/data-sheet/JN5168-001-MXX.pdf|JN5168-001 single chip wireless microcontroller]]. * [[https://faire-ca-soi-meme.fr/news/2017/07/28/edito-n2-avancement-de-passerelle-zigate/|Edito n°2 – Avancement de la passerelle ZiGate]] * [[https://faire-ca-soi-meme.fr/news/2017/09/20/edito-n4-zigate-ca-avance/|Edito n°4 – ZiGate ça avance !]] :YES: * [[https://zigate.fr/produits-ikea-tradfri-compatibles-zigate/|Supported devices (compatible with IKEA Trådfri)]] * firmware/SDK is opensource :?: ([[hass>zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/350|zigate firmware is supposed to be opensourced, but it’s dead at the moment]]) :NO: * [[hass>zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/334|both zigate & zigate_homeassistant are dead at the moment, no proper updates]] * website/documentation is in French ---- [[hornbach>6046444|{{https://www.studiopieters.nl/wp-content/uploads/2018/06/3-1-1024x618.png?300|Philips Hue Bridge 2.0 – €49.95}}]] :YES: * [[https://www.ikea.com/gb/en/customer-service/smart-lighting-support/faq-smart-lighting/compatibility-protocols/#1364400184185|Supported devices (compatible with IKEA Trådfri)]] * [[https://www.meethue.com/en-us/p/hue-bridge/046677458478|Integrates with Alexa, Apple HomeKit, and Google Assistant]] ---- [[https://www.amazon.de/Samsung-SmartThings-Hub-Bundle-GP-U999SJVLGEA/dp/B07H9G68DW/|{{https://support.smartthings.com/hc/article_attachments/360002610603/im6001v3.png?500|Samsung SmartThings Hub – €95.43}}]] :YES: * [[https://support.smartthings.com/hc/en-us/articles/115005937923-How-to-connect-IKEA-bulbs|Supported devices (compatible with IKEA Trådfri)]] * [[github>stjohnjohnson/smartthings-mqtt-bridge/|Share and control SmartThings device states via MQTT]] ---- [[tweakers>430548/zipato-zipabox-smart-home-controller|{{https://cdn.shopify.com/s/files/1/0218/7704/products/Zipabox-top.jpg?300|Zipabox – €184.95 }}]] [[https://www.zipato.com/product/zipabox|{{https://community.zipato.com/public/attachments/480cba03e26439b7caa3639a354ac915.jpg?400}}]] * ARM9 208MHz CPU, 64MB RAM, 128MB Flash, Linux 2.6 * Z-Wave, Zigbee (ext module), ONVIF / IPcam, SMS (ext. module) ---- [[https://www.athom.com/en/store/product/homey/|{{https://images.m.nu/data/product/raw/athom_homey.jpg?300|Homey – €299}}]] * Wi-Fi 802.11b/g/n 2.4GHz, Bluetooth 4.0 Low Energy, Zigbee 2.4GHz, Z-Wave Plus (433MHz, 868MHz), IR receiver/transmitter, NFC * [[https://www.mediamarkt.nl/nl/product/_athom-homey-1427926.html|Buy at MediaMarkt]] or [[https://www.coolblue.nl/product/792927/athom-homey.html|Coolblue]]. * [[youtube>x7-UOEYq-lU|Распакуем и поговорим о чудо колобке Athom Homey]] :YES: * [[https://www.athom.com/en/talks-with-homey/|Supported devices (compatible with IKEA Trådfri)]] ==== Devices ==== [[https://bilisty.en.alibaba.com/productgrouplist-812619056/Zigbee_Smart_Devices.html|{{ https://sc02.alicdn.com/kf/HTB1bl0HeBGw3KVjSZFDq6xWEpXad/220489354/HTB1bl0HeBGw3KVjSZFDq6xWEpXad.jpg?700|Bilisty Zigbee smart devices}}]] {{https://i0.wp.com/www.marketcom.eu/sonoff-smartwise-shelly-EU-wholesale-distribution/wp-content/uploads/2019/09/shelly_dimmer_wiring.png?800|Single, double, momentary and 3-way switch for Shelly dimmer with and without neutral wire}} [[aliexpress>1005001688505175|{{https://ae01.alicdn.com/kf/H418e93e08fb4410483808a9fecdeecdaZ.jpg?700|SONOFF ZBMINI Zigbee 3.0 – €8.58 ($9.90)}}]] * [[https://zigbee.blakadder.com/zigbee2mqtt.html|Devices supported by Zigbee2mqtt gateway]] * [[https://www.aliexpress.com/af/xiaomi-zigbee.html|Search for Xiaomi Zigbee]] items * [[aliexpress>32827930218|Original Xiaomi Smart Home Kits (gateway, door window sensor, human body sensor, switch, temperature and humidity sensor]] * [[https://docs.google.com/spreadsheets/u/0/d/1quCLYmbA2dku2-M-SNfLEMv8xsgZsSZeGy2zWAEWVVM/htmlview|Продукция экосистемы Xiaomi Mi]] * [[https://www.igeekphone.com/xiaomi-aqara-launches-10-new-zigbee-3-0-smart-home-products/|Xiaomi Aqara launches 10 new Zigbee 3.0 smart home products]] * [[https://www.ikea.com/nl/nl/catalog/categories/departments/lighting/36812/|IKEA Trådfri]] * [[hassweb>blog/2017/04/17/ikea-tradfri-internet-of-things-done-right/|IKEA Trådfri: Internet of Things done right]] * [[hass>ikea-smart-lighting-zigbee/4871/161|IKEA Smart Lighting (Zigbee)]] * [[https://www.youtube.com/channel/UCLecVrux63S6aYiErxdiy4w/videos|BRUH Automation]] * [[youtube>ifR5nNNISmc|ZigBee-девайсы IKEA Trådfri]] * [[https://tradfri.blogspot.com/|Teardown of LED lamps]] * [[github>basilfx/TRADFRI-Hacking|Hacking IKEA Zigbee module]] * [[https://trmm.net/Ikea|Ikea Tradfri firmware hacking]] * [[http://www.sensorsiot.org/145-ikea-tradfri-hack-with-gateway/|IKEA Trådfri Hack]] * [[https://learn.pimoroni.com/tutorial/sandyj/controlling-ikea-tradfri-lights-from-your-pi|Controlling IKEA Trådfri Lights from your Pi using libcoap]] * [[https://trust.com/nl/zigbee|Trust Zigbee producten]] * [[https://bilisty.en.alibaba.com/productgrouplist-812619056/Zigbee_Smart_Devices.html|Bilisty Zigbee smart devices]] * [[https://sunricher.en.alibaba.com/productgrouplist-811954196/Zigbee_LED_Controller.html|Sunricher Zigbee Smart Devices]] * [[https://sprut.ai/client/blog/2308|Подборка статей @AlexxIT]]: "Как подключить непрошитый Sonoff к Home Assistant и не зависить от китайских серверов", "Где купить выключатель без нуля в круглый подрозетник", "Что почитать про организацию управления светом в умном доме"... * [[youtube>LQNkeEnAfNs|E-paper 2.13 nRF52840 BME280 Mysensors]] * [[https://sprut.ai/client/article/2138|Aqara cube + deCONZ. А что же он реально может?]] * [[https://sprut.ai/client/article/2365|Home-Assistant + Deconz и Xiaomi Magic Cube: "нативное" использование]] === Switches === * [[https://sprut.ai/client/blog/1999|Wi-Fi выключатели без нуля в круглый подрозетник]] {{ https://livolotouch.ru/image/catalog/stati/wiring-diagram/wiring-diagram-3-701S.jpg?400|Схема подключения}} [[https://livolo.aliexpress.com/store/group/New-Arrivals/500715_516365659.html|Livolo switches]]: :WARN: Zigbee switches cannot work in 2-way mode with non-Zigbee (RF or WiFi) switches, see [[https://www.livoloeurope.eu/frequently-asked-questions|10. Can I synchronize a 2 ways Zigbee switch and a none Zigbee 2 ways switch?]]. Это положение не подтверждается: функциональность Livolo 2-way никак не связана со способами удалённого управления: Zigbee 1-gang 2-way выключатель VL-C701SZ работает отлично в связке с обычным 1-gang 2-way выключатель VL-C701S. :WARN: Zigbee version works on 26 channel and with specific manufacture-locked extended pan ID, see [[https://zigbee.blakadder.com/Livolo_TI0001.html|Switch 1 or 2 Gang by Livolo]]. :WARN: Livolo switches without group wire do not act as Zigbee routers (amperage is not enough to support that feature). :WARN: After power is back (after power shut down or changing the lamp/load), the coordinator should be in "permit join" mode because Livolo devices re-announce themselves (and get a new short network address). Otherwise they don't return back to network. :WARN: Livolo devices are flooding the network with requests ([[github>Koenkk/zigbee2mqtt/issues/592#issuecomment-752814633|see this comment]]) which probably only Livolo switches may answer. :INFO: RF switches use 433.92MHz frequency which allows it to be controlled using Arduino, see [[https://www.instructables.com/id/Controlling-a-Livolo-RF-Light-Switch-Using-a-Raspb/|Controlling a Livolo RF Light Switch Using a Raspberry Pi 3 B in Python]] and [[https://forum.arduino.cc/index.php?topic=153525.0|ontrol Livolo switches / Livolo switch library]]. There is now way to update/get the current status, so communication is one-way. :INFO: [[https://mysku.ru/blog/aliexpress/30435.html|Еще раз про Livolo + схема + ремонт + допилинг]] -- решение проблемы, когда выключатель реагирует на касания переключением светодиода, но реле не щёлкает :INFO: [[github>Koenkk/zigbee2mqtt/issues/592#issuecomment-667074236|Home Assistant configuration to fix Zigbee2mqtt issue with Livolo switch]] Price comparison for 1 gang 2 way switch: ^ Site ^ Product ^ Price ^ | [[https://www.livoloeurope.eu/livolo-full-product-catalogue/livolo-zigbee-touch-light-switches/livolo-zigbee-touch-light-1-way-switches|Livolo EU – Zigbee Schakelaars]] | [[https://www.livoloeurope.eu/index.php?route=product/product&product_id=210|VL-C701SZ]] | €44.95 | | [[https://www.livolo.nl/c-5023588/smart-home-schakelaars/|Livolo NL]] | [[https://www.livolo.nl/a-54143126/smart-home-schakelaars/livolo-zwart-enkelpolig-wisselschakelaar-zigbee-wifi-app/#description|VL-C701SZ + VL-C7-C1-12]] | €49.95 | | [[https://livolo01.en.alibaba.com/productgrouplist-813739937/White.html|Alibaba]] | [[https://www.alibaba.com/product-detail/LIVOLO-VL-C701SZ-11-EU-Standard_62024359844.html|VL-C701SZ-11]] | $35.97 (3-9 pcs) | | Aliexpress | [[aliexpress>32919290067|C701Z-C1EUZ-11]] | €28.23 ($30.89) | ESP32 based: * [[https://sprut.ai/client/article/1751|Выбор реле в подрозетник (Sonoff, Aqara Wireless Relay)]] * [[youtube>zFIPrJybt94|Sonoff Mini vs Shelly One comparison]], [[youtube>PtFNUkDJTnE|More Sonoff Mini vs. Shelly One comparisons]], [[youtube>J20hxfUTP9I|Is the Shelly 1 better than the Sonoff Basic?]], [[youtube>nrSbZFNSbXI&t=411|Shelly native MQTT support, Tasmota on the Shelly2, & Setting Up a 3-Way switch]] * [[youtube>DsTqOlrQQ1k|Sonoffs can work with Home Assistant with original firmware]] DIY: * [[https://modkam.ru/?p=1309|Реле Zigbee в «подрозетник»]], [[https://modkam.ru/?p=1054|Zigbee реле. Версия №2]] === Power sockets === * [[https://www.livolo.nl/c-2722805/wandcontactdozen/|Livolo NL – Wandcontactdozen]] ==== FAQ ==== === Control devices (switches) and bulb status update ===
advanced:
report: true
Other issue reports:
* [[hass>zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/1329|... the status we did not change in the HA]]
* [[hass>zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/1300|If I switch on the bulb, HA won't notice it]]
* [[hass>zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/1448|Zigbee xiaomi sockets do not automatically switch on after power is restored]]
* [[github>Koenkk/zigbee2mqtt/issues/1064|zigbee2mqtt issue#1064]]
* [[github>Koenkk/zigbee2mqtt/issues/966#issuecomment-463375297|zigbee2mqtt issue#966]]
* [[github>Koenkk/zigbee2mqtt/issues/782#issuecomment-462095606|zigbee2mqtt issue#782]]
* [[github>Koenkk/zigbee2mqtt/issues/534|zigbee2mqtt issue#534]]
{"id":4,"ieeeAddr":"0xccccccfffed5138a","nwkAddr":38336,"epList":[],"endpoints":{},"interviewCompleted":false,"meta":{}}
means that there was a problem when pairing with the device. To cure that do the steps from [[github>Koenkk/zigbee2mqtt/issues/2148#issuecomment-543052077|issue #2148]]:
* ''systemctl stop zigbee2mqtt.service''
* Edit ''data/database.db'' and set ''interviewCompleted: true'' and ''%%meta: {"configured": 0}%%''
* :OPT: Wake up the control device by clicking buttons on it
* ''systemctl start zigbee2mqtt.service''
# apt-get install libstdc++-dev libusb-1.0-0-dev
# wget -nv -O - https://github.com/homewsn/whsniff/archive/v1.3.tar.gz | tar -xz
# cd whsniff-1.3
# make all install
* :OPT: Assign a special group for CC2531 stick device so that it can be read by ''whsniff'':
# cat <<'EOF' > /etc/udev/rules.d/95-CC2531.rules
ACTION=="add", SUBSYSTEMS=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="16ae", MODE="660", GROUP="wireshark"
EOF
# udevadm control --reload
:OPT: Otherwise it should be run by root:
# cat < /etc/sudoers.d/whsniff
$USER ALL = NOPASSWD: /usr/local/bin/whsniff *
EOF
* :OPT: Grant access to USB stick to some user
usermod -a -G wireshark $USER
:OPT: or open a new root session with
su - wireshark
* Run
whsniff -c 11 | wireshark -k -i -
where ''11'' is obligatory parameter that specifies ZigBee channel ID
More info:
* [[https://blog.radiotech.kz/radio/sniffer-zigbee-trafika-v-linux/|Сниффер Zigbee трафика в Linux]]
* [[http://re-engr.ru/zigbee-sniffer/|Zigbee sniffer]]
* [[https://www.linux.org.ru/news/opensource/9924433|Открытый Zigbee сниффер ZBOSS]], [[https://zboss.dsr-wireless.com/projects/zboss/wiki/ZBOSS_Sniffer|ZBOSS Sniffer]]
* [[youtube>4vG4CVNAm_A|Wireshark Decrypt Zigbee Packets]]
apt-get install g++ libpython3.9-dev libudev-dev && pip3 install homeassistant-pyozw==0.1.4 --prefix=~/.homeassistant/deps
Successful HASS log:
INFO (Dummy-3) [openzwave] Driver ready using library Static Controller version Z-Wave 2.78
INFO (Dummy-3) [openzwave] home_id 0x014ce230, controller node id is 1
INFO (MainThread) [homeassistant.components.zwave] Z-Wave node 1 ready after 1 seconds
INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new zwave.zwave entity: zwave.aeon_labs_dsa02203_z_stick_s2
* [[https://www.smarthomebeginner.com/configure-google-assistant-for-home-assistant/|Configure Google Assistant for Home Assistant]].
* [[github>dmitry-k/yandex_smart_home|Yandex Home component for Home Assistant]], [[https://sprut.ai/client/article/1404|Добавляем Home Assistant в Умный Дом Яндекса]], [[https://wiki.yaboard.com/w/%D0%90%D0%BB%D0%B8%D1%81%D0%B0_%D0%B8_Home_Assistant|Алиса и Home Assistant]]
* [[https://www.home-assistant.io/integrations/google_maps/|Google Maps]] to track users' location via unofficial API
* To create cookies file use new private window (otherwise some cookies might get mixed with another account). After login check that necessary persons are displayed on [[https://www.google.com/maps/@/data=!3m1!4b1!4m2!7m1!2e1?authuser=1|Google Maps]] (otherwise re-enable location sharing on their devices).
* [[https://community.home-assistant.io/t/google-maps-location-sharing-new-thread/54555/179|Check the minimal list of cookies to be present]]
* [[hass>my-lovelace-plugins/70726/18|Honored Lovelace plugins]]
* [[github>thomasloven/lovelace-auto-entities|Auto entities]] -- automatically populate lovelace cards with entities matching certain criteria
* [[github>kalkih/mini-media-player|Mini Media Player]]
* [[github>kalkih/mini-graph-card|Mini Graph Card]]
* [[github>rgruebel/ha_zigbee2mqtt_networkmap|Custom Component to show the zigbee2mqtt Networkmap]] or [[github>azuwis/zigbee2mqtt-networkmap/|Custom Card to show Zigbee2mqtt network map]]
* [[github>andrey-git/home-assistant-custom-ui|CustomUI]]
* [[https://community.home-assistant.io/t/how-to-change-icons-colour-of-template-sensor-in-lovelace/107619|How to change icon’s colour of template sensor in Lovelace?]]
* [[https://community.home-assistant.io/t/change-a-sensor-icon-color-very-confused/59111|Change a Sensor Icon color]]
* Changing colors using using ''state-icon'' or ''custom:card-modder'' cards (i.e. without CustomUI):
* [[https://community.home-assistant.io/t/lovelace-with-state-dependant-colors/72587|Lovelace with state-dependant colors]]
* [[https://community.home-assistant.io/t/solved-customize-scene-icon-color-in-picture-glance-card/108335|Customize scene icon color in Picture Glance Card]]
* [[https://www.home-assistant.io/integrations/braviatv|Sony Bravia TV integration]] / [[https://community.home-assistant.io/t/sony-bravia-tv-component-with-pre-shared-key/30698|Sony Bravia TV component with Pre-Shared Key]].
* Working reports:
* [[https://community.home-assistant.io/t/sony-bravia-tv-component-with-pre-shared-key/30698/368|KDL-65W850A]]
* [[https://community.home-assistant.io/t/sony-bravia-kdl-48w650d/18276/2|KDL-46W905]]
* [[https://community.home-assistant.io/t/support-for-bravia-smart-tv-2013/594/46|KDL-32W705B]]
* Failed reports:
* [[https://community.home-assistant.io/t/sony-bravia-kd43xe8077su-configuration/27822|KD43XE8077SU]]
==== Managed installation ====
# apt-get install python3-pip python3-setuptools
# mkdir -m 770 /var/lib/homeassistant
# useradd -d /var/lib/homeassistant -G dialout -r homeassistant
# chown homeassistant.homeassistant /var/lib/homeassistant
# su - homeassistant
$ pip3 install homeassistant --prefix=~/.homeassistant/deps
$ ln -s .homeassistant/deps/bin bin
$ ln -s .homeassistant/deps/lib/python3.7/site-packages packages
# cat <<'EOF' > /etc/systemd/system/homeassistant.service
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
User=homeassistant
UMask=0027
Environment=PYTHONPATH=/var/lib/homeassistant/packages
Environment=TMP=/var/tmp
# [optional] scan network to populate ARP table:
#ExecStartPre=/usr/bin/nmap --open -p 23,80 -oG - 10.0.1.0/24
ExecStart=/var/lib/homeassistant/bin/hass
# Don't log output to syslog:
StandardOutput=null
# Enable if Home Assistant crashes:
# Below will restart the service StartLimitBurst times. For that set StartLimitInterval=RestartSec*StartLimitBurst+small_delta
#Restart=on-failure
#RestartSec=20
#StartLimitInterval=80
#StartLimitBurst=3
[Install]
WantedBy=multi-user.target
EOF
# systemctl daemon-reload
# systemctl enable homeassistant
$ apt-get remove --purge python3-async-timeout python3-bcrypt python3-cryptography python3-jinja2 python3-pycparser
$ apt-get remove --purge python3-aiohttp python3-astral python3-ruamel.yaml python3-slugify python3-voluptuous python3-voluptuous-serialize
# apt-get install -y docker-ce docker-ce-cli docker-compose-plugin containerd.io
# cat <<'EOF' > /var/lib/homeassistant/docker-compose.yaml
version: "3.6" # minimum version level that supports "tmpfs" volume type
services:
homeassistant:
container_name: homeassistant
image: ghcr.io/home-assistant/home-assistant:2023.4.0
restart: unless-stopped
privileged: true
volumes:
- /etc/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
- /run/mysqld:/run/mysqld:ro
network_mode: host
frigate:
container_name: frigate
image: blakeblackshear/frigate:0.12.0-beta2
restart: unless-stopped
privileged: true # this may not be necessary for all setups
# check here for more information about how to calculate this value: https://docs.frigate.video/frigate/installation#calculating-required-shm-size
shm_size: "64mb"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/frigate:/config
- /home/frigate:/media/frigate
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 1000000000
network_mode: host
EOF
# cat <<'EOF' > /etc/systemd/system/homeassistant.service
[Unit]
Description=Home Assistant
After=network-online.target mosquitto.service mariadb.service
[Service]
Type=simple
# Discover the network to learn hostnames of various devices:
ExecStartPre=/usr/bin/nmap --open -p 23,80 -oG - 10.0.1.0/24
# Builds, (re)creates, starts, and attaches to containers. If the process encounters an error, the exit code for this command is 1. If the process is interrupted using SIGINT (ctrl + C) or SIGTERM, the containers are stopped, and the exit code is 0.
ExecStart=docker compose -f /var/lib/homeassistant/docker-compose.yaml up
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target
* :OPT: For hardware acceleration on Intel chipsets:
# apt-get install i965-va-driver
If the following error is displayed:
# ffmpeg -hwaccel vaapi -i test.mp4 -c:v libx264 output.mp4
...
[AVHWDeviceContext @ 0x559f7e1aabc0] libva: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
...
then check that ''vainfo'' (should be installed via ''apt-get install vainfo'') outputs profiles using ''i965_drv_video.so'' driver:
# vainfo
libva info: VA-API version 1.10.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_8
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264MultiviewHigh : VAEntrypointVLD
VAProfileH264MultiviewHigh : VAEntrypointEncSlice
...
and then force ''ffmpeg'' to use that driver:
LIBVA_DRIVER_NAME=i965 ffmpeg -hwaccel vaapi -i test.mp4 -c:v libx264 output.mp4
If OK, then add
ffmpeg:
hwaccel_args: preset-vaapi
to ''/etc/frigate/config.yml''. \\
More info:
* [[https://trac.ffmpeg.org/wiki/Hardware/VAAPI|Intel / i965 platform support]] and [[https://trac.ffmpeg.org/wiki/Hardware/QuickSync#HardwareSupport|Hardware support]]
* [[https://docs.frigate.video/configuration/hardware_acceleration/#intel-based-cpus|Frigate Intel-based CPUs hardware acceleration]]
Additionally install ''intel-gpu-tools'' and monitor the load on GPU:
# apt-get install intel-gpu-tools; intel_gpu_top
intel-gpu-top: Intel Haswell (Gen7) @ /dev/dri/card0 - 238/ 238 MHz; 0% RC6; 0.36/ 8.82 W; 14 irqs/s
IMC reads: 1219 MiB/s
IMC writes: 345 MiB/s
ENGINES BUSY MI_SEMA MI_WAIT
Render/3D 1.50% | | 0% 0%
Blitter 0.00% | | 0% 0%
Video 2.49% |██▍ | 0% 0%
VideoEnhance 0.00% | | 0% 0%
See also:
* [[youtube>43E5bxuaVj4|Frigate NVR in Home Assistant for Automation and Notifications based on Object Detection]]
* [[youtube>pqDCEZSVeRk|Even more free local object detection with Home Assistant - Frigate Install]]
==== FAQ ====
=== Error executing query: (MySQLdb.OperationalError) (1271, "Illegal mix of collations for operation 'UNION'") ===
[homeassistant_db]> select table_name, table_collation from information_schema.tables where table_schema = 'hass_db' and table_collation = 'utf8mb4_general_ci';
+-----------------------+--------------------+
| table_name | table_collation |
+-----------------------+--------------------+
| recorder_runs | utf8mb4_general_ci |
| schema_changes | utf8mb4_general_ci |
| statistics | utf8mb4_general_ci |
| statistics_runs | utf8mb4_general_ci |
| statistics_short_term | utf8mb4_general_ci |
+-----------------------+--------------------+
[homeassistant_db]> alter table recorder_runs convert to character set utf8mb4 collate utf8mb4_unicode_ci, lock=exclusive;
...
The solution is provided in [[github>home-assistant/core/issues/73235#issuecomment-1150471129|issue 73235]] (see also [[github>home-assistant/core/issues/92852|issues 92852]], [[github>home-assistant/core/issues/93410|issue 93410]]).
# cat < /etc/apt/sources.list.d/grafana.list
deb https://packages.grafana.com/oss/deb stable main
EOF
# wget -nv -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
2019-08-10 12:36:19 URL:https://packages.grafana.com/gpg.key [1694/1694] -> "-" [1]
OK
# apt-get update
# apt-get install grafana influxdb influxdb-client mosquitto
* Setup Grafana:
-
# chgrp grafana -R /etc/grafana
# chmod o-rwx -R /etc/grafana
# patch -p0 <<'EOF'
--- /etc/grafana/grafana.ini.orig 2020-02-11 22:13:49.346687600 +0100
+++ /etc/grafana/grafana.ini 2020-02-06 19:05:54.087086389 +0100
@@ -33,6 +33,7 @@
# The ip address to bind to, empty will bind to all interfaces
;http_addr =
+http_addr = 127.0.0.1
# The http port to use
;http_port = 3000
@@ -48,6 +49,7 @@
# If you use reverse proxy and sub path specify full url (with sub path)
# See https://grafana.com/docs/grafana/latest/installation/behind_proxy/
;root_url = http://localhost:3000
+root_url = https://www.host.com/grafana/
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
;serve_from_sub_path = false
@@ -172,12 +174,15 @@
# set to true if you host Grafana behind HTTPS. default is false.
;cookie_secure = false
+cookie_secure = true
# set cookie SameSite attribute. defaults to `lax`. can be set to "lax", "strict" and "none"
;cookie_samesite = lax
# set to true if you want to allow browsers to render Grafana in a ,
- :OPT: Setup datasources
# cat < /etc/grafana/provisioning/datasources/mysql.yaml
apiVersion: 1
deleteDatasources:
- name: MySQL
datasources:
- name: MySQL
type: mysql
editable: false
url: 10.0.0.2:3306
database: source_db
user: grafana
secureJsonData:
password: abc123
- :OPT: Install necessary plugins:
# grafana-cli plugins list-remote
# grafana-cli plugins install pr0ps-trackmap-panel
# grafana-cli --pluginUrl https://github.com/alexandrainst/alexandra-trackmap-panel/archive/refs/heads/master.zip plugins install alexandra-trackmap-panel
* Setup Apache:
# cat <<'EOF' > /etc/apache2/conf-available/grafana.proxy.conf
# Grafana requires a slash at the end of the path, hence implementing proxying using mod_rewrite:
RewriteEngine on
# In this context the path is actually /var/www/grafana, hence don't start regexp with ^
RewriteRule /grafana$ /grafana/ [R,L]
RewriteRule /grafana/(.*)$ http://localhost:3000/$1 [P,L]
SSLRequireSSL
AuthType Basic
AuthName "Grafana"
Require valid-user
# Prevent the client from setting these headers:
RequestHeader unset Authorization
RequestHeader unset X-WEBAUTH-USER
RequestHeader set X-WEBAUTH-USER %{REMOTE_USER}s
ProxyPass ws://localhost:3000/api/live/ws
ProxyPassReverse ws://localhost:3000/api/live/ws
SSLRequireSSL
Require all granted
EOF
# a2enconf grafana.proxy
# systemctl restart apache2.service
* Setup Mosquitto MQTT server((Should be setup in a specific order, see [[stackoverflow>49977385|InfluxDB can create the first user only when auth is turned off]])) (see also [[https://docs.influxdata.com/influxdb/latest/administration/authentication_and_authorization/|Authentication and authorization in InfluxDB]]):
# mosquitto_passwd -c /etc/mosquitto/passwd
Password: ****
Reenter password: ****
# cd /etc/mosquitto
/etc/mosquitto# chgrp mosquitto -R .
/etc/mosquitto# chmod o-rwx -R .
* :OPT: Setup InfluxDB server:
-
# chgrp influxdb -R /etc/influxdb
# chmod o-rwx -R /etc/influxdb
# influx
> CREATE USER admin WITH PASSWORD 'secret1' WITH ALL PRIVILEGES
> CREATE DATABASE hass_db
> USE hass_db
> CREATE USER hass WITH PASSWORD 'secret2'
> GRANT ALL ON hass_db TO hass
> exit
# patch -p0 <<'EOF'
--- /etc/influxdb/influxdb.conf.orig 2018-10-19 06:47:59.000000000 +0200
+++ /etc/influxdb/influxdb.conf 2020-01-27 12:01:56.766787568 +0100
@@ -223,7 +223,7 @@
# bind-address = ":8086"
# Determines whether user authentication is enabled over HTTP/HTTPS.
- # auth-enabled = false
+ auth-enabled = true
# The default realm sent back when issuing a basic auth challenge.
# realm = "InfluxDB"
EOF
# systemctl restart influxd
- Setup Home Assistant to dump the entity states also to InfluxDB:
influxdb:
database: hass_db
username: hass
password: !secret hass_password
default_measurement: state
component_config_glob:
sensor.*humidity:
override_measurement: humidity
sensor.*temperature:
override_measurement: temperature
* :OPT: Setup MySQL backend support to replace [[https://www.home-assistant.io/integrations/recorder/|event state recorder]]
- Run
# apt-get install python3-mysqldb
# mysql -uroot -p <<'EOF'
CREATE DATABASE hass_db;
GRANT SELECT ON hass_db.* TO 'hass'@'localhost' IDENTIFIED BY 'zzz';
GRANT SELECT ON hass_db.* TO 'grafana'@'localhost' IDENTIFIED BY 'xxx';
EOF
- Change ''homeassistant.service'' to read:
[Unit]
After=network-online.target mariadb.service
- Change ''configuration.yaml'' to read:
recorder:
db_url: mysql://hass:zzz@localhost/hass_db?unix_socket=/run/mysqld/mysqld.sock&charset=utf8
=== How to implement datetime filters and grouping for SQL source? ===
...
WHERE $__timeFilter(time_created)
GROUP BY $__timeGroup(time_created, $__interval)
ORDER BY $__timeGroup(time_created, $__interval) ASC
:OPT: Second option would be to introduce a special variable, which will provide more fine-grained control but will require the user to select manually the appropriate scaling where necessary:
* Create ''$interval'' template variable as in [[https://community.grafana.com/t/how-to-add-time-series-queries-with-grafana-and-mysql/3170/2|this post]]:
SELECT 'minute' AS __text, '%Y%m%d%H%i' AS __value
UNION
SELECT 'hour' AS __text, '%Y%m%d%H' AS __value
UNION
SELECT 'day' AS __text, '%Y%m%d' AS __value
UNION
SELECT 'month' AS __text, '%Y%m' AS __value
* Use the following SQL query template (:INFO: ''last_updated'' is indexed):
SELECT
max(unix_timestamp((last_updated))) as time,
max(volume) as value,
'Volume' as metrics
FROM states
WHERE $__timeFilter(last_updated)
AND ...
GROUP BY date_format(last_updated, '$interval')
ORDER BY date_format(last_updated, '$interval') ASC
See also: [[https://www.percona.com/live/e17/sites/default/files/slides/Visualize%20Your%20Data%20With%20Grafana%20-%20FileId%20-%20115450.pdf|Visualize Your Data With Grafana, Percona Live 2017 (Daniel Lee)]]