Make device appear online when using Rest API

Thanks for the explanation @PeteKnight! Excellent points. How would I then mark a device as online via the REST API?

Check this out

I think that “online” means that a keep-alive ssl/tls connection is present between the device and the server, so if you’re using the HTTPS API for pushing data to the server then by definition your device isn’t online.


Thanks @John93! But this just shows, if the device is connected, right?

Thanks for the clarification @PeteKnight. That means I need to keep the connection open, when sending API calls?

@floriandotorg I’ve moved this discussion to a new topic, as it’s unrelated to my original tutorial post and I don’t want that topic cluttered-up with this sort of stuff.

It would help if you explained what hardware, programming language and device topology you are using, and why the Rest API is your choice of commu8nication with the server.

Also, what is the benefit of having the device appear as Online?


It will return true if the device is online and false if the device is offline.

Thanks a ton @PeteKnight, makes a lot of sense moving it to the new topic.

The device is a very complicated python script running on a Raspberry Pi managing a battery. I didn’t use the python lib cause first I couldn’t make it run (“auth token invalid” whatever I tried) and secondly it forces a certain program structure that doesn’t fit particularly well for this use-case.

Seeing the device online would be a nice bonus, so I know everything is alright, and I don’t get an error message when changing values.

Okay, the error message when changing values, and the device offline indication won’t go away unless you solve your “invalid auth token” issue.
This is because the Blynk server is expecting the device to have an open, constantly maintained, channel of communication with the device, so that the device instantly knows when a widget value has changed.

The alternative is to move away from the Pythion script, or somehow incorporate what this script is doing, and use Node-Red instead (or as well).

Node-Red, with the Blynk IoT plug-in (contribution or contrib in Node-Red speak) will establish and maintain that ssl/tls connection with Blynk, and incoming values from widgets attached to virtual pins will be available within Node-Red.
You could then potentially use the node-red-node-pi-gpio plug-in for Node-Red to change GPIO values on the Pi, or maybe even communicate with your Python script.

To be honest, Node-Red could probably do everything that your Python script currently does, and communicate with Blynk and other peripheral systems at the same time.