Help with automation Zwave doorsensor

Hit there,

I’am struggling to get an automation wright. I have a Z-wave stick (gen5) with a Coolcam doorsensor. Both I can see and I made it so far that when my sliding door is open or closed I get a notification in Telegram,
But now my problem, I get both notifications in one message every time.

Who van help me with this?
My yaml file looks like:

- id: '***************'
  alias: 'Schuifpui '
  description: ''
  trigger:
  - entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_door_window_detector_sensor
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_door_window_detector_sensor
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      message: schuifpui is open
      title: Schuifpui
    service: telegram_bot.send_message
  - data:
      message: schuifpui is dicht
      title: Schuifpui
    service: telegram_bot.send_message
  mode: single ```

You should make it 2 separate automations.

Hi pensionado,
thanks for your quick answer. I will try it.

Greetings

Bastiaan

unfortunately it doesn’t work. where do I start the second automation?
would you be so kind to help me set up both?

Set up 1 automation for the sensor going from on to off and the second for off to on, so you have 2 separate automations. Something like this:

- id: '***************'
  alias: 'Schuifpui '
  description: ''
  trigger:
  - entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_door_window_detector_sensor
    from: 'on'
    platform: state
    to: 'off'
  action:
  - data:
      message: schuifpui is open
      title: Schuifpui
    service: telegram_bot.send_message
- id: '111111'
  - entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_door_window_detector_sensor
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      message: schuifpui is dicht
      title: Schuifpui
    service: telegram_bot.send_message

thank you very much. I will try this

finally, it works the way I want.
this is the final automation.yaml file which works

- alias: Schuifpui dicht
  trigger:
  - platform: state
    entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_door_window_detector_sensor
    to: 'off'
  action:
  - service: telegram_bot.send_message
    data:
      message: schuifpui is dicht
  id: *****************
- alias: Schuifpui open
  trigger:
  - platform: state
    entity_id: binary_sensor.shenzhen_neo_electronics_co_ltd_door_window_detector_sensor
    to: 'on'
  action:
  - service: telegram_bot.send_message
    data:
      message: schuifpui is open