Open-collector comparator with hysteresis and LED indicator at output
You need to learn to do error budgets.

1) Are your 24 and 5 volt supplies exactly 24 and 5 volts? If not, what will this do to your trip points?

2) I'll assume your resistors are 1% units. Go through the various permutations of each resistor being 1% off (99% or 101% of nominal) and look at the results. Combine this with 1) above.

3) Your speculation about D1 is probably correct (at least as a factor), but there is no excuse for not determining its effect rather than speculating. With the 293 output high, exactly what voltage do you see on the output? How about when the output is low?