Help requesting data from my server

I have an Electron that reads the data from a temperature sensor. Every 15 minutes, this electronic takes the data and compares it with a variable, if the temperature is below, it sends a JSON to the server.

The routine works, but this variable has a fixed value. My idea would be for that variable to be stored in my ElasticSearch and when the Electron connects, ask the Elastic Via Node what the value of that variable is.

Can you help me on how to do this? is it possible that the Electron will “request” a data directly to my Node without going through an API intermediary?

Thank you so much

Not knowing Elasticsearch, it appears you can GET data using the exposed API: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
Seeing as it’s HTTP, you might be able to do it from the device directly, or alternatively (to save on data), use webhooks.

If possible, why not have the server push the new value to the device it it sees it coming online?

Hi @Moors7

I’ll explain the case better. The problem comes because the Electron is asleep all the time.
The operator from the web changes the value by which he wants to receive the alert, for example from 20 to 10 degrees.
The Electron has the alert variable set to 20, when the machine rises, it has to ask “somewhere” if there are new variables, and it has occurred to me doing so, that the Electron asks for the new data.
The data is in a table in Elastic, but directly it is not the way, the idea is to make a GET request to NODE and it will return the field.
What do you think about it?
Eduard

I wouldn’t know why not. Give it a shot and let us know if it works :)?

on wake, publish an event that triggers a webhook…

wait for the webhook response (subscribe) before sleeping.

2 Likes