Really like using the trace functions to debug why things don’t work properly but the time they persist just doesn’t make it practical to use unless you are in front of the PC when the automation executes.
I’d like to be able to make the traces persist longer, even half hour would be great. At the moment I have a misbehaving automation that only runs when I arrive home (there are a lot more things than that) and it is not practical to re-create by simulating me leaving/arriving whilst in front of the PC.
By the time I get in the door, and get to the PC 2-3 minutes have elapsed, and by then, “Chosen trace is no longer available”. Haven’t managed to catch this automation once, the trace is always gone.
Currently only the last 4 or 5 traces are kept. But they are kept until HA is restarted.
There is a feature in the new release 2021.05 that allows you to configure the number of traces you want to keep (on a per automation)
It was in one of the release notes, you are supposed to put this in the automation or script.
trace:
stored_traces: 1
I have however found it to be ineffective. The ‘show trace’ button simply doesnt show up when you look in the logbook.
Edit: it does work, just not how I expected.
The traces stored from the Automations tab in the Configuration page shows it storing traces of automations that both were and weren’t triggered due to the conditions not being met. I assume it would only store the successful executions not the failed ones. I’ve got automations that run based on every motion event in my house (so can be every few seconds), and only pass under very specific conditions (occurs maybe every few minutes). Explains why stored_traces = 10 would result in the successful execution being quickly deleted, as the failed ones are quickly replacing it and when I go and try and check the trace of a successful execution just minutes after execution, I get trace not found.
Seems like this is here now…
Is it working for everyone?
—> UPDATE…
It worked for me but after a HA Core Restart. Reloading automations didn’t do it. This was on an Automation Blueprint I use for my Magic cube. Those thing spits out abut 4 null triggers to get one good one, which the conditions screen, but they all cause traces.Now I have 10 to search thru for it. AWESOME!!
I too have an automation that gets triggered frequently (once per minute) and my history of traces gets wiped out in a few minutes. I’m mainly concerned with SUCCESSFUL executions, but those are erased before I even have a chance to look at them.
Maybe store two categories of trace, both of which have a history. Success and Failure.
Related to this request - Home assistant seems happy to evict traces even if they are still running. This is very confusing if you have long-running automations (possibly by accident).
Conside this scenario:
I write a duff automation than run every minute
15 minutes later light in my house comes on.
I go into HASS, it says “tiggered by automation X”
I look at the traces for automation X, but it just shows the last 5 minutes of traces where nothing happend.
Use a time based history (keep traces for up to 6 hours and in any case always keep the last 5)
Make the cache based on some sort of priority
Don’t trace very dull runs, or don’t count them towards the cache limit
Dull runs could be things such as “Stopped because only a single execution is allowed”, or runs that don’t get past “wait” steps.
[@emontnemery ] you seem to have written most of the trace stuff. Any thoughts on whether this is a reasonable issue? of if any of these fixes would be viable?
This use case is one where it starts to get a bit near ok to use time patterns. But for a wakeup light that is on for maybe half an hour (don’t know, just guessing) it is triggering uselessly for the other 23.5 hours.
The only thing I miss from my previous home automation system is a transition helper (quite similar to a timer helper). With that you can set up a repetition count and a duration. It is like a temporary time trigger, that you can set off when you want and ends when the sequence is done. It could also be an option on the current timer to send intermediate events.
I’d consider writing one myself, were it not I do not know Python yet. I lack the time to even get ready to start writing one, let alone support it the coming years.