I did something similar here, maybe some of the code will be helpful to you. Particle now supports the RPi, so you'd be able to use the webhook stuff I used as well.
GitHub - Here-Be-Dragons/Pool-Controller: Cloud-based pump speed, solar collector controls, and temperature monitoring for your pool