Stream for variables

Hi Particle folks,
I’ve recently notice a couple of interesting commands in the particle CLI:

  • particle monitor device_id var_name returns continuously a variable value
  • particle monitor var_name returns continuously all variables values from all devices

I would love to be able to do the same with the CloudAPI. We already use the endpoint to get a stream of events from our Photons.

Do you plan to support the same for variables?

Wouldn’t that defeat the purpose of variables? If you want data to be pushed, why not just use publishes?

I guess you’re right @Moors7 .
Still I would have to enforce publishing max once a second on the firmware side, which shouldn’t be a problem.
The idea though is not about getting the variable pushed, but to get the most recent value with the least effort. Currently we pull most variables every 15 seconds. We could increase and send hundreds of requests per minutes (we handle many Photons) or open a stream for each variable and avoid the overhead of initiating a connection for each request.

It’s the exact opposite though. There’s no such thing as a variable ‘stream’, it’s just long-polling it. The SSEs are the actual streams, giving you the most up-to-date info.
The variables will keep returning the same value until you take a new measurement, whereas the events would only give you a value after measuring, saving you the (rather useless) data in between.

1 Like

You convinced me! Thanks for the quick answers. :smile:

1 Like