Code

file_5911.txtJavaScript
    var client = require('twilio')('{{ sid token }}', '{{ auth token }}');

var pinoccio = require('pinoccio');

var api = pinoccio("{{ pinoccio api token }}");

var s = api.sync();

s.on('data', function(data) {
    data = data.data;
    if (data.type === 'digital' && data.troop === '1' && data.scout === '1') {
        if (data.value.state[0] == 0) {
            console.log("Someone rang the doorbell");
            command = "led.green delay(5000) led.off";
            // initialize the command that we will set below.
            client.sendMessage({

                to: '+{{ your phone number }}', 
                // Any number Twilio can deliver to
                from: '+{{ twilio phone number }}', 
                // A number you bought from Twilio and can use f
                // or outbound communication
                body: '\nword to your mother.\nsomeone rang the doorbell.'
                // body of the SMS message
            }, function(err, responseData) { 
              //this function is executed when a response is received 
              // from Twilio

                if (!err) { 
                  // "err" is an error received during the request, if any
                  // "responseData" is a JavaScript object containing 
                  // data received from Twilio.
                  // A sample response from sending an SMS message is 
                  // here (click "JSON" to see how the data appears in
                  // JavaScript):
              // http://www.twilio.com/docs/api/rest/sending-sms#example-1
                    console.log(responseData.from); 
                    // outputs your twilio number
                    console.log(responseData.body);
                    // outputs the body of the text from above
                }
            });
            api.rest({
                url: "/v1/1/1/command",
                data: {
                    command: command
                }
            }, function(err, data) {});
        }
    }
});

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

    DHT22 Sensor and Pinoccio
    • 1,613
    • 5

    Full instructions

    Using DHT22 Temperature and Humidity sensor with Pinoccio

    Mesh Your Brain
    • 3,464
    • 22

    Full instructions

    Build your own Internet of Brains with this wireless EEG hack!

    Human Presence Detection & Visualization
    • 1,064
    • 9

    Full instructions

    Team Cogitate's social radar displays people nearby as a set of glowing orbs

    Hideous Arc Reactor Sweater (WIP)
    • 813
    • 6

    Work in progress

    Power through the holiday slump with this festive, EEG-reactive sweater!

    Pinoccio Craft
    • 375
    • 5

    Full instructions

    Send Bitlash Pinoccio Commands through Minecraft.

    Solar Powered Pinoccio Scout
    • 1,079
    • 9

    Run your wireless mesh forever with Adafruit's solar LiPo charger

    Add projectSign up / Login