Page 1 of 1

Update multiple fields thingspeak

Posted: 03 Aug 2021, 14:27
by zierbeek
Hi all,
Is there a possibility to edit the link that espeasy generates to update a field, i would like that multiple fields get updated. So i can make a plot of all temperatures and a daily average.

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 21:25
by TD-er
Do you have an example of the URL it now generates and how you would like to have it?

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 21:49
by zierbeek
Sure!

I think, at the moment it is something like :

Code: Select all

https://api.thingspeak.com/update?api_key=xxxxxxxx&field1=0
and i would like to have a second one so i could display daily averages without the need of creating a new channel and writing and reading from it.

Code: Select all

https://api.thingspeak.com/update?api_key=xxxxxxxx&field1=0&field2=

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 21:58
by TD-er
You can for sure create any formatted URL you like when sending from the rules.

You can also try to use the Advanced HTTP controller as it does allow for more elaborate formatting.
The Generic HTTP controller only splits per value.

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 22:17
by zierbeek
aha that can come in handy. in my espeasy setup, i don't see rules...

Will get the advance http, works better :)

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 22:26
by Ath
Rules can be enabled on the Tools/Advanced page.

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 22:43
by TD-er
That, or maybe he considers anarchy, ignoring rules ;)

Both can be a good reason for trying to use the Advanced HTTP controller ;)

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 22:49
by zierbeek
I get values on my thingspeak channel, it works with a static value. What is the variable for the output of the ds18b20? or how can i get it :)

update?api_key=xxx&field1=%device1%&field2=%device1%

I need to get the correct piece for the device

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 23:08
by TD-er
A task is given a name.
For example your dallas task is called "dallas" :)
Then the first temp sensor may be called "T1" (you can change it to whatever you want)

To access its value, you write [dallas#T1] which will be replaced by the current value of that task value.
See some examples here: https://espeasy.readthedocs.io/en/lates ... g-examples

Re: Update multiple fields thingspeak

Posted: 03 Aug 2021, 23:42
by zierbeek
hmm that doesn't seem like somthing i can put in the http request.

I'm very new to this. i would like that thingspeak can just copy 1 field to another, but not possible

Re: Update multiple fields thingspeak

Posted: 04 Aug 2021, 00:06
by TD-er
Why not?
These references (and other variables, wrapped in % characters) will be replaced when they are encountered.
So if you create an URL in the rules, you can use these and when the line is parsed, those will be replaced.

Re: Update multiple fields thingspeak

Posted: 04 Aug 2021, 12:24
by zierbeek
Yeah wrapped in the %. But what exactly is thé label i need to wrap in. At thé moment i only have one sensor, thé Dallas ds18b20

Re: Update multiple fields thingspeak

Posted: 04 Aug 2021, 12:39
by TD-er
If you only have one, you can use the [taskname#varname] syntax. Isn't the most universal solution, but for a single sensor you can try it to get started.
So literally using the square brackets and the names you assigned yourself to the task.

Re: Update multiple fields thingspeak

Posted: 05 Aug 2021, 09:33
by zierbeek
Hi, thanks!
It isn't a Task at the moment, it's only a device.

Re: Update multiple fields thingspeak

Posted: 05 Aug 2021, 14:32
by zierbeek
Yes, it worked!

Just needed to remove the '%' in my syntax.

/update?api_key=xxxx&field1=[zwijver#temperature]&field2=[zwijver#temperature] with zwijver being task and temperature the value.