Logbook spam - where to configure filters?

Relatively new to Home Assistant. I’ve used it for about 3 months now, primarily to automate my grid DIY PowerWall-alike battery system - switching inverters on/off based on power meter reading, scheduling charging. I’ve done nearly everything solely using the web UI.

Trying to diagnose why one of my pair of routine automations isn’t running as scheduled, and I open the logbook… and it seems like every time I open the logbook the past few days, I get spam that looks like this:


“MQTT connect count changed to 12”
“WiFi connect count changed to 3”
“MQTT connect count changed to 12”
“WiFi connect count changed to 3”
“MQTT connect count changed to 12”
“WiFi connect count changed to 3”
etc etc etc… over and over, constantly trickling in as I watch the page.

There doesn’t seem to be any configuration for Logbook filtering - and a very common frustration I’ve had with Home Assistant is that everyone speaks in “code” - when telling someone how to do something, they refer to some obscure block of config text that I can’t find any reference to anywhere in the UI. So, advice has been given on how to filter the “logs” (same as logbook? not sure - “logs” is a name of a different page in this site), but the advice is given in the form of a config block, like so:

Well, great! I don’t know what to do with this info :joy:

It’s almost like this entire web UI is an entirely different “product” than the Home Assistant there’s so much info and documentation for - and there’s no documentation for the web UI itself. I would love to filter a ton of actual garbage/noise out of my Logbook (automations triggered every minute, for example) and make it more useful. And probably reduce database clutter as well…

Advice?

1 Like

Put this in your configuration.yaml file then restart:

logbook:
  exclude:
    entities:
      #list of entity_ids you want to exclude goes here e.g.
      - binary_sensor.some_sensor
      - binary_sensor.some_other_sensor
1 Like

Do I seriously have to go ripping into the server’s file system to make simple edits to log filters?

Is all the documentation advice built around ripping into config files by hand? :astonished:

I would have expected a built-in editor in the web UI, because the web UI seems to be incredibly thorough and not leave many/any other needs to make manual edits (I’ve not had to directly edit a single config file so far, and I have pulled a lot of stuff together in here). But the closest I can find is a documentation page basically saying “have fun, enjoy SCPing your way out of this mess”: Configuration.yaml - Home Assistant (home-assistant.io)

As HA is still a growing system and is coming from config yaml files you have to adjust the confit file for filtering the logs.
If you are not happy with that you can develop a webui for this and submit a change request. It is all open source and everyone is welcome to contribute

That used to be the only way to configure Home Assistant.

The frontend is growing to encompass more of the configuration with every release but it is still a work in progress.

If you can type in a text box you can type in a file. There’s not much difference. Even Paul Hibbert can do it.

1 Like

:joy::joy:

Also worth pointing out that excluding from log book won’t exclude from recorded but excluding from recorder will exclude it from logbook….unless that’s changed recently.

2 Likes

If editing config files is so essential, why isn’t there a way to do it from the web front-end? I would think that should be feature #0 (blocker) in evolving a system away from config-file-editing.

As it is now, I’ve built my whole HA system without ever needing to SSH into the box (except for an attempt to set-up/debug ZeroTier, which never worked - could never be connected-to through the VPN), and never needing to edit config files directly. The web interface covers everything.

It’s just been an incredibly frustrating process trying to take the “happy path” of installing HA via a virtual machine, configuring it, but every time I Google something, it doesn’t even touch the HA web interface (the happy path), it always references some esoteric YAML blobs out-of-context. Not a great experience for something that hopes to gain more mainstream consumer adoption with a well-polished (honestly! it’s great!) web interface.

As it is now, I would have to dig up the location of this configuration.yaml file, fire up/configure WinSCP to connect to it, pull out the file, edit it, put it back, and hope the web interface doesn’t trample it. It feels a lot like asking someone to SSH into their consumer router and edit a file just to change something as pedestrian as the DHCP IP range.

Most of my frustration here, honestly, comes from the attitude of “this is perfectly normal”.

I guess let’s try and find a resolve here the “hard way”. I’d like to figure out how to exclude this “connect count changed” spam and the automation-triggered spam for certain automations - from even being recorded (so it doesn’t clog up its database). Optimally, also to clean out the past logs. So:

  • how can I figure out what the entity names of these logbook entries are? (from there, presumably I can expand it to wildcards)
  • how can I clean up the logbook DB entries?

You can simply go to Settings / Add-ons / add-on-store and install “File Editor”.

That will give you a simple web based editing tool and by default give you access to config folder and all the files contained within.

The move to make less yaml and more Ui has been immense recently, however its a contentious issue as yaml is in most cases a dam sight more powerful than what’s readily available in the Ui. Some like the Ui only and others prefer yaml.

I think you have to remember that HA is super powerful and that is what makes it more complicated, it has very few limitations, but with that comes complexity. Compare it to any other products like smartthings for example and you will see that is all Ui based and because of this its super limited.

Home assistant is by far the best because it offers both yaml and Ui in my humble opinion.

Give the file editor a go and see how you get on.

1 Like

Right - I was pretty in-love with its UI’s ability to allow powerful integrations/automations in a relatively straightforward way - though I was frustrated with a bit of its odd logic interactions*. It’s really well done, allowing me to create an automation “program” that monitors my home power meter and switches inverters on/off.

* e.g. an automation’s actions run in sequence, even though one of them was “call service: trigger automation” which seemed like it should be a non-blocking asynchronous trigger, but required intensive logic re-writing when I discovered it was waiting on each trigger’s automation to fully complete - some of which included 3 to 10-minute wait periods.

And I’m off to do that now :slight_smile: Still need to figure out how to find the entity names, though :thinking:

oh dear. that log spam is INTENSE. :astonished:

image

Uh, can we crunch that database down from 1.5 GB?! :joy::sob::skull:

Edit recorder (yes…in yaml :wink:) and choose to either exclude all and list what you want included OR include all and list what you want included. excluded.

Go to Developer tools / template and clear whats in there and paste the following code:

{% for state in states %}
- {{- state.entity_id -}}
{% endfor %}

This will list all entities for you.

You could also go to developer tools / states and see a complete list with a handy little copy icon next to each one that will aid in cutting and pasting. Take your pick.

1 Like

Yeah! This seems to have silenced my log spam for that “connect count” stuff… and tomorrow I’ll see if it also silences the irrelevant automation triggers (on a minute cycle, and they fire off other automations based on their conditions):


# Loads default set of integrations. Do not remove.
default_config:

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
shell_command: !include shell_commands.yaml

recorder:
    exclude:
        entities:
            - sensor.inverter_1000w_mqtt_connect_count_2
            - sensor.inverter_1000w_wifi_connect_count_2
            - sensor.inverter_600w_mqtt_connect_count
            - sensor.inverter_600w_wifi_connect_count
            - automation.inverter_down_cycle
            - automation.inverter_up_cycle

OK, and from here - any way to purge the past log history and compact that database?

1 Like

Select the purge service from Developer Tools > Services. Select the “Repack” option and switch it on before running the service.

1 Like

I also had to select “days to keep: 0” for it to have an effect, but after doing that + Repack, my server’s off and humming… (running on an old ThinkPad E420 in a VM on an SSD)

It’s doing about 2.5MB/s disk I/O, on a 1.5GB database, so I’ll check in on it tomorrow :joy:

We seem to be set, then! Thanks! :grinning_face_with_smiling_eyes:

1 Like

haha, OK, final conclusion. It ran pretty quickly, and it did clear my logbook, but… it didn’t have an effect on the database size. Still 1.5GB. (and yes, Repack was checked)

I dug a little deeper and installed the SQLite web add-on as well - via this thread: How to keep your recorder database size under control - Community Guides - Home Assistant Community (home-assistant.io) - I ran the query to find the size of all tables, and they were all under 1MB at most. Strange.

One more Google for how to make SQLite compact itself, and I found the “VACUUM” query. So I simply ran the query:

VACUUM;

And voila, instantly:

Great success. :sunglasses: