Skip to content

Rules Engine Documentation

Jeremy Manoto edited this page Sep 3, 2013 · 15 revisions

#Preconditions

ninjaChange

{ handler: 'ninjaChange', params: { guid: "STEALTHYNINJA_1_0_11", to:"101010100001100" } }

  • guid String The guid of the device you are comparing
  • to String The value which will cause the precondition to return true

ninjaEquality

{"handler":"ninjaEquality","params":{"guid":"STEALTHYNINJA_2_0_9","equality":"GT","value":30}}

  • guid String The guid of the device you are comparing
  • equality String Values: GT/LT/GTE/LTE/EQ
  • value Number The value to compare against which will cause the precondition to return true
  • Note This handler is a basic comparison handler, and will continue to fire if the conditions hold

ninjaThreshold

{"handler":"ninjaThreshold","params":{"guid":"STEALTHYNINJA_2_0_9","equality":"GT","value":30}}

  • guid String The guid of the device you are comparing
  • equality String Values: GT/LT
  • value Number The value to compare against which will cause the precondition to return true
  • Note This handler will only fire once when the value crosses a threshold, and then wait until it returns back over the line before resetting itself.

ninjaRangeToggle

{"handler":"ninjaRangeToggle","params":{"guid":"STEALTHYNINJA_2_0_9","between":26,"and":30}}

  • guid String The guid of the device you are comparing
  • between Number The lower bounded range comparison datapoint
  • and Number The upper bounded range comparison datapoint

ninjaWebhookTickle

{"handler":"ninjaWebhookTickle","params":{"guid":"WEBHOOK_240146aa78d6211c47a7f51521e791ef06153f4c_0_107","subDeviceId":"RYf7U"}}

  • guid String the guid of the webhook device
  • subDeviceId String The subdevice id what we want to catch being tickled

Actions

ninjaSendCommand

{ handler: 'ninjaSendCommand', params: { "guid":"STEALTHYNINJA_2_0_1001", "da":"110110101100101010010001" } }

  • guid String The device guid you want to send a command to
  • da String The data to send

ninjaToggleCommand

{ handler: 'ninjaToggleCommand', params: { "guid":"STEALTHYNINJA_2_0_1001", "between":"110110101100101010010001", "and":"110110101100101011010001" } }

  • guid String The device guid you want to send a command to
  • between String The first value to toggle between
  • and String The second value to toggle between

sleep

{ handler: 'sleep', params: { guid:"N/A", sleepLength:5000 } }

  • guid String Use "N/A"
  • sleepLength Number Milliseconds to sleep for. Must be between 0 and 3600000

sendSms

{"handler":"sendSms","params":{"to":"+15555555","body":"NJA BLKS FTW","guid":"TWILIO_GUID"}}

  • guid String The twilio device
  • to String The phone number to SMS, must start with +
  • body String The contents of the SMS

sendEmail

{"handler":"sendEmail","params":{"to":"EMAIL@EXAMPLE.COM","subject":"NINJA","body":"Hello World!","guid":"EMAIL_GUID"}}

  • guid String The email device
  • to String The email address to send to
  • body String The body of the email
  • subject String The subject of the email

sendTweet

{"handler":"sendTweet","params":{"status":"Something happened on my #ninjablock","guid":"TWITTER_GUID"}}

  • guid String The twitter device
  • status String The text of the tweet you want to send

getNinjaSnapshot

{"handler":"getNinjaSnapshot","params":{"guid":"STEALTHYNINJA_0_0_1003"}}

  • guid String The guid of the camera

sendToDropbox

{"handler":"sendToDropbox","params":{"guid":"YOUR_DROPBOX_GUID"}}

  • guid String The dropbox device Note: Must be after getNinjaSnapshot

sendToGoogleDrive

{"handler":"sendToGoogleDrive","params":{"guid":YOUR_GOOGLE_GUID"}}

  • guid String The google device Note: Must be after getNinjaSnapshot

postToFacebook

{"handler":"postToFacebook","params":{"message":"Something happened on my #ninjablock","guid":"FACEBOOK_GUID"}}

  • guid String The facebook device
  • message String The text of the post to put on the user's wall

actuateWebhook

{"handler":"actuateWebhook","params":{"guid":"WEBHOOK_GUID","url":"http://example.com","data":"DATATOSEND"}}

  • guid String The webhook device
  • url String The url to POST to
  • data String (optional) The data to post