configured twilio voice, fixed bug with added slash on numbers
This commit is contained in:
@@ -52,21 +52,21 @@
|
|||||||
<td>2.
|
<td>2.
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input required name="sms2" type="tel" id="sms2" placeholder="+3876xxxxxxxx" value={{ config 'sms2'}}/>
|
<input required name="sms2" type="tel" id="sms2" placeholder="+3876xxxxxxxx" value={{ config 'sms2'}} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>3.
|
<td>3.
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input required name="sms3" type="tel" id="sms3" placeholder="+3876xxxxxxxx" value={{ config 'sms3'}}/>
|
<input required name="sms3" type="tel" id="sms3" placeholder="+3876xxxxxxxx" value={{ config 'sms3'}} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>4.
|
<td>4.
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input required name="sms4" type="tel" id="sms4" placeholder="+3876xxxxxxxx" value={{ config 'sms4'}}/>
|
<input required name="sms4" type="tel" id="sms4" placeholder="+3876xxxxxxxx" value={{ config 'sms4'}} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
4
app/public/sayings/alarm.twiml.xml
Normal file
4
app/public/sayings/alarm.twiml.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Response>
|
||||||
|
<Say voice="woman" language="english">Zoblak Farm ALARM! ALARM! ALARM!</Say>
|
||||||
|
</Response>
|
||||||
@@ -218,7 +218,7 @@ reactToAlarmData = function(controller_id) {
|
|||||||
var boxSilent = config.timeoutBox && minutesSinceLastBoxContact > config.timeoutBox;
|
var boxSilent = config.timeoutBox && minutesSinceLastBoxContact > config.timeoutBox;
|
||||||
|
|
||||||
var minutesSinceLastPhoneContact = state.lastPhoneContact ? moment(new Date()).diff(moment(state.lastPhoneContact), 'minutes') : -1;
|
var minutesSinceLastPhoneContact = state.lastPhoneContact ? moment(new Date()).diff(moment(state.lastPhoneContact), 'minutes') : -1;
|
||||||
var phoneSilent = false;//config.timeoutPhone && minutesSinceLastPhoneContact > config.timeoutPhone;
|
var phoneSilent = false; //config.timeoutPhone && minutesSinceLastPhoneContact > config.timeoutPhone;
|
||||||
|
|
||||||
console.log("too ", tooCold, tooHot, boxSilent, phoneSilent);
|
console.log("too ", tooCold, tooHot, boxSilent, phoneSilent);
|
||||||
console.log("lpc", state.lastPhoneContact);
|
console.log("lpc", state.lastPhoneContact);
|
||||||
@@ -254,7 +254,9 @@ function soundTheAlarm(controller_id, tooCold, tooHot, boxSilent, phoneSilent) {
|
|||||||
var smsSent = !!state.state.alarmSmsSent;
|
var smsSent = !!state.state.alarmSmsSent;
|
||||||
var needsToSendSms = !smsSent // && phoneSilent;
|
var needsToSendSms = !smsSent // && phoneSilent;
|
||||||
|
|
||||||
var sendSmsPart = needsToSendSms ? { 'state.alarmSmsSent': true } : {};
|
var sendSmsPart = needsToSendSms ? {
|
||||||
|
'state.alarmSmsSent': true
|
||||||
|
} : {};
|
||||||
|
|
||||||
ControllerState.update(state._id, {
|
ControllerState.update(state._id, {
|
||||||
'$set': Object.assign({
|
'$set': Object.assign({
|
||||||
@@ -265,17 +267,18 @@ function soundTheAlarm(controller_id, tooCold, tooHot, boxSilent, phoneSilent) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (needsToSendSms) {
|
if (needsToSendSms) {
|
||||||
sendAlarmingSms(controller_id,reason, state.config.smsNumbers)
|
sendAlarmingSms(controller_id, reason, state.config.smsNumbers);
|
||||||
|
callTheUser(controller_id, reason, state.config.smsNumbers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendAlarmingSms(controller_id,reason, numbers) {
|
function sendAlarmingSms(controller_id, reason, numbers) {
|
||||||
for (var i in numbers) {
|
for (var i in numbers) {
|
||||||
var number = numbers[i];
|
var number = numbers[i];
|
||||||
twilio = Twilio('AC10d7ed0bf54c1be4b1cd7133130e63f4', 'e133d3f02a69b79e93ad9ca1d73517d1');
|
twilio = Twilio('AC10d7ed0bf54c1be4b1cd7133130e63f4', 'e133d3f02a69b79e93ad9ca1d73517d1');
|
||||||
twilio.sendSms({
|
twilio.sendSms({
|
||||||
to: number, // Any number Twilio can deliver to
|
to: number, // Any number Twilio can deliver to
|
||||||
from: '+447481345235', // A number you bought from Twilio and can use for outbound communication
|
from: '+19282124174', // A number you bought from Twilio and can use for outbound communication
|
||||||
body: 'Zoblak alarm! Pokrenite aplikaciju! HITNO! http://agrar.zoblak.com/alarm?controller_id=' + controller_id // body of the SMS message
|
body: 'Zoblak alarm! Pokrenite aplikaciju! HITNO! http://agrar.zoblak.com/alarm?controller_id=' + controller_id // body of the SMS message
|
||||||
}, function(err, responseData) { //this function is executed when a response is received from Twilio
|
}, 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
|
if (!err) { // "err" is an error received during the request, if any
|
||||||
@@ -289,6 +292,21 @@ function sendAlarmingSms(controller_id,reason, numbers) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function callTheUser(controller_id, reason, numbers) {
|
||||||
|
for (var i in numbers) {
|
||||||
|
var number = numbers[i];
|
||||||
|
twilio = Twilio('AC10d7ed0bf54c1be4b1cd7133130e63f4', 'e133d3f02a69b79e93ad9ca1d73517d1');
|
||||||
|
twilio.makeCall({
|
||||||
|
to: number, // Any number Twilio can call
|
||||||
|
from: '+441143031932', // A number you bought from Twilio and can use for outbound communication
|
||||||
|
url: 'https://handler.twilio.com/twiml/EH9491c24474db07ec52b598baa5724f1e' // A URL that produces an XML document (TwiML) which contains instructions for the call
|
||||||
|
}, function(err, responseData) {
|
||||||
|
//executed when the call has been initiated.
|
||||||
|
console.log(err); // outputs "+14506667788"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function stopTheAlarm(controller_id, everythingIsBackToNormal = false) {
|
function stopTheAlarm(controller_id, everythingIsBackToNormal = false) {
|
||||||
// time of alarm stopped is reset so that scheduled job can raise the alarm
|
// time of alarm stopped is reset so that scheduled job can raise the alarm
|
||||||
// again
|
// again
|
||||||
|
|||||||
Reference in New Issue
Block a user