IFTTT Post Ingredients - Date/Time Problem


#1

I’m trying to figure out how I can pull info from IFTTT to webCoRE. I made a test piston to figure out the $args and ingredients. One of the ingredients is a date/time. However, whenever it comes into webCoRE, it only displays the date.

I’m not sure what I’m missing or doing wrong.

image

image


#2

Why not just let webCoRE assign the time when the piston executes?


#3

I’m setting up an applet using ComEd and it Peak Time Savings. The applet currently sends me a notification letting me know when the PTS will start and end. I’m mostly interested in capturing the PrecoolTime ingredient. I am using Switch_On_Time in my text example which is a similar ingredient to PrecoolTime. In both case, webCoRE on displays up to the first coma. Ex. August 7, 2019 at 1:00PM. Only August 7, is displayed.

image


#4

I suspect their comma is breaking up that dataPoint…
(you can check for invalid json here)

It appears that ComEd’s JSON needs work, as seen in another post.

Normally, commas should not be inside dataPoints, unless the entire string is enclosed in quotation marks.

Can you find an “EndTime” that is written in this format?
2019-07-15T18:00:00.000Z


Edit :
Just to clarify, in your piston above, there is absolutely nothing that webCoRE can do unless IfTTT actually sends the time.


Alternatively, you can bypass IfTTT completely, and use webCoRE to query ComEd, as talked about over here. This way, you can strip out the comma etc… (often, even on an invalid JSON)


If you’d rather not work with an invalid JSON, you can try contacting ComEd. The fix should be easy on their end, and I bet they would like a functioning API.


#5

You’re right. The comma was acting as a delimiter. Thus I put the ingredient in quotes and now it returns the entire string.

SWON:August 07, 2019 at 09:57PM

{“SW” : {{SwitchName}}, “SWON” : “{{SwitchedOnAt}}”}

However, now I have to figure out how to extract just the time from the entire string. I’m looking to have a piston do something at the given time.


#6

It is definitely possible, but unfortunately I do not have enough freetime at the moment to give you the help that you need. Hopefully someone else can step up to the plate.

If it helps, you will find most of the needed code on this wiki page.


Also, this might be a bit premature, but keep in mind that if a global variable time changes, no piston will be made aware of the new time until after it has been triggered by some other means first. This is often the trickiest part to get right.


#7

Here’s a quick example to strip the time out, but it is still in string format. It will need to be converted into a time format. (see my last link)

temp


#8

I was able to work through manipulating the original string. When the date comes in from IFTTT;

  1. My variable test will strip off the last 7 characters
  2. test1a will then strip off the leading zero if there is one
  3. test2 will then format the final string into a time format that can then be used to compare with $time

There probably is an easier way to do this, with less steps, but this seems to work.


#9

All three steps can be combined in a single line, but honestly, I prefer breaking down in steps as you have done.


I am curious though… Why did you choose a double (identical command) on line 27? It basically says:
Show me the right 7 characters… and then take that result, and show me the right 7 characters.

I would condense that line slightly to:
Set variable {test} = {right(Switch_On_Time,7)}

Line 28 can be done similarly. There is never a need for right((right(variable,X)),Y)


And lastly, if you just need a visual indication, then a string variable saying “9:57 PM” is perfect. However, if you want that time to be a trigger somewhere, then that string will need to be converted into a time variable.


#10

:rofl: Don’t know why I did that. I probably was throwing everything at the wall and see what sticks.

I corrected it now. I did convert the last string to a time variable in order to compare it and be used as a trigger.