Get rid off "false" Interrupt Signal when Motor starts

I've got a 24V Circuit which contains a Photoelectric sensor (this one)

This photoelectric sensor now is used as an Interrupt for the Arduino (I'm using a Voltage Divider to bring the 24V Signal to 5V, activated about once a second).

The Arduino than switches a relay which starts a Motor, and then the photoelectric sensor gets 'activated' and the Signal gets back to the Arduino, the Arduino switches off the relay, does some calculations, enables relay, and so on...

Now the problem is that sometimes when the motor starts the photoelectric sensor sends out a signal which causes an interrupt (I think caused by inrush current of the motor)

So I found a solution which works fine but I don't know if it's correct what I did

I just connected a 100nf ceramic capacitor from Signal to GND (I add a picture), without any resistor
should there be a resistor (in picture R1), if yes, which value should this resistor have

Is 100nf a proper value, or should I change it to something else?

The capacitor should just be across the lower resistor of the divider, then you won't be loading the
24V sensor output overly - it may not be designed for a capacitive load. 10nF may be plenty, experiment?

Basically the place to reduce interference is directly at the source, and right at the input to the Arduino.

You may have poor choice of cable layout with sensor and motor wiring alongside? Avoid this, motor
power wiring is usually quite noisy and it should be kept away from your sensors and their wiring for
a quiet life (!)

you mean like this (image added)

if you say 10nF is plenty, do you mean 10nF is better or is 100nF better (more secure), but 10 would maybe also be enough?

unfortunately, I can't change anything directly at the sensor or at the motor, the machine was designed by someone else

PS. maybe I'm lucky and you've also got an answer to my second question

you mean like this (image added)

Yes.

Yes 10nF might be enough but 100nF would be better.

You can always put it at the Arduino end, that is better than nothing.