Just read the state of the button (digitalRead() typically) and react to that in your loop(). To block it from doing anything else something like:
while (digitalRead(buttonPin) == LOW) {
ditigalWrite(solenoidPin, HIGH);
}
digitalWrite(solenoidPin, LOW);
This assuming button is wired active LOW, and the solenoid active HIGH.
Replace that later by something that reads your Cayenne.
You'll have to come up with a better solution for your 500 meter gap. Both Bluetooth and WiFi can't do this. Considering the distance you may need something with fixed directional antennas.