My UPS (using NUT) goes has an entity called ups status data, which shows all of the current statuses for the UPS, concatenated together.
For example, under normal conditions, the UPS has a full battery and is on line power, so the value is simply "OL". However, when it switches to battery power and is discharging, it states "OB DISCHRG", meaning it is On Battery and it is Discharging.
This is fairly simple, but is difficult if it has other statuses as well. Let's say it's just got power back after draining to just above the "low battery" threshold. The entity would say "OL CHRG". But if it returned below the "low battery" threshold, it would say "FSD OL CHRG", meaning "Forced Shutdown, Online, Battery Charging" (the most important value always goes first).
My question is, how can I have an automation run when the entity changes so that it now has "OL" as part of it? But not run repeatedly when it changes beyond that (such as changing from FSD OL CHRG to OL CHRG)?