SD Card Corruption Problem? Couple Tips

In your configuration.yaml, recorder section (recorder: or recorder.yaml file), exclude every domain possible and include only the things you care about. I.e.:

purge_keep_days: 7
purge_interval: 1
include:
  entities:
    - binary_sensor.kitchen_opened
    - sensor.kitchen_temperature
    - sensor.kitchen_humidity 
    - binary_sensor.attic_opened
    - sensor.attic_humidity
    - sensor.attic_temperature
    - binary_sensor.tool_shed_opened
exclude:
  domains:
    - automation
    - binary_sensor
    - calendar
    - camera
    - climate
    - device_tracker
    - group
    - input_text
    - input_number
    - light
    - lock
    - media_player
    - remote
    - script
    - sensor
    - sun
    - switch
    - zone
    - weather

Thank you very much. I will modify my file “configuration.yaml”.

I can’t find the “recorder” section in my configuration file. I don’t have a file called “recorder.yaml” either.

What am I supposed to do? Thank you again

By default you won’t have an entry but you can create one. Here is a link to the document that covers it.

Thank you for your patience and help.

I haven’t been able to find anything about “recorder” in the Home Assistant docs. Now I know how to do it.

Tomorrow I will modify my configuration file.

My HASSIO instance just died a few days ago (this happened once before several months ago). I assume it is a corrupted SD card, because everything works fine with a new SD card. My latest backup was about a month old. Some headaches, but not the end of the world. I was back up and running in about 4 hours or so.

Now, a few days later, HASSIO just died again. I added the automatic backup to google drive add-on, so I have a snapshot from last night.

I am certainly guilty of logging way too much stuff. I barely have anything excluded and my log file takes FOREVER to open. I’ll have to change that. I have also been experiencing corrupted database files a lot in the past few months. Lots of deleting the database file and restarting.

I am using this SD Card: https://www.amazon.com/gp/product/B06XWN9Q99/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

Maybe I need a new power supply. I have the power supply that came with the CanaKit which I would expect to be good, but something isn’t right. Anyone have a specific power supply to recommend that is reliable?

To check if your Canakit power supply is good (which it should be), hook up the Raspberry Pi to an HDMI monitor or TV and check the output to see if there are any under-voltage warnings. Bad power supplies should get warnings within a minute or two. If there aren’t, then your power supply should be good and think about other solutions.

The Samsung Evo Plus and Select are identical… Amazon has exclusive rights to use the Select branding. So yes you are using a good card. Get rid of all those writes that you don’t need is a big step in the right direction. If you have a Synology NAS maybe setup a MariaDB I think I spent 45 minutes moving the database off the Pi including time to install the DB and phpMyAdmin.

Just unplugged and replugged the raspberry pi and wouldn’t you know it, that sucker booted right up. Huh… That’s a new one.

I need to look into some of the database options. I know next to nothing about databases, so it may take me some time.

Funny thing… not sure if others have experienced this. I have a few Pi’s for different uses and each have done the same thing at one time or another… not booted up and a quick turn the power off and on and they come right up. They have different power supplies so I think it is something with the RPi 3 B+. One power supply is from the Canakit, one is a 3 amp I bought and another is a 5 volt 5 amp tap from a transformer so they all should have plenty of power.

The remote database is kind of a no-brainer depending on what you have to run it on. I could not believe how easy it was to setup.

I have a windows 10 machine available. Do you know if that will play nicely?

Just make sure that if you move to an external DB server, that it is always up and running. So a desktop is probably not a good candidate. Also, you would need to shutdown HA before you do maintenance/updates on the DB server system.

After my SD card died recently I switched to MariaDB on Synology using Docker, very simple and a noticeable speed boost too on the HA responsiveness.

What did surprise me was a raise from 30 IOPS to 100 IOPS average disk activity on the Synology; even though I have pruned what is sent to the recorder the amount of transactions from HA is still more than I’d expect. Not sure of the cause of those yet, I have to look into some further monitoring tools to trace activity. I’d be shocked if HA team have spent much time assessing efficiency of transactions.

If your windows machine has enough power and is on all the time should work. For windows I would try this (link below) to make it much easier or run it in Docker on windows. I have no real experience with it though. It does bundle everything you would need together.

Also I followed this link to setup on my Synology NAS but I now run in Docker on my NUC. Except for actually installing the Maria DB and phpMyAdmin the rest of the setup should be pretty much the same.

It looks like I’ll try other items before going down the external database route. I changed my config to reduce the amount of writes to the database. We’ll see how it goes. I now have this:

recorder:
  include:
    domains:
      - lock
      - climate
    entities:
      - sensor.jeremy
      - sensor.nichole
      - sensor.tim_visiting
      - sensor.mike_visiting
      - sensor.paula_visiting
      - group.presence_trigger
      - input_boolean.on_vacation
      - sensor.house_locked
      - sensor.doors_closed
      - sensor.water_leak_status
      - sensor.grill_detector
      - sensor.fireplace_detector
      - switch.watercop_valve
      - sensor.water_valve_status
      - group.shop_lights
      - fan.finishing_room_exhaust
      - sensor.basement_average_humidity
      - sensor.shop_average_humidity
      - sensor.garage_multisensor_temperature
      - sensor.garage_multisensor_humidity
      - sensor.front_door_deadbolt_last_action
      - sensor.garage_door_last_action
      - sensor.deck_door_deadbolt_last_action
      - sensor.basement_door_deadbolt_last_action
      - sensor.front_door_last_code
      - sensor.garage_door_last_code
      - sensor.deck_door_last_code
      - sensor.basement_door_last_code

# Enables support for tracking state changes over time
history:
      
# View all events in a logbook
logbook:

What did you exclude?

Mine is more like this…

recorder:
db_url: mysql://root:redacted@redacted
purge_interval: 1
purge_keep_days: 4
include:
entities:
- device_tracker.faiths_cell
- device_tracker.vins_cell
- group.all_devices
exclude:
domains:
- automation
- weblink
- updater
- sensor
- scene
entities:
- sun.sun
- binary_sensor.anycubic_i3_printing
- binary_sensor.anycubic_i3_printing_error
- binary_sensor.dome_motion_detector_sensor_2

I excluded EVERYTHING that is not on the include list.

From the recorder doc (note the part that says: If set, all other entities will not be recorded.):

include
(map)(Optional)Configure which components should be included in recordings. If set, all other entities will not be recorded.

domains
(List)(Optional)The list of domains to be included in the recordings.

entities
(List)(Optional)The list of entity ids to be included in the recordings.

Basically it breaks down into 3 categories based on what you put in your config:
include only → excludes everything not on the include list
exclude only → includes everything not on the exclude list
include & exclude → 3rd option that I don’t 100% understand.

In the documentation they give a specific example that does make sense. Basically goes like this:

Include the domain “sensor” for example. Let’s pretend you have 100 sensors, but only want to keep 99 of them. You could then EXCLUDE a specific entity. Note this case includes the domain and then excludes entities within the domain.

I’m not sure what happens if you include some domains AND exclude other domains at the same time. It seems like you end up with a contradiction. (include causes unspecified items to be excluded and exclude causes unspecified items to be included this leads to the unspecified items being both included and excluded) Hopefully that makes sense.

I’m not sure I quite got what the documentation is saying either but I’m happy with what shows up in my logbook and I know a bunch of stuff I didn’t need is gone now.

Thank you for carefully preparing two effective hardware repair methods. I have already collected these two methods, and they will definitely be useful to me at the crucial moment. I also have seen several other tips for repairing SD cards. Please allow me to make a supplement.

THX for all the hints, also not thougth about logging config so far at all.
→ Are all this problems not relevant by migrating to “Home Assistant Blue” ?
THX M