🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

IFTTT Filter Code RGB to HEX
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

IFTTT Filter Code RGB to HEX

by iHally on Tue Nov 05, 2019 6:29 am

After searching high and low with no success I was hoping someone could help with figuring out how to use the IFTTT service filter code with Adafruit.io
I am trying to create an applet to grab text from Google Assistant and send to Adafruit.io controlling some LED lights on an ESP. (this is easily done) But I would like the colours i say to be converted to HEX for Adafruit.io.

When you create a new applet with IFTTT you can add some filter code between the services to control things like active only during certain times or converting values etc
[url=https://platform.ifttt.com/docs/applets#using-filter-code]All tutorials[/url} are for services other than Adafruit.io

When creating the filter this text appears next to the box
Code: Select all | TOGGLE FULL SIZE
Trigger data
GoogleAssistant.voiceTriggerWithOneTextIngredient.CreatedAt
GoogleAssistant.voiceTriggerWithOneTextIngredient.TextField
Actions
Adafruit.sendData.skip()
Other
Meta.currentUserTime
Meta.triggerTime


Handy. But no indication of how to pass values appart from the skip() method.
the alt text on the method reveals
Code: Select all | TOGGLE FULL SIZE
const Adafruit: { readonly sendData: { skip(reason?: string): void;};}


I have no idea how to send the data. the only thing that works is Adafruit.sendData.skip()
The following with variation do not work
Code: Select all | TOGGLE FULL SIZE
Adafruit.sendData.value(
Adafruit.sendData(
return colours[colour.toLowerCase()]


Perhaps Adafruit.io IFTTT service does not want to allow filter code? or am i missing something obvious?

Here is my code attempt. (be gentle Im a noob who usually plays with c++)
Code: Select all | TOGGLE FULL SIZE
//IFTTT to adafruit.io filter code converting colour names to hex value
var colour = GoogleAssistant.voiceTriggerWithOneTextIngredient.TextField
var colours: {[key:string]:string} = {"off":"#000000","aliceblue":"#f0f8ff","antiquewhite":"#faebd7","aqua":"#00ffff","aquamarine":"#7fffd4","azure":"#f0ffff","beige":"#f5f5dc","bisque":"#ffe4c4","black":"#000000","blanchedalmond":"#ffebcd","blue":"#0000ff","blueviolet":"#8a2be2","brown":"#a52a2a","burlywood":"#deb887","cadetblue":"#5f9ea0","chartreuse":"#7fff00","chocolate":"#d2691e","coral":"#ff7f50","cornflowerblue":"#6495ed","cornsilk":"#fff8dc","crimson":"#dc143c","cyan":"#00ffff","darkblue":"#00008b","darkcyan":"#008b8b","darkgoldenrod":"#b8860b","darkgray":"#a9a9a9","darkgreen":"#006400","darkkhaki":"#bdb76b","darkmagenta":"#8b008b","darkolivegreen":"#556b2f","darkorange":"#ff8c00","darkorchid":"#9932cc","darkred":"#8b0000","darksalmon":"#e9967a","darkseagreen":"#8fbc8f","darkslateblue":"#483d8b","darkslategray":"#2f4f4f","darkturquoise":"#00ced1","darkviolet":"#9400d3","deeppink":"#ff1493","deepskyblue":"#00bfff","dimgray":"#696969","dodgerblue":"#1e90ff","firebrick":"#b22222","floralwhite":"#fffaf0","forestgreen":"#228b22","fuchsia":"#ff00ff","gainsboro":"#dcdcdc","ghostwhite":"#f8f8ff","gold":"#ffd700","goldenrod":"#daa520","gray":"#808080","green":"#008000","greenyellow":"#adff2f","honeydew":"#f0fff0","hotpink":"#ff69b4","indianred ":"#cd5c5c","indigo":"#4b0082","ivory":"#fffff0","khaki":"#f0e68c","lavender":"#e6e6fa","lavenderblush":"#fff0f5","lawngreen":"#7cfc00","lemonchiffon":"#fffacd","lightblue":"#add8e6","lightcoral":"#f08080","lightcyan":"#e0ffff","lightgoldenrodyellow":"#fafad2","lightgrey":"#d3d3d3","lightgreen":"#90ee90","lightpink":"#ffb6c1","lightsalmon":"#ffa07a","lightseagreen":"#20b2aa","lightskyblue":"#87cefa","lightslategray":"#778899","lightsteelblue":"#b0c4de","lightyellow":"#ffffe0","lime":"#00ff00","limegreen":"#32cd32","linen":"#faf0e6","magenta":"#ff00ff","maroon":"#800000","mediumaquamarine":"#66cdaa","mediumblue":"#0000cd","mediumorchid":"#ba55d3","mediumpurple":"#9370d8","mediumseagreen":"#3cb371","mediumslateblue":"#7b68ee","mediumspringgreen":"#00fa9a","mediumturquoise":"#48d1cc","mediumvioletred":"#c71585","midnightblue":"#191970","mintcream":"#f5fffa","mistyrose":"#ffe4e1","moccasin":"#ffe4b5","navajowhite":"#ffdead","navy":"#000080","oldlace":"#fdf5e6","olive":"#808000","olivedrab":"#6b8e23","orange":"#ffa500","orangered":"#ff4500","orchid":"#da70d6","palegoldenrod":"#eee8aa","palegreen":"#98fb98","paleturquoise":"#afeeee","palevioletred":"#d87093","papayawhip":"#ffefd5","peachpuff":"#ffdab9","peru":"#cd853f","pink":"#ffc0cb","plum":"#dda0dd","powderblue":"#b0e0e6","purple":"#800080","rebeccapurple":"#663399","red":"#ff0000","rosybrown":"#bc8f8f","royalblue":"#4169e1","saddlebrown":"#8b4513","salmon":"#fa8072","sandybrown":"#f4a460","seagreen":"#2e8b57","seashell":"#fff5ee","sienna":"#a0522d","silver":"#c0c0c0","skyblue":"#87ceeb","slateblue":"#6a5acd","slategray":"#708090","snow":"#fffafa","springgreen":"#00ff7f","steelblue":"#4682b4","tan":"#d2b48c","teal":"#008080","thistle":"#d8bfd8","tomato":"#ff6347","turquoise":"#40e0d0","violet":"#ee82ee","wheat":"#f5deb3","white":"#ffffff","whitesmoke":"#f5f5f5","yellow":"#ffff00","yellowgreen":"#9acd32"}
   if (typeof colours[colour.toLowerCase()] != 'undefined'){
        //data to send
   colours[colour.toLowerCase()]
       
   }
   else {
     Adafruit.sendData.skip("Don't know that colour")
   }


Thank you

iHally
 
Posts: 4
Joined: Tue Mar 26, 2013 10:40 pm

Re: IFTTT Filter Code RGB to HEX

by iHally on Wed Nov 06, 2019 11:08 pm

For a beif second another Action became availiable. Not quite long enough for me to save and test it.

Actions
Adafruit.sendData.skip()
Adafruit.sendData.setData()

There is a wizard working in the background making this a feature. Thank you!!

iHally
 
Posts: 4
Joined: Tue Mar 26, 2013 10:40 pm

Re: IFTTT Filter Code RGB to HEX

by iHally on Sun Nov 10, 2019 9:36 am

Embarrising simple mistake!

If you select the output to be editable by the user then the setData method dissapears/unavailable.

But if you make the output fixed then you can use Adafruit.sendData.setData( method. No matter what you put in the box at the bottom of the page under "data to save" (you have to put something) then Adafruit.sendData.setData(somethinghere) will override it.

This isnt obvious in the documentation. I should have clicked around more before seeking help.

Anyway here is my working code

Google Assistant colour name to hex value for adafruit.io controlling RGB led lights
Code: Select all | TOGGLE FULL SIZE
var colour = GoogleAssistant.voiceTriggerWithOneTextIngredient.TextField
var colours: {[key:string]:string} = {"off":"#000000","alice blue":"#f0f8ff","antique white":"#faebd7","aqua":"#00ffff","aquamarine":"#7fffd4","azure":"#f0ffff","beige":"#f5f5dc","bisque":"#ffe4c4","black":"#000000","blanched almond":"#ffebcd","blue":"#0000ff","blue violet":"#8a2be2","brown":"#a52a2a","burlywood":"#deb887","cadet blue":"#5f9ea0","chartreuse":"#7fff00","chocolate":"#d2691e","coral":"#ff7f50","cornflower blue":"#6495ed","corn silk":"#fff8dc","crimson":"#dc143c","cyan":"#00ffff","dark blue":"#00008b","dark cyan":"#008b8b","dark goldenrod":"#b8860b","dark gray":"#a9a9a9","dark green":"#006400","dark khaki":"#bdb76b","dark magenta":"#8b008b","dark olive green":"#556b2f","dark orange":"#ff8c00","dark orchid":"#9932cc","dark red":"#8b0000","dark salmon":"#e9967a","dark sea green":"#8fbc8f","dark slate blue":"#483d8b","dark slategray":"#2f4f4f","dark turquoise":"#00ced1","dark violet":"#9400d3","deep pink":"#ff1493","deep skyblue":"#00bfff","dim gray":"#696969","dodgerblue":"#1e90ff","firebrick":"#b22222","floral white":"#fffaf0","forest green":"#228b22","fuchsia":"#ff00ff","gainsboro":"#dcdcdc","ghost white":"#f8f8ff","gold":"#ffd700","goldenrod":"#daa520","gray":"#808080","green":"#008000","green yellow":"#adff2f","honeydew":"#f0fff0","hot pink":"#ff69b4","indian red ":"#cd5c5c","indigo":"#4b0082","ivory":"#fffff0","khaki":"#f0e68c","lavender":"#e6e6fa","lavender blush":"#fff0f5","lawn green":"#7cfc00","lemon chiffon":"#fffacd","light blue":"#add8e6","light coral":"#f08080","light cyan":"#e0ffff","light goldenrod yellow":"#fafad2","light grey":"#d3d3d3","light green":"#90ee90","light pink":"#ffb6c1","light salmon":"#ffa07a","light sea green":"#20b2aa","light sky blue":"#87cefa","light slategray":"#778899","light steel blue":"#b0c4de","light yellow":"#ffffe0","lime":"#00ff00","lime green":"#32cd32","linen":"#faf0e6","magenta":"#ff00ff","maroon":"#800000","medium aquamarine":"#66cdaa","medium blue":"#0000cd","medium orchid":"#ba55d3","medium purple":"#9370d8","medium sea green":"#3cb371","medium slate blue":"#7b68ee","medium spring green":"#00fa9a","medium turquoise":"#48d1cc","medium violet red":"#c71585","midnight blue":"#191970","mint cream":"#f5fffa","misty rose":"#ffe4e1","moccasin":"#ffe4b5","navajo white":"#ffdead","navy":"#000080","old lace":"#fdf5e6","olive":"#808000","olive drab":"#6b8e23","orange":"#ffa500","orange red":"#ff4500","orchid":"#da70d6","pale goldenrod":"#eee8aa","pale green":"#98fb98","pale turquoise":"#afeeee","pale violet red":"#d87093","papaya whip":"#ffefd5","peach puff":"#ffdab9","peru":"#cd853f","pink":"#ffc0cb","plum":"#dda0dd","powder blue":"#b0e0e6","purple":"#800080","rebecca purple":"#663399","red":"#ff0000","rosy brown":"#bc8f8f","royal blue":"#4169e1","saddle brown":"#8b4513","salmon":"#fa8072","sandy brown":"#f4a460","sea green":"#2e8b57","seashell":"#fff5ee","sienna":"#a0522d","silver":"#c0c0c0","sky blue":"#87ceeb","slate blue":"#6a5acd","slate gray":"#708090","snow":"#fffafa","spring green":"#00ff7f","steel blue":"#4682b4","tan":"#d2b48c","teal":"#008080","thistle":"#d8bfd8","tomato":"#ff6347","turquoise":"#40e0d0","violet":"#ee82ee","wheat":"#f5deb3","white":"#ffffff","white smoke":"#f5f5f5","yellow":"#ffff00","yellow green":"#9acd32"}
   if (typeof colours[colour.toLowerCase()] != 'undefined'){
     Adafruit.sendData.setData(colours[colour.toLowerCase()])
   }
   else {
     Adafruit.sendData.skip("Don't know that colour")
   }

iHally
 
Posts: 4
Joined: Tue Mar 26, 2013 10:40 pm

Re: IFTTT Filter Code RGB to HEX

by brubell on Mon Nov 11, 2019 11:13 am

I'm glad you resolved your error. Thanks for posting the resolution - it'll be useful for others!

brubell
 
Posts: 649
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.