Text virtual pin webhook and display in the app

Hi All,

I would like to get a text variable from a http request (get) and display it in the app,
in order then to use it with the eventor.

My http request return a single word. I have set up the webhook to get it in “text/plain”
format and put the output in V1. But I see no way to display it.

Am I missing something ?

More generally, can text be in a virtual pin, or VP are only numbers ?

If yes, how to display in the app, without coding the hardware ?

By the way, I have already programmed the ESP8266 to do everything by coding the http request, but I want to see If I can do everything in the app, without coding.

Thanks

Is your webhook request actually giving you the single word response?

If it is then you can simply virtualwrite() it to a widget.

Yes, the http request gives a single word answer.

question A : can I do everything on the app (Android) and display the value there ?

question B : can I use this value in the eventor.
I want to open or close a switch depending on this (text) value.

Yes, you can.

You mean in the codition “if V1 == xxx”? Yes, but only in case this is the number.

Could you please describe your use case so we can help you?

Thanks Dmitriy,

I monitor an electric heater with an ESP8266 and Blynk with the eventor.
In addition, as my electricity fare depends on the day ( peek demand or not)
I want to avoid to use the radiator when the fare is high, which occurs some days in the year.

I can get the condition of the day with a http request at

http://domogeek.entropialux.com/tempoedf/now

This will give a single word, BLEU, BLANC, ROUGE

So I want to use this result in the eventor to decide if I use the heater or not.

I have already coded directly the request, and can retrive and display the result in a blynk app of test, before putting it in my main application, but I saw the webhook widget, and wonder if I could do everything in the app.

I see… The WebHook widget was designed for the hardware side. So typical use case for your case would be:

  1. Add the webhook widget for some pin, let’s say V1 and configure it as GET request for http://domogeek.entropialux.com/tempoedf/now ;

  2. In order to perform the web request to the above url you need to trigger the webhook. For that, you need to call regular virtual write on hardware Blynk.virtualWrite(V1, "any value here");;

  3. In order to get the response from the webhook you need to write:

    BLYNK_WRITE(V1){
    String webhookdata = param.asStr();//BLEU, BLANC, ROUGE
    }

  4. That’s it. Now you may send those value back to app or turn off radiator;

Unfortunately, the eventor doesn’t support strings right now. However, this would be the good improvement. I’ll take a look into it.

Webhook docs - http://docs.blynk.cc/#widgets-other-webhook
Ticket - https://github.com/blynkkk/blynk-server/issues/839

Thanks for reporting this use case.

Thanks for the precisions

I made it work like that

BLYNK_WRITE(V30){
   String tempo = param.asStr();//BLEU, BLANC, ROUGE
   USE_SERIAL.println("webhook ");
   USE_SERIAL.println(tempo);
   Blynk.virtualWrite(V31, tempo);
}

and write the value in the app with V31.
At least I see it works.
As I understand, to use it really in the app, I need to convert it first to integer with
something like

int ipo;
ipo=0;
if (tempo=="BLEU")  {ipo=1;}
if (tempo=="BLANC") {ipo=2;}
if (tempo=="ROUGE") {ipo=3;}      

and then

Blynk.virtualWrite(V32, ipo);

All this now work, and I should be able to link with the eventor. This is great.

But I do not find it satisfactory. It is just finding a tricky path to go around the normal
behaviour of the app.

I understand that it was not meant to do that, but I do not see why one should
go through the hardware to get the outcome of the http request in the app.
In fact, my full initial code (with everything in the hardware) was not that complicated.
What worried me is that I would have to update all devices with these requests.

I understand that you will add conditions with text in the eventor.
That will be nice, but not as much an improvement as to allow to totally bypass the
hardware.

Best Wishes for the New year.

Jacques

PS : I was one of your kickstarter supporters and really congratulate you for the improvements you made in the past two years.

1 Like

Sure. We will work on that.

@jacquesBBB I notice there are quite a lot of 3rd party sites that provide access to EDF’s api and that EDF themselves say with the tempo option the “color” for the next day is available via the internet https://particulier.edf.fr/en/home/energy-at-home/electricity/blue-tariff.html (Tempo option selected).

Does EDF only provide access to the api via their online billing interface?

Edit found what I needed: OK the colour for today and tomorrow is available at https://particulier.edf.fr/fr/accueil/contrat-et-conso/options/tempo.html# but this is not their API and would require a search for “Jour bleu”, “Jour blanc” or “Jour rouge”.

The API appears to be available directly from:

https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=[date]&TypeAlerte=TEMPO

By looking through ClassTempo.py at https://github.com/guiguiabloc/api-domogeek/blob/master/ClassTempo.py the format for the date is Y-M-D so 2017-12-31 for today and this returns:

{"JourJ":{"Tempo":"BLEU"},"JourJ1":{"Tempo":"BLEU"}}

This is colour for today and tomorrow.