• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Values blank in IFTT trigger email sent via curl

Q&A Forum › Category: Other › Values blank in IFTT trigger email sent via curl
0 Vote Up Vote Down
vgershman asked 6 years ago

Hello,
Just in case someone had that issue. I am doing MicroPython IFTT project. When pressing “Test it” on IFTT site,  i get an email with 3 values. However, if i copy the curl command to my Windows 10 command line, the trigger fires, but the data in the email are blanks.
 
curl -X POST -H “Content-Type: application/json” -d ‘{“value1″:”23.2″,”value2″:”22.2″,”value3″:”55.5”}’ https://maker.ifttt.com/trigger/bme280-1/with/key/xxxxxx
 
Tnaks,
 
 

Question Tags: blank, email, IFTT, value
5 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

But do you receive the email? Does the final project work? Thanks for letting me know… I’ve only tested the command directly the IFTTT website.

0 Vote Up Vote Down
vgershman answered 6 years ago

Yes, i do receive the email, but with blank values.
The project, however fails. I tried with ES8266. when i run i get errors. I do not have bme280 yet, so i have dummy values:

Start your code here
try:
temp = 55.0
hum = 40.0
pres = 10.0

sensor_readings = {'value1':temp,'value2':hum,'value3':pres}
print ('Sensor read:', sensor_readings)

request_headers = {'Content-Type:application/json'}

request = urequests.post('http://maker.ifttt.com/trigger/bme280-1/with/key/' + api_key, json=sensor_readings,headers=request_headers)

But when i download, i get errors with http: (no “s”):
Connection successful-ful
(‘192.168.y.z’, ‘255.255.255.0’, ‘192.168.x.x’, ‘192.168.x.x’)
Sensor read: {‘value3’: 10.0, ‘value1’: 55.0, ‘value2’: 40.0}
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “<string>”, line 46, in <module>
File “<string>”, line 40, in <module>
File “urequests.py”, line 115, in post
File “urequests.py”, line 100, in request
File “urequests.py”, line 68, in request
TypeError: ‘set’ object isn’t subscriptable
if i use https: i get:
(‘192.168.y.z’, ‘255.255.255.0’, ‘192.168.x.x’, ‘192.168.x.x’)
Sensor read: {‘value3′: 10.0, ‘value1’: 55.0, ‘value2’: 40.0}
TLS buffer overflow, record size: 5143 (+5)
ssl_handshake_status: -257
Failed to read”help()” for more information.
Thanks
P.S. BTW why would the values be printed in different order than in the string above:
“Sensor read: {‘value3’: 10.0, ‘value1’: 55.0, ‘value2’: 40.0}”
 
 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

To answer your questions:

  • You need to connect to IFTTT with HTTP on the ESP. Please don’t modify that part of the code, otherwise it will not work.
  • When it prints the sensor_readings, “the string” is not ordered {‘value3′: 10.0, ‘value1’: 55.0, ‘value2’: 40.0} because it’s actually a Python dictionary. However, that will not affect the request and it works
  • The “TypeError: ‘set’ object isn’t subscriptable” error means that you’ve defined the dictionary in a wrong way. I’m not sure what’s missing from you, because on my end that dictionary works…
0 Vote Up Vote Down
vgershman answered 6 years ago

Thanks, Rui. It was my mistake.  I used wrong syntax.
I used the syntax from IFTTT curl line: “”Content-Type: application/json”” in the code you gave .
Your code had single quotes around each item :  ‘Content-Type’: ‘application/json’,
In the code i typed in, i was missing quotes: “‘Content-Type: application/json'”
As soon as i used your code i got the event fired and the 3 values in the email.
Sorry, to have bothered you with this.
Thanks again!
 
 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

No problem! I didn’t realize that too and I’m glad you made it work! Regards,
Rui

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.