Binary sensor switches 2 times?

I have a xiaomi door switch.
I made 2 wires on it and connected them to a normal on/off switch.
So the switch turns state on and off.
I made an automation wich switches a light on and off with toggle.
If i switch it on the lamp turns on. (State sensor is on)
If i turn off light in the hass app, after few moments the light turns on automatically.
If i switch it in app off again it stays off.
It looks like the sensor send something twice?
I there a way to make this work?

To me it looks like you’re doing something wrong :wink: Post your automation

i figured it out!
First i only triggered, now i put on/off in it and it works!

‘’’

  • alias: “kleine_tafel_toggle”
    trigger:
    • platform: state
      entity_id: binary_sensor.door_window_sensor_158d0001b75587
      from: ‘off’
      to: ‘on’
    • platform: state
      entity_id: binary_sensor.door_window_sensor_158d0001b75587
      from: ‘on’
      to: ‘off’
      action:
    • service: light.toggle
      data:
      entity_id: light.kleine_tafel
      ‘’’