-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Home Assistant and SSD TBW. #394
Comments
Sorry if the question seems dumb: this only affects the SSD if the BT receiver is connected directly to the machine running HA, am I correct? _Warnings Requires BT adapter with USB2.0 HS. Otherwise, there will be many gaps in the reception. Do not use ESP32xxx - it cannot work with BLE at normal speed and drains the batteries of all BLE devices when connected! ESPHome does not work with Bluetooth 5.0 and misses a lot of advertising packets from BLE devices._ But I see many in the forums using ESPHome to connect (that's my config: an ESPHome mainly dedicated to BT devices (3 of them actually) + BTHome protocolo + Home Assistant). Is this safe or this will drain the BLE battery (still don't understand how since the ESP should be in "passive" mode and only get data when the device sends it out)? |
misses a lot of advertising packets from BLE devices
When using Bluez. This is not the main problem. More than 60 different devices: Start on a new SSD: |
Thanks, so I can just exclude the sensor from the recorder: in config.yaml and I'm going to be fine? |
Then there will be no measurement history. For recording, all unnecessary and uninteresting entities, such as reception levels and others, are disabled. Store depth limitation for one month and data saved at one minute intervals. There is a desire to use the database for 1 year, but in HA this is impossible - it will either work slowly on weak machines, or the size of the database will be TB. And every day the database in TB will be completely rewritten :( The ratio of the desired device memory (RAM) size for normal operation of Home Assistant is approximately 2 GB + database file size. |
Pardon my confusion: is this to say that there is no good way to connect BLE sensors to Home Assistant? Based on what I can see here, using a BT dongle on the HA machine ruins the SSD, and using an ESPHome device in the middle misses advertisements and wastes battery on the sensors. I have ten LYWSD03MMC, is there any solution that truly works? |
If I understood this correctly you can exclude the BLE sensor form recording to the DB, and if you need an history record for any of them create a dummy sensor that updates every once in a while, like when the values changes for more than 0.5 °C, or more than 1% HR. |
This still does not allow Home Assistant to work for a long time on eMMC and especially on SD cards. Only on SSD or HDD. |
That' s a generic HA anyways, not related to BLE devices in particular (I have switched to SSD a long time ago also gaining some speed at boot). My plan is also to have a full HW backup ready to switch in in case of failure (another raspberry, with another SSD); at the cost SSD are now I can consider it like some sort of "consumable", to switch completely every 2/3 years. |
Failure due to loss of markings or programs due to a power failure. Server SSDs have additional capacities and other elements and a program for emergency reset of vital data. This is not the case in household ones. https://www.phoronix.com/news/NVMe-Abrupt-Shutdown-Linux smartctl -a /dev/nvme0
|
Hello, You don't have to worry about that. First, under GNU/Linux, the data is not committed to disk on every write. For example for ext4 it is usually 4 seconds. https://www.kernel.org/doc/Documentation/filesystems/ext4.txt
Secondly, the SSD firmware decides where to write data and data is not always contiguous. The firmware choose to write where ZEROs are written. Thirdly, you can trim your SSD using Linux trim or on file removal, which gives SSD firmware more space to choose. You may use the discard option to automatically trim your partitions. This is an example in /etc/fstab
Last if you are really worried you may use a RAM disc for a folder or some files. Again, just don't worry about that!!! |
@ffries eMMC (system) and NVMe (Home Assistant), All logs are written to RAMdisk
https://stackoverflow.com/questions/65957677/bluez-change-local-storage-directory
Nobody cares - it's just fun. PS: SSD is a consumable item. Change every 2 years. Single board computer with eMMC - also replace every 2 years. |
With Raspberry Pi, enabling the Overlay Filesystem (which uses the RAM to store changes) allows setting the SD card in read-only mode (or defining an overlayed read-only partition for the root filesystem and a non-overlayed RW partition for the data). It can be configured via raspi-config. With the Overlay Filesystem, the system can be turned off without shutdown (but if a RW data partition is defined, it will not be protected). |
Home Assistant is very slow on an SD card. It's the same on an SSD drive via ATA.
If the card is recording enabled, any power cycle may cause the entire card to fail. |
@pvvx I am running HA on an Nvme and SSD on different systems without any issue and I have around 100 objects. I have been a GNU/Linux user for more that 20 years. Please don't mess-up an NVMe/SSD with an SD card. The NVMe/SSD has an internal controller that prevents wearing, moving data at different places. This is done in hardware without user intervention. On the converse, data on an SD card does not have an internal controller. An SD card can indeed wear very quickly when data is constantly written at the same place (for example logs). The graphs shown are not real disk access but only disk commits. Data is not written instantly but only after a few seconds. Therefore an NVMe/SSD will not wear even when written 100 times a second. Under GNU/Linux, data is written to RAM and then committed to disk. This is done without intervention. i.e. your graphs show commits to RAM and every 5 seconds or so, data is written to disk. Only the OS will decide when to write to disk. To my knowledge this is not possible to access the real statistics of disk writing as this is done transparently in the OS and this is kind of a "black-box". All this discussion is pointless and you should close this issue. User without GNU/Linux knowledge might become confused if they don't know the difference between CF and NVMe/SSD and no previous system knowledge. If you need more information, please ask otherwise please mark this issue as resolved. |
@ffries - what are you talking about?
It looks like you need some guiding questions. :)
Your objects change value once a day. That's 100 kilobyte records per day :)
I have been using GNU/Linux and other operating systems since their inception. |
The BLE devices do update quite often. I assume it will ameliorate (eliminate?) the excessive write situation if I convert it to be using Zigbee instead of BLE? It states that in Zigbee firmware the sensor only reports every 5 minutes, which I hope can be made configurable. Or tweak BLE Measurement Interval/Advertisement Interval to max so HA updates every 3min? |
I wish to understand what is this case about... |
I don't think I fully understand this issue. I have raspberry pi 4 with 32 GB sd card and 4 thermometers in BTHome v2 mode. Does this affect me? Should I worry about lifespan of the sd card? I was expecting to changed it every year to be safe, but reading this meaning I should do it more frequently or switch to HDD? I do not need so detailed history (only maybe for week, then its okay to have average value for lets say 1 hour period, is there an easy way to setup it like that?) |
The entire database is rewritten every day to remove old data. |
On Debian(Armbian tested) you can bypass the option to write the BlueZ cache to disk in two ways: The Second way is more simple:
(pay attention to the option comment=x-gvfs-hide - it hides from BlueZ that this is a binded folder). |
90MB per month / three sensors = 30MB per sensor?
|
@Deoptim According to the "Uptime MMC writen" graph, the recording decreased by 320 megabytes per day. |
@pvvx |
i'm using this trick, i'm running homeassistant os + sd + hdd on a rpi... go to /var/lib/bluetooth/MACADDRESS and just run rm -r cache && > cache no more unnecessary writes to the microsd and all (seems) working at the moment, no needs to disable active scan (i have a switchbot bot to activate and requires the active scan to work) (i just started studing linux so i did all by my self, very happy :D) |
These are all problems with Bluez and it is not clear why it is used in Home Assistant. Bluez does not yet fully support Bluetooth 4.2 (Bluez: Core specification 4.2, 2014). Modern Bluetooth has version 5.4. |
@pvvx |
@Deoptim Со старта HA работает постоянно (питание автономное). Кроме HA ничего другого не установлено, docker не используется. Система на eMMC, HA c базой на NVMe. Производилось несколько обновлений всего ПО, но это копейки по сравнению с суточной записью HA. С примерно с 30-ти датчиков данные обновляются каждые 10 секунд. С других в среднем к 30 сек. Аналогично на все поддерживаемые устройства (это примерно к 20 типам устройств, часть из них ещё с 3-мя вариантами интерфейсов связи - Zigbee, BLE, Zigbee+BLE). Если система отработает год - полтора, то всё равно менять на новую платформу, т.к. для комфортной работы требования к производительности и ресурсам всегда растут. |
recorder in configuration.yaml:
Operating system on MMC. The main record on the MMC disk comes from Bluez to '/var/lib/bluetooth/'.
Home assistant database on SSD-NVME. Only write operations to 'home-assistant_v2.db-wal' and 'home-assistant_v2.db'.
All other write operations on ramdisk.
View all active disk writes in the system:
On the last 256 GB SATA solid-state drive, Home Assistant worked for 2 years before the TBW of the disk was exhausted. In the last few months, 'Available_Reservd_Space' has been exhausted on the disk ('Reallocated_Sector_Count' has reached its maximum). Uninterruptible power supply was used.
The text was updated successfully, but these errors were encountered: