Cannot figure out how to combine 2 automations

According to the trace, it entered the initial if statement’s else and proceeded to evaluate the second if statement’s test. That’s where it checks if switch.backup is on.

  - if: "{{ is_state('switch.backup', 'on') }}"
    then:

According to the trace, the result was false so it means the switch wasn’t on and the automation ended normally (it had no other actions to perform).

      "action/0/else/0/if/condition/0": [
        {
          "path": "action/0/else/0/if/condition/0",
          "timestamp": "2026-02-17T08:00:00.099920+00:00",
          "result": {
            "result": false,
            "entities": [
              "switch.backup"
            ]
          }
        }
      ]

All this to say that the automation executed all of its steps correctly. However, the outcome wasn’t what you had expected and may require investigation of switch.backup and why it was not in the expected state (on).


NOTE

Uh-oh! I think this may be my fault.

Looking back at your original automation, I believe the test should be to check if switch.backup is off, not on.

If that’s true, please modify the Template Condition accordingly and test the automation again.

  - if: "{{ is_state('switch.backup', 'off') }}"
    then:

That was it! The best part is now I can start to analyze this automation with good trace data and study if and learn from it. I learn best by example and have a really hard time learning by looking at docs, I think the biggest problem is I am not a programmer and it really takes a different mindset to be good at coding.

Thanks a bunch for the help!

Matt

1 Like

I’m fighting to not use the last several posts in this thread as an “I told you so…” moment. But I’m now failing miserably in that fight.

You had two working automations but wanted to merge them.

You couldn’t figure out how to do it so you asked here.

Someone did it for you.

then it didn’t work and you had to come here again and ask for help figuring out why it didn’t work.

repeat at least one more time.

the person who wrote the combined automation for you realized they made a mistake and fixed it for you.

success!

But what did you gain out of it?

If you couldn’t figure out why the submitted automation didn’t work by yourself then I’m not sure I would ever call that

[quote=“dtrott, post:8, topic:985482”]reducing the number of automations I need to consider does help my comprehension of whats going on.
[/quote]

You needed help with every part of reducing the number of automations in the quest for easier understanding but failed to understand how the resulting way more complicated automation worked and needed more help to troubleshoot it.

Sometimes more simpler automations are better than fewer overly complicated ones.

Whoever said that was giving you some good advice.

:wink: :smile:

You are entitled to you opinion of course.

What did I gain? I have studied the new automation and walked through it step by step and have learned a new way to do things… will I use it often? I don’t know.

With automations there are of course always multiple ways to accomplish the end goals. I now have 2 ways to do it that I understand and may use these methods in the future.

As I stated before, I learn by example, yes I asked for help to get it working… is that a sin? I thought this communities purpose was to help troubleshoot and to help users learn. Many of my automations are very old and I suspect somewhat inefficient. Cleaning them up helps me. There are many cases that I agree that 2 simple automations are better than one more complex one, but not in this case.

2 Likes

@mattlward - I think you said that very eloquently I was going to post something similar in response to the “told you so” post - but decided to let sleeping dogs lie.

It’s a volunteer forum, every respondent is going to have their own reasons for jumping in on a thread. In a lot of cases I only jump in if answering the question will teach me something too.

I also find the documentation lacking, in that the documentation authors have a very difficult task - they have to support an audience ranging from:

  • Those that have never written a line of code before, to
  • Those that have been kicking code professionally for decades.

And doing so, without being paid for it.

As such I believe the only way to learn HA is to experiment and your use case was small enough that I felt it was a good place to learn.

Additionally your started point was a post showing what you had done - again a major positive over other posts which simply say: It doesn’t work …

1 Like