August Welcome home greeting

Is there a way to have a trigger based on a state changing from a list of items to any item not in a list?

If Sensor state X changes from Manual Lock, Manual Unlock, Auto Relock, One-Touch Lock to anything but Manual Lock, Manual Unlock, Auto Relock, One-Touch Lock
do action

Thanks.

You can add it via code:

{% if states('sensor.lock')  != 'State I Want' %}
  ... do stuff here
{% endif %}

Thanks, (Jeep wave). And now for two things which will show how new I am to all of this.

  1. Where would I put that code? in the action element of the automation?
  2. Would I separate the multiple states with a comma?

I got it to work with one value (code at end), but not the entire list.
How should the IF line be? I I tried this and it didn’t work. Did I miss something?

{% if states('sensor.main_door_operator') != 'Manual Lock', 'Manual Unlock', 'Auto Relock', 'One-Touch Lock'  %}  
- id: "1620854877589"
  alias: Welcome Back
  description: ""
  trigger:
    - platform: device
      device_id: 6c652e113de5451aa323129d81b3b211
      domain: lock
      entity_id: lock.main_door
      type: unlocked
  action:
    - delay:
        hours: 0
        minutes: 0
        seconds: 10
        milliseconds: 0
    - service: tts.google_translate_say
      data:
        entity_id:
          - media_player.formal_speaker
        message: >
          {% if states('sensor.main_door_operator') != 'Manual Unlock' %}  
            Welcome home {{states('sensor.main_door_operator')}}
          {% endif %}
  mode: single