So it’s time to check how often this automation is running in reality.
Of course my first thought was that I might have duplicate automation or something similar. But I have changed the message received by the persistent notification and this is the one that I receive. I only think that the var component is receiving something that, despite being Success, is not verifiable by the if or the choose (I have tried both ways). Even so, this would be a rare error, because as you can see in the trace, the result of that if is false, and the action continues to be executed…
I’ll open an issue, thank you.
No. That is not what it shows. See 123’s explanation:
I highly doubt, that an issue is getting any attention. The first question will be the same, that was asked here for four times now:
Is this one specific automation running more than once?
This is a yes or no question - no maybe, no duplicates, nothing else.
Please, if you want this solved, just look at the automation traces and tell us how often it is run. Can’t be to difficult just to answer this one question, that is repeadetly asked here.
And on a side note: I recently stumbled over an old article, but it still is more than valid. I recommend reading it, when you have time to do so. It might not apply to all and everything here in this forum, but it is kind of a guidance on how to not make things more problematic, than they need to be.
For example:
Don’t rush to claim that you have found a bug
When you are having problems with a piece of software, don’t claim you have found a bug unless you are very, very sure of your ground. Hint: unless you can provide a source-code patch that fixes the problem, or a regression test against a previous version that demonstrates incorrect behavior, you are probably not sure enough. This applies to webpages and documentation, too; if you have found a documentation “bug”, you should supply replacement text and which pages it should go on.
Remember, there are many other users that are not experiencing your problem. Otherwise you would have learned about it while reading the documentation and searching the Web (you did do that before complaining, didn’t you?). This means that very probably it is you who are doing something wrong, not the software.
The people who wrote the software work very hard to make it work as well as possible. If you claim you have found a bug, you’ll be impugning their competence, which may offend some of them even if you are correct. It’s especially undiplomatic to yell “bug” in the Subject line.
When asking your question, it is best to write as though you assume you are doing something wrong, even if you are privately pretty sure you have found an actual bug. If there really is a bug, you will hear about it in the answer. Play it so the maintainers will want to apologize to you if the bug is real, rather than so that you will owe them an apology if you have messed up.
Here is the link:
http://www.catb.org/~esr/faqs/smart-questions
(as wanted by the authors of the linked text: this is not another support forum for HA, I’m just linking to an article!)
Yes yes, I can see that the automation ended, but I have the persistent notification evertime that the automation is executed, despite the trace shows that the execution don’t enter in the if.
Ok, the automation runs normally 1 time every night. I have 3 backups created in duplicati. Scheduled only one per night. When the backup ends, it sends the result to the home assistant, updating the corresponding var sensor. This works correctly I have checked it over the weeks. Later I thought it would be a good thing to notify me in a more striking way when the result of the backup is different from Success. I thought about the persistent notification and got to work. I update the state of the var entity as follows in a script at the completion of the backup:
current_datetime=$(date -u +"%Y-%m-%dT%H:%M:%S.%N%:z")
state="$PARSEDRESULT"
event_name="$EVENTNAME"
result_file="$RESULTFILE"
entity_id="var.estado_backup_local"
json_data="{\"entity_id\": \"$entity_id\", \"value\": \"$state\", \"attributes\": {\"event_name\": \"$event_name\", \"result_file\": \"$result_file\", \"datetime\": \"$current_datetime\"}}"
curl -X POST -H "Authorization: MY_TOKEN" \
-H "Content-Type: application/json" \
-d "$json_data" \
http://192.168.1.150:8123/api/services/var/set 2>/dev/null
As I say, this works fine. The problem is in the automation. The part where I send the persistent notification is executed even if the result of the if is false. I do not have any other automation in all home assistan that uses this service, also the appearance of the persistent notification coincides with the completion of the backup and therefore, with the execution of the automation.
Check your other traces, that one is not the one that created the persistent notification.
To prove it, change your condition in the if statement to this:
- choose:
- conditions:
- condition: template
value_template: "{{ false }]"
Then trigger your automation manually. Did the notification get created?
You don’t get what we’re saying, sorry! But we’ll get there.
What you think: A duplicate automation.
What we think: One automation is triggered multiple times. One time it works ok, but another time the condition is valid and so you get the notification.
See where I’m going with this?
Just do this: go to the automation trace (where you downloaded the trace) and open the menu in the center, all the way to the top.
Is the automation really only run once? We doubt that, that’s why we’re asking for it. Please check and report back.
Thank you @paddy0174, I understand now. And you are completly right… ohhh I feel stupid…
The problem was just that… The automation first execute one time changing the state from (the night before) “Success” to “En proceso”, and then execute a second time when the backup job finish changing the state from “En proceso” to “Success”…
The first wast the one that are executing the persistant notification service… sorry and thank you
I have changed the template in the if condition to solve this and it’s working fine now…
Glad you got it working!
But no need to thank me, the first one that was onto this was
@tom_l
!
Honestly, I’m happy, if I can be part of the solution. It may take a while, but in the end it was worth it, if the problem is solved.
Remember when I said this?
So it turns out you examined, and posted, the wrong trace file.
If you opened an Issue, you should explain what happened and close it.
Yes, you are absolutely right. I was blinded thinking that the automation was executed only once, since the backup job was very fast. As soon as I clicked the run button in duplicati, the backup start and finished (it’s an incremental backup) and I would see the “Success” status in home assistant. Looking at the trace history made me see that it was executed twice, once for the start and once for the end of the backup, and only in the last case the status change was “success”.
Thank you all so much for the support!