Page 1 of 1
Custom block
Posted: Sun Oct 15, 2017 12:28 pm
by gillesroszak
HI guys,
Being a real noob in coding, i need your help for building a custom block.
I have a nodemcu esp8266 who collecting data from T° sensors DS18B20 and send them to thnigspeak who makes graph
I would like to include this graph (iframe) thingspeak to a blank block but I have no idea how to do it !!!!!
Thanks for your reply
Re: Custom block
Posted: Sun Oct 15, 2017 12:40 pm
by Jachym
Gilles a block with an iframe is likely to look quite bad because it will be small and slowing your page down. I would say try to avoid iframes as much as possible, especially in blocks
Re: Custom block
Posted: Mon Oct 16, 2017 11:17 am
by gillesroszak
Hi Jachym,
thanks for your reply.
May be there is another way to go ??
Thingspeak provide an API request code, see below :
GRT channel feed :
Code: Select all
GET https://api.thingspeak.com/channels/343953/feeds.json?api_key=......&results=2
Or GET channel field :
Code: Select all
GET https://api.thingspeak.com/channels/343953/fields/1.json?api_key=....&results=2
Can we do something with it
Re: Custom block
Posted: Mon Oct 16, 2017 11:37 am
by Jachym
Yes, that would be much easier, parse the JSON file and then display it in the block much better solution then Iframe.
I edited your post and deleted the API keys from the URL
Re: Custom block
Posted: Mon Oct 16, 2017 11:48 am
by gillesroszak
thanks, for deleting the API key jachym
Can you help me or tell me where i can found some tutorial or explanation to do it please.
it seems to difficult for me
Re: Custom block
Posted: Mon Oct 16, 2017 12:05 pm
by Jachym
gillesroszak wrote: ↑Mon Oct 16, 2017 11:48 am
thanks, for deleting the API key jachym
Can you help me or tell me where i can found some tutorial or explanation to do it please.
it seems to difficult for me
It depends what information from the API result you want.
Re: Custom block
Posted: Mon Oct 16, 2017 1:41 pm
by gillesroszak
there will be 2 data series, (soil T° 10 cm and 20 cm) i just want to display the current T° so the last data
Re: Custom block
Posted: Mon Oct 16, 2017 2:53 pm
by Jachym
OK, email me the URL with the full API key so that I can look at it and I will send you the customized block by email as well
Re: Custom block
Posted: Mon Oct 16, 2017 3:18 pm
by gillesroszak
Ok done it
Thanks
Re: Custom block
Posted: Mon Oct 16, 2017 5:41 pm
by Jachym
I sent you the working block.
Re: Custom block
Posted: Mon Oct 16, 2017 5:46 pm
by gillesroszak
yes but it does not update ???
What can be the problem ?
Re: Custom block
Posted: Mon Oct 16, 2017 5:49 pm
by Jachym
It is cached, if you want to change the cache time
go to the script and modify the number:
if (time()-filemtime("cache/data.txt") > 60 * 30) {
in minutes
Re: Custom block
Posted: Mon Oct 16, 2017 5:55 pm
by gillesroszak
OK if I want an update every 10 mn what should i write ?
Very sorry Jachym but ......
Re: Custom block
Posted: Mon Oct 16, 2017 5:57 pm
by Jachym
gillesroszak wrote: ↑Mon Oct 16, 2017 5:55 pm
OK if I want an update every 10 mn what should i write ?
Very sorry Jachym but ......
Change 30 to 10:
60 * 10
Re: Custom block
Posted: Mon Oct 16, 2017 6:10 pm
by gillesroszak
Thanks