Best practice for reusable conditions

Hello,

I’m pretty new to HA and have two conditions that I use across multiple automations. Now that I’m adding more and more automations that’s starting to get problematic and I need a way to reuse these conditions and be able to edit them globally for all automations.

The first condition I have is a check for if the TV is being watched. I check this by looking at weather the TV is playing and the source isn’t Spotify as the TV is used to play music as well.

The second condition is weather all iPhones are set to the sleep focus mode or not. This is used to turn off all lights when the last person activate the sleep mode for example.

Is it possible to create a reusable condition for these?

Thanks in advance!

You can create a Template Binary Sensor for each of your two conditions. Reference the Template Binary Sensors in your automations. Any change you make to the binary_sensor’s behavior is automatically employed by the automations. Easy peasy.

1 Like

I’ll look into that, thanks!

That worked great for my use-case :slight_smile:

1 Like