Show that $E(X)$ = $E[(X|Y=y1) * 1(Y=y1)+ (X|Y=y2) * 1(Y=y2)]$

where $Y$ can be either $y1$ or $y2$ with some probabilities.

I suppose the result will not be restricted to $Y$ being binary, and the proof should extend.

Some clarification and the idea behind what is being asked:

Suppose I want to calculate $E(S(T))$ Where $S(T)$ represents the stock price at time T. However, it so happens that $T$ is also a random variable, so I want to be able to write this as:

$$E[S(T1)*1(T=T1)+S(T2)*1(T=T2)]$$

Note that $S(T1)$ and $S(T2)$ are still random and are stock prices in the future.