1 Lamp in 2 Automations

Hello, I have 1 automation that when I turn off light A, light B also turns off. But there is a second automation that also switches off light A and then light B may not go out. Is this possible, and if so how do I do this?
Thanks for every response.

Can you explain further what you mean by:

Then light B may not go out

What conditions would make it so that light B would not go out?
Is Light A going from on to off, the trigger to turn off light B?

It would be helpful if you post the automations formatted so the community could see what you are doing and then could answer your question.

Thanks for your response.

There is 1 automation that when lamp 1 switches off, lamp 2 also goes out. But there is a second automation that switches off lamp 1 and then lamp 2 must remain on.

It is hard to tell what ways the light can turn on and off, and when you want them synced and when not. Without knowing that, my first instinct would be: create a group for both lights. Use the group to turn on and off when you want them to do the same. You retain control of both lights individually.

But if this helps depends entirely on the ways you want to turn both lights off together. Being called form an automation can mean many things.

The second automation could call the service automation.turn_off on the first automation before it turns off lamp 1, then call automation.turn_on after. In this way, your automation 1 will happen at all times that light 1 turns off except when it is turned off by automation 2.

Use trigger ID’s, Choose or A/B conditions. If/Then may work also. There are numerous ways to handle this.