I’m trying to send commands to a Particle Photon using an HTTP Post; I’m building a Particle powered “vacation monitor” that I can take to hotels or anywhere with a wifi network that can trigger audible and visual feedback in response to OH switches that are defined in an item file; the main use case is letting me know about intrusion alarms or other issues without relying on my phone (which could be on do not disturb, etc.)
My point is that I don’t want to use MQTT or a similar service; I’d rather send an HTTP Post command to the Particle web service to trigger these Particle functions. I tried using IFTTT: it works but with an unacceptably long delay.
@guessed, I looked at your example in a different thread as a starting point. It’s not working as expected. I don’t have experience working with JSON so I’m looking for someone to tell me if there’s something glaringly wrong with my code.
particle.rules:
val String MY_URL = 'https://api.particle.io/v1/devices/mydeviceid'
var String myData = '{
"ohc": {
"access_token": mytoken,
"args": "AlarmOn",
}
}'
rule "Openhab Particle Monitor"
when
Item OHMonitor changed to ON
then
sendHttpPostRequest(MY_URL, "application/x-www-form-urlencoded", myData)
end
My Particle function is ohc, the argument I’m looking to trigger is AlarmOn. Obviously mydeviceid and mytoken are stand-ins for my actual tokens.
Let me know if you hit any issues, but it’s “straight Particle” in terms of device ID, functions, variables, and dynamically adjusts to the item types it’s bound to, so it ought to work for any Particle application. The OH2 version will support SSE events for near real-time item updates, but the Garadget binding has an adjustable polling cycle in the meantime.
@watou I am trying to use this on oh2, (it was available in Paper) but I don’t see anything in the Particle Console.
I set up the account username/password in the Paper config. I am just trying to send a simple command to the core which is listening via a function. (Spark.function(“color”, color);Spark.function(“color”, color)
@Billmans, I don’t ever see anything in the Particle Console from this binding. At least in my case it doesn’t seem to affect functionality and I can’t speak to whether this is intended or not. Good luck!
@watou, I forgot to thank you for your help. I got it working and, thanks to your binding, released my work as the “Openhab Particle Monitor” on Github. It uses an Internet Button to make notifications.