Maybe I don't understand...
You don't.
The message was not that SENSOR_VALUE was undefined or constant. It was the the case label was not a constant. Aside from the not-following-convention name, there is nothing to indicate that the name is not a declared variable of the correct type.