Call a service dependant on drop down value

I have a helper configured like this:


I can show this as an entity in Lovelace, but I am unsure how to call a service depending on the state of this - i’m not great with scripts etc.
Basically, if the state is changed, it needs to call a service where one of the attributes is the state

You have an example in the input_select doc:

 # This automation script runs when the thermostat mode selector is changed.
 # It publishes its value to the same MQTT topic it is also subscribed to.
- alias: "Set Thermostat Mode"
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
  action:
    service: mqtt.publish
    data:
      topic: "thermostatMode"
      retain: true
      payload: "{{ states('input_select.thermostat_mode') }}"

That doesnt seem to work for me:

  "action":
      service: surepetcare.set_lock_state
      data:
         flap_id: '680285'
         lock_state: '{{ states(''input_select.flap_state.state'') }}'

gives me an error:

 Stopped because an error was encountered at 16 August 2021, 11:23:04 (runtime: 0.02 seconds)

value must be one of ['locked_all', 'locked_in', 'locked_out', 'unlocked'] for dictionary value @ data['lock_state']

states(''input_select.flap_state'')

Genius! Thank you. Today I have learnt something, appreciate the help. :slight_smile: