Skip to content

Commit

Permalink
rename atoc json variable to noto -- which stands for notification op…
Browse files Browse the repository at this point in the history
…tions; update user manual and API document
  • Loading branch information
rayshobby committed Jan 2, 2018
1 parent 6a0af1e commit 7d86e6c
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 49 deletions.
Binary file modified Compiled/og_1.0.7.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion OpenGarage/OpenGarage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ OptionStruct OpenGarage::options[] = {
{"ato", OG_AUTO_NONE,255, ""},
{"atib", 3, 24, ""},
{"atob", OG_AUTO_NONE,255, ""},
{"atoc", OG_AUTO_NONE,255, ""},
{"noto", OG_NOTIFY_DO|OG_NOTIFY_DC,255, ""},
{"usi", 0, 1, ""},
{"ssid", 0, 0, ""}, // string options have 0 max value
{"pass", 0, 0, ""},
Expand Down
7 changes: 3 additions & 4 deletions OpenGarage/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
#define OG_NOTIFY_NONE 0x00
#define OG_NOTIFY_DO 0x01
#define OG_NOTIFY_DC 0x02
#define OG_NOTIFY_VL 0x03
#define OG_NOTIFY_VA 0x04
#define OG_NOTIFY_VL 0x04
#define OG_NOTIFY_VA 0x08

#define OG_STATE_INITIAL 0
#define OG_STATE_CONNECTING 1
Expand All @@ -79,7 +79,6 @@
#define BLYNK_PIN_RELAY V1
#define BLYNK_PIN_LCD V2
#define BLYNK_PIN_DIST V3
#define BLYNK_PIN_RCNT V4
#define BLYNK_PIN_IP V5

#define MAX_LOG_RECORDS 100
Expand Down Expand Up @@ -107,7 +106,7 @@ typedef enum {
OPTION_ATO, // automation options
OPTION_ATIB, // automation interval B (in hours)
OPTION_ATOB, // automation options B
OPTION_ATOC, // automation options C
OPTION_NOTO, // notification options
OPTION_USI, // use static IP
OPTION_SSID, // wifi ssid
OPTION_PASS, // wifi password
Expand Down
2 changes: 1 addition & 1 deletion OpenGarage/html/sta_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}
//Use correct graphics
if (jd.vehicle>=3){ //3 is disabled
//$('#pic').attr('src', (jd.door?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorOpen.png':'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorShut.png'));
$('#pic').attr('src', (jd.door?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorOpen.png':'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorShut.png'));
}else{
$('#pic').attr('src', jd.door?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/Open.png':(jd.vehicle?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/ClosedPresent.png':'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/ClosedAbsent.png'));
}
Expand Down
15 changes: 8 additions & 7 deletions OpenGarage/html/sta_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
</table>

<table>
<tr><td colspan=4><b>Choose Notifications:</b></td></tr>
<tr><td><input type='checkbox' id='noto0' data-mini='true'><label for='noto0'>Door<br> Open</label></td><td><input type='checkbox' id='noto1' data-mini='true' ><label for='noto1'>Door<br> Close</label></td>
<td><input type='checkbox' id='noto2' data-mini='true' disabled><label for='noto2'>Vehicle<br> Leave</label></td><td><input type='checkbox' id='noto3' data-mini='true' disabled ><label for='noto3'>Vehicle<br> Arrive</label></td></tr>

<tr><td colspan=4><b>Automation:</b></td></tr>
<tr><td colspan=4></td></tr><tr><td colspan=4></td></tr>
<tr><td colspan=4>If open for longer than:</td></tr>
Expand All @@ -47,9 +51,6 @@
<tr><td colspan=4>If open after time:<small> (Use UTC 24hr format)</small>:</td></tr>
<tr><td><input type='text' size=3 maxlength=3 id='atib' value=3 data-mini='true'></td><td> UTC:</td><td><input type='checkbox' id='atob0' data-mini='true'><label for='atob0'>Notify me</label></td><td><input type='checkbox' id='atob1' data-mini='true'><label for='atob1'>Auto-close</label></td></tr>
</table><table>
<tr><td colspan=4>Change Notifications:</td></tr>
<tr><td><input type='checkbox' id='atoc0' data-mini='true'><label for='atoc0'>Door<br> Open</label></td><td><input type='checkbox' id='atoc1' data-mini='true' ><label for='atoc1'>Door<br> Close</label></td>
<td><input type='checkbox' id='atoc2' data-mini='true' disabled><label for='atoc2'>Vehicle<br> Leave</label></td><td><input type='checkbox' id='atoc3' data-mini='true' disabled ><label for='atoc3'>Vehicle<br> Arrive</label></td></tr>
</table>
</div>
<div id='div_other' style='display:none;'>
Expand Down Expand Up @@ -131,9 +132,9 @@
var atob=0;
for(var i=1;i>=0;i--) { atob=(atob<<1)+eval_cb('#atob'+i); }
comm+='&atob='+atob;
var atoc=0;
for(var i=1;i>=0;i--) { atoc=(atoc<<1)+eval_cb('#atoc'+i); }
comm+='&atoc='+atoc;
var noto=0;
for(var i=1;i>=0;i--) { noto=(noto<<1)+eval_cb('#noto'+i); }
comm+='&noto='+noto;
comm+='&name='+encodeURIComponent($('#name').val());
comm+='&auth='+encodeURIComponent($('#auth').val());
comm+='&iftt='+encodeURIComponent($('#iftt').val());
Expand Down Expand Up @@ -177,7 +178,7 @@
$('#atib').val(jd.atib);
for(var i=0;i<=1;i++) {if(jd.ato&(1<<i)) $('#ato'+i).attr('checked',true).checkboxradio('refresh');}
for(var i=0;i<=1;i++) {if(jd.atob&(1<<i)) $('#atob'+i).attr('checked',true).checkboxradio('refresh');}
for(var i=0;i<=1;i++) {if(jd.atoc&(1<<i)) $('#atoc'+i).attr('checked',true).checkboxradio('refresh');}
for(var i=0;i<=1;i++) {if(jd.noto&(1<<i)) $('#noto'+i).attr('checked',true).checkboxradio('refresh');}
$('#name').val(jd.name);
$('#auth').val(jd.auth);
$('#iftt').val(jd.iftt);
Expand Down
16 changes: 8 additions & 8 deletions OpenGarage/htmls.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ if (jd.vehicle >=2){
}
//Use correct graphics
if (jd.vehicle>=3){ //3 is disabled
//$('#pic').attr('src', (jd.door?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorOpen.png':'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorShut.png'));
$('#pic').attr('src', (jd.door?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorOpen.png':'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/DoorShut.png'));
}else{
$('#pic').attr('src', jd.door?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/Open.png':(jd.vehicle?'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/ClosedPresent.png':'https://github.com/OpenGarage/OpenGarage-Firmware/raw/master/icons/ClosedAbsent.png'));
}
Expand Down Expand Up @@ -340,16 +340,16 @@ const char sta_options_html[] PROGMEM = R"(<head><title>OpenGarage</title><meta
<tr><td><b>MQTT Server:<a href='#mqttInfo' data-rel='popup' data-role='button' data-inline='true' data-transition='pop' data-icon='info' data-theme='c' data-iconpos='notext'>Learn more</a><div data-role='popup' id='mqttInfo' class='ui-content' data-theme='b' style='max-width:320px;'><p>MQTT provides additional workflow options through tools like NodeRed (e.g. SMS, email).</p></div></b></td><td><input type='text' size=16 maxlength=20 id='mqtt' data-mini='true' value=''></td></tr>
</table>
<table>
<tr><td colspan=4><b>Choose Notifications:</b></td></tr>
<tr><td><input type='checkbox' id='noto0' data-mini='true'><label for='noto0'>Door<br> Open</label></td><td><input type='checkbox' id='noto1' data-mini='true' ><label for='noto1'>Door<br> Close</label></td>
<td><input type='checkbox' id='noto2' data-mini='true' disabled><label for='noto2'>Vehicle<br> Leave</label></td><td><input type='checkbox' id='noto3' data-mini='true' disabled ><label for='noto3'>Vehicle<br> Arrive</label></td></tr>
<tr><td colspan=4><b>Automation:</b></td></tr>
<tr><td colspan=4></td></tr><tr><td colspan=4></td></tr>
<tr><td colspan=4>If open for longer than:</td></tr>
<tr><td><input type='text' size=3 maxlength=3 id='ati' value=30 data-mini='true'></td><td>minutes:</td><td><input type='checkbox' id='ato0' data-mini='true'><label for='ato0'>Notify me</label></td><td><input type='checkbox' id='ato1' data-mini='true'><label for='ato1'>Auto-close</label></td></tr>
<tr><td colspan=4>If open after time:<small> (Use UTC 24hr format)</small>:</td></tr>
<tr><td><input type='text' size=3 maxlength=3 id='atib' value=3 data-mini='true'></td><td> UTC:</td><td><input type='checkbox' id='atob0' data-mini='true'><label for='atob0'>Notify me</label></td><td><input type='checkbox' id='atob1' data-mini='true'><label for='atob1'>Auto-close</label></td></tr>
</table><table>
<tr><td colspan=4>Change Notifications:</td></tr>
<tr><td><input type='checkbox' id='atoc0' data-mini='true'><label for='atoc0'>Door<br> Open</label></td><td><input type='checkbox' id='atoc1' data-mini='true' ><label for='atoc1'>Door<br> Close</label></td>
<td><input type='checkbox' id='atoc2' data-mini='true' disabled><label for='atoc2'>Vehicle<br> Leave</label></td><td><input type='checkbox' id='atoc3' data-mini='true' disabled ><label for='atoc3'>Vehicle<br> Arrive</label></td></tr>
</table>
</div>
<div id='div_other' style='display:none;'>
Expand Down Expand Up @@ -430,9 +430,9 @@ comm+='&ato='+ato;
var atob=0;
for(var i=1;i>=0;i--) { atob=(atob<<1)+eval_cb('#atob'+i); }
comm+='&atob='+atob;
var atoc=0;
for(var i=1;i>=0;i--) { atoc=(atoc<<1)+eval_cb('#atoc'+i); }
comm+='&atoc='+atoc;
var noto=0;
for(var i=1;i>=0;i--) { noto=(noto<<1)+eval_cb('#noto'+i); }
comm+='&noto='+noto;
comm+='&name='+encodeURIComponent($('#name').val());
comm+='&auth='+encodeURIComponent($('#auth').val());
comm+='&iftt='+encodeURIComponent($('#iftt').val());
Expand Down Expand Up @@ -476,7 +476,7 @@ if(jd.mnt>0) $('#vth').textinput('disable');
$('#atib').val(jd.atib);
for(var i=0;i<=1;i++) {if(jd.ato&(1<<i)) $('#ato'+i).attr('checked',true).checkboxradio('refresh');}
for(var i=0;i<=1;i++) {if(jd.atob&(1<<i)) $('#atob'+i).attr('checked',true).checkboxradio('refresh');}
for(var i=0;i<=1;i++) {if(jd.atoc&(1<<i)) $('#atoc'+i).attr('checked',true).checkboxradio('refresh');}
for(var i=0;i<=1;i++) {if(jd.noto&(1<<i)) $('#noto'+i).attr('checked',true).checkboxradio('refresh');}
$('#name').val(jd.name);
$('#auth').val(jd.auth);
$('#iftt').val(jd.iftt);
Expand Down
53 changes: 25 additions & 28 deletions OpenGarage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,18 +844,18 @@ void perform_notify(String s) {
}
}

void perform_automation(byte event) {
void process_dynamics(byte event) {
static bool automationclose_triggered=false;
byte ato = og.options[OPTION_ATO].ival;
byte atob = og.options[OPTION_ATOB].ival;
byte atoc = og.options[OPTION_ATOC].ival;
if(!ato && !atob && !atoc) {
byte noto = og.options[OPTION_NOTO].ival;
if(!ato && !atob && !noto) {
justopen_timestamp = 0;
return;
}
if(event == DOOR_STATUS_JUST_OPENED) {
justopen_timestamp = curr_utc_time; // record time stamp
if (atoc & OG_NOTIFY_DO)
if (noto & OG_NOTIFY_DO)
{ perform_notify(og.options[OPTION_NAME].sval + " just OPENED!");}

//If the door is set to auto close at a certain hour, ensure if manually opened it doesn't autoshut
Expand All @@ -866,7 +866,7 @@ void perform_automation(byte event) {

} else if (event == DOOR_STATUS_JUST_CLOSED) {
justopen_timestamp = 0; // reset time stamp
if (atoc & OG_NOTIFY_DC)
if (noto & OG_NOTIFY_DC)
{ perform_notify(og.options[OPTION_NAME].sval + " just CLOSED!");}

} else if (event == DOOR_STATUS_REMAIN_OPEN) {
Expand Down Expand Up @@ -997,31 +997,30 @@ void check_status() {

//Upon change
if(event == DOOR_STATUS_JUST_OPENED || event == DOOR_STATUS_JUST_CLOSED) {
// write log record
DEBUG_PRINTLN(" Update Local Log");
LogStruct l;
l.tstamp = curr_utc_time;
l.status = door_status;
l.dist = distance;
og.write_log(l);

#if 0
//Debug Beep (only if sound is enabled)
if(og.options[OPTION_ALM].ival){
/*og.play_note(1000);
og.play_note(1000);
delay(500);
og.play_note(0);*/
og.play_note(0);
}
DEBUG_PRINT(curr_utc_time);
if(event == DOOR_STATUS_JUST_OPENED) {
DEBUG_PRINTLN(F(" Sending State Change event to connected systems, value: DOOR_STATUS_JUST_OPENED")); }
else if(event == DOOR_STATUS_JUST_CLOSED) {
DEBUG_PRINTLN(F(" Sending State Change event to connected systems, value: DOOR_STATUS_JUST_CLOSED")); }
else {
DEBUG_PRINTLN(F(" Sending State Change event to connected systems, value: OTHER"));
DEBUG_PRINTLN(String(event,DEC));
}

// write log record
DEBUG_PRINTLN(" Update Local Log");
LogStruct l;
l.tstamp = curr_utc_time;
l.status = door_status;
l.dist = distance;
og.write_log(l);
#endif

// Blynk notification
#if 0
byte ato = og.options[OPTION_ATO].ival;
if(curr_cloud_access_en && Blynk.connected() && ato) {
//The official firmware only sends these notifications on ato enabled (which seems a somewhat unrelated function)
Expand Down Expand Up @@ -1056,23 +1055,21 @@ void check_status() {
mqttclient.publish(og.options[OPTION_NAME].sval + "/OUT/CHANGE",String(event,DEC));
}
}

#endif
} //End state change updates

//Send current status only on change and longer interval
if ((curr_utc_time >checkstatus_report_timeout) || (event == DOOR_STATUS_JUST_OPENED || event == DOOR_STATUS_JUST_CLOSED) ){
#if 0
DEBUG_PRINT(curr_utc_time);
uint32_t ram = ESP.getFreeHeap();
//DEBUG_PRINTLN(" RAM: "+ram);
if(event == DOOR_STATUS_REMAIN_OPEN) {
DEBUG_PRINTLN(F(" Sending State Refresh to connected systems, value: OPEN")); }
else if(event == DOOR_STATUS_REMAIN_CLOSED) {
DEBUG_PRINTLN(F(" Sending State Refresh to connected systems, value: CLOSED")); }

#endif
// report status to Blynk
if(curr_cloud_access_en && Blynk.connected()) {
DEBUG_PRINTLN(F(" Update Blynk (State Refresh)"));
Blynk.virtualWrite(BLYNK_PIN_RCNT, read_cnt);
Blynk.virtualWrite(BLYNK_PIN_DIST, distance);
(door_status) ? blynk_led.on() : blynk_led.off();
Blynk.virtualWrite(BLYNK_PIN_IP, get_ip());
Expand All @@ -1099,12 +1096,12 @@ void check_status() {
//DEBUG_PRINTLN(curr_utc_time + " Sending MQTT State Notification: CLOSED");
}
}
//Set to run every 5 seconds
checkstatus_report_timeout= curr_utc_time + 5;
// Send status report every 15 seconds: we don't need to send updates frequently if there is no status change.
checkstatus_report_timeout= curr_utc_time + 15;
}

//Process any built in automations
perform_automation(event);
// Process dynamics: automation and notifications
process_dynamics(event);
checkstatus_timeout = curr_utc_time + og.options[OPTION_RIV].ival;

}
Expand Down
Binary file modified docs/OGAPI1.0.7.pdf
Binary file not shown.
Binary file modified docs/OGManual.pdf
Binary file not shown.

0 comments on commit 7d86e6c

Please sign in to comment.