ControlEverything.com Particle Photon special firmware for reporting 7 inputs ON/OFF status - IFTTT changes

About 6 years ago I purchased from ControlEverything.com a Particle Photon with special firmware to allow reporting the ON/OFF status of seven inputs via WiFi. While I am not a programmer, I managed to connect the device to Particle and IFTTT and Gmail so that I could receive email whenever the status of any of the seven inputs changed, or the device went OFFLINE/ONLINE, and to control the relay on the device with RELAY ON/OFF with commands from Gmail (which later stopped working when Gmail revised their interface). With Particle changing the IFTTT interface, I am at a loss to make any sense of the documentation provided by Particle. It seems like it should be an easy transition, but everything I have tried with Particle integrations and IFTTT Webhooks has failed because of the vagueness of the documentation (maybe not vague to experienced programmers, but I didn’t write the Photon firmware, and don’t have a readable copy of the code. In the IFTTT system being discontinued I just wrote something like IF (device) published (Input_n) with event contents (ON/OFF) then… or IF (device) status is (Online/Offline) then… and everything worked well for years.

I have the IFTTT API key.

In the Particle Integrations Webhook builder its not clear how the “Event Name” corresponds to the published event (NAME: Input_4 and DATA:OFF) or the status event (NAME: spark/status and DATA: online).

In IFTTT I followed the Particle video for changing my IFTTT applets to Webhooks (seemed simple enough, but IFTTT said “Your Applet can’t be created because it hasn’t been set up properly.”) after I changed the IF part of one of my applets to use Webhooks following the video instructions.

When I purchased the hardware years ago, it came with instructions to connect it to Particle and IFTTT that any moron, like me, could follow. Particle’s transition instructions seem to require a higher education. If anyone can translate IFTTT IF {Event Name} INPUT_7 is {Event contents} OFF to a webhooks version, and/or a Particle event NAME and DATA to a Webhooks Integration, I would probably be able to do all the changes necessary to make the transition to IFTTT Webhooks.

Share the code you did write, it’ll help us to help you more.

Thanks for your reply.

I have two attachments “ParticleSide” showing my attempt at integration, and “IFTTTside” showing my old IFTTT applet and my attempts to modify it for Webhooks. It would seem that the documentation and video assume a level of knowledge I don’t have, because this should be a simple transition (according to Particle). Note that I have no ability to modify the firmware of the Photon, since I have no source code, nor programming equipment nor experience programming firmware.

John Richards

Johnrobert84@yahoo.com

Your event name is incorrect, they need to match. “OFF” is the data you’re sending, its not part of the event name.

2 Likes

I made the change you suggested, and noticed that my Particle web page didn’t fit the window, and also didn’t have scroll bars on side or bottom to indicate a lack of fit. Enlarging the web page window provided interesting information. If the JSON information shown in the larger window is sent to IFTTT with the Webhook, then I need to know how to extract that “OFF” and “time” information on the IFTTT side.

An update to the browser restored scroll bars.

I think on the particle side I have made the particle Webhook/integrations for "Input_"1 to 7 and “spark/status”. Now my only issue is getting IFTTT to respond appropriately.I have attached a sample of the Particle Webhook code. [For spark/status integration I changed the https line so that the trigger had no “/” (spark_status, not spark/status)].

John Richards

Johnrobert84@yahoo.com

Check the docs for proper syntax, the guess work here is going to be your event name and payload. You’ll have to trigger some events and watch your console for these, but it should be doable. I will say that your data payload will not be “spark_status” as that is a particle sent event based on the internal status of the device.

I have had considerable success thanks to your help. I have attached two images - the IFTTT action to generate an email, and the email received from it. The email received has everything I need to understand what has happened on the Particle side.

However, copies of the email will be sent to people less than familiar with the underlying system. To make the email more helpful for them I would like to move the item underlined in red (“online”) from the JsonPayload to the email subject where it now shows “ON/OFF”. I know that IFTTT probably has some way to reference the JSON data fields. Ultimately I would like the subject to just say “John’s house is online.”

Can you show me a sample of (or point me to a document about) how to reference the word “online” from the “data”:“online” field in the “Extra Data:” section of the Json.

John Richards

Johnrobert84@yahoo.com

Do you have a screenshot of an email you received previously?

Before Webhooks Particle/IFTTT was receptive to both NAME and DATA (under Webhooks called EVENT and DATA), so I used entirely different code for IFTTT (see attachment) and received more succinct emails (same attachment).

John Richards

Johnrobert84@yahoo.com

What you’re getting is JSON data, a lot of which is unneeded fo your purpose. You’ll need to narrow down the information you need and limit the data sent in the email to only that. There are topics on this in the documentation and in the community.

Thanks for your help. Although the documentation sucks, I did manage to cobble together code to do what was needed.

This may be off topic, so ignore it if you don’t know the answer. In the original Particle/IFTTT system, when a Particle device like mine went offline, IFTTT would be notified (so that IF device IS Offline THEN… would work). I don’t know how Particle notified IFTTT, because Particle does not have a named event for offline. It notices that the device is unreachable and signals IFTTT without creating a Particle event that Webhooks can capture. If there is a secret way Webhooks can capture this non-event, that would be useful information.

John Richards

Johnrobert84@yahoo.com

What you’re looking for is:

if !Particle.connected(){
//    do something here;
}

The “!” before the statement gives you the opposite check of what is listed, in this case it’s saying "if Particle ISN’T connected, then do something.
Unfortunately, if your device is not cloud connected, you can’t publish anything, but you should be able to have some sort of server sent trigger to send you an email.

Unfortunately, I have no access to programming the particle device. I did not create the firmware, and have no desire or ability to change it. It was purchased as a stand alone turnkey device with instructions provided for particle/IFTTT use. Since Particle is changing how it connects to IFTTT, I have limited options and am forced to rely on extremely poor documentation written for advanced programmers. Particle and IFFTT were not created for people with my skill set, and before a few days ago I had never read or written a line of JavaScript code.

Particle (the company) does recognize the loss of connectivity to the Particle device when power or WiFi fails on the device, and did provide some sort of non-standard notification to IFTTT (old school), but not anything by the Webhooks mechanism (that I could find). The Particle console Event list does not have an event for loss of connection. I've looked at the event list when a connection is lost, and no event is shown, but IFTTT manages to send an email about loss of connection. Somehow Particle manages to notify old school IFTTT. Since Events are what triggers Webhooks, I don't have a lot of hope.

When Particle (the device) regains power it publishes something (old school and Webhooks) which reports that power was previously lost at an unknown time and is now restored as of the current time (helpful, but not greatly, because the device also separately reports connection restored at the same time ).

If you're interested, This is one sample of a filter I wrote to go between the Webhooks event and SendEmail action. I'm sure it could be written better, but I don't have time to learn more about joys of the JavaScript language. The code below requires only minor modifications for the other Webhooks. All of them are of the event/SendEmail structure.

let payload = JSON.parse(MakerWebhooks.jsonEvent.JsonPayload)
let ops = payload.data
let opsa = ' HOME'
if (ops === 'ON') {opsa = ' AWAY'}
let ev = payload.event
let al = MakerWebhooks.jsonEvent.JsonPayload
let pa = payload.published_at
let su = 'Johns house: '+ops+opsa+' .'
let sb = 'Johns house: '+ops+opsa+'.
What: '+ev+' The event named '+ev+' occurred on the Maker Webhooks service
When: '+pa+'
Extra Data: '+MakerWebhooks.jsonEvent.JsonPayload
Gmail.sendAnEmail.setSubject(su)
Gmail.sendAnEmail.setBody(sb)

John Richards

Johnrobert84@yahoo.com

| Mjones Level 1 | Cadet
July 5 |

  • | - |

What you’re looking for is:

if !Particle.connected(){
//    do something here;
}

The “!” before the statement gives you the opposite check of what is listed, in this case it’s saying "if Particle ISN’T connected, then do something.
Unfortunately, if your device is not cloud connected, you can’t publish anything, but you should be able to have some sort of server sent trigger to send you an email.