Is it possible to use condition that contains a string

Hi everyone, I am new to HA.

I have installed Hass agent on my computer and trying to achieve an automation based on the active window of my pc.

condition: state
entity_id: sensor.asusrhox_activewindow
state: "active window title"

This only works is the active windows doesn’t change at all.

active window returns title of the window. I can’t use is because title changes depending on the active tab of the browser. I want to use a condition that contains a string so I it works.

brave_AKgYgHZ1R6

Is it possible?!

1 Like

Use a Template Condition to check if the string you want exists within the state value of sensor.asusrhox_activewindow.

- condition: template
  value_template: "{{ 'the string you want' in states('sensor.asusrhox_activewindow') }}"
4 Likes

That worked thank you very much.

please mark as solution :wink: