Update multiple fields thingspeak

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Update multiple fields thingspeak

#1 Post by zierbeek » 03 Aug 2021, 14:27

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Update multiple fields thingspeak

#2 Post by TD-er » 03 Aug 2021, 21:25

Do you have an example of the URL it now generates and how you would like to have it?

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: Update multiple fields thingspeak

#3 Post by zierbeek » 03 Aug 2021, 21:49

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=

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Update multiple fields thingspeak

#4 Post by TD-er » 03 Aug 2021, 21:58

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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: Update multiple fields thingspeak

#5 Post by zierbeek » 03 Aug 2021, 22:17

aha that can come in handy. in my espeasy setup, i don't see rules...

Will get the advance http, works better :)

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Update multiple fields thingspeak

#6 Post by Ath » 03 Aug 2021, 22:26

Rules can be enabled on the Tools/Advanced page.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Update multiple fields thingspeak

#7 Post by TD-er » 03 Aug 2021, 22:43

That, or maybe he considers anarchy, ignoring rules ;)

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

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: Update multiple fields thingspeak

#8 Post by zierbeek » 03 Aug 2021, 22:49

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Update multiple fields thingspeak

#9 Post by TD-er » 03 Aug 2021, 23:08

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

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: Update multiple fields thingspeak

#10 Post by zierbeek » 03 Aug 2021, 23:42

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Update multiple fields thingspeak

#11 Post by TD-er » 04 Aug 2021, 00:06

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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: Update multiple fields thingspeak

#12 Post by zierbeek » 04 Aug 2021, 12:24

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Update multiple fields thingspeak

#13 Post by TD-er » 04 Aug 2021, 12:39

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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: Update multiple fields thingspeak

#14 Post by zierbeek » 05 Aug 2021, 09:33

Hi, thanks!
It isn't a Task at the moment, it's only a device.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: Update multiple fields thingspeak

#15 Post by zierbeek » 05 Aug 2021, 14:32

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.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 29 guests