'method': ui['web_hook_notifications_http_method'],
'url': url})
+ if ui['command_notifications_enabled']:
+ commands = ui['command_notifications_exec'].split(';')
+ on_event_start += [c.strip() for c in commands]
+
if ui['working_schedule']:
data['@working_schedule'] = (
ui['monday_from'] + '-' + ui['monday_to'] + '|' +
ui['movie_quality'] = min(100, int(round(ffmpeg_bps * 100.0 / max_val)))
+ command_notifications = []
for e in on_event_start:
if e.count('sendmail.py') and e.count('motion_start'):
e = e.replace('"', '').split(' ')
continue
ui['web_hook_notifications_enabled'] = True
- ui['web_hook_notifications_method'] = e[1]
+ ui['web_hook_notifications_http_method'] = e[1]
ui['web_hook_notifications_url'] = e[2]
+ else: # custom command
+ command_notifications.append(e)
+
+ if command_notifications:
+ ui['command_notifications_enabled'] = True
+ ui['command_notifications_exec'] = '; '.join(command_notifications)
+
working_schedule = data['@working_schedule']
if working_schedule:
days = working_schedule.split('|')
makeTextValidator($('#smtpAccountEntry'), true);
makeTextValidator($('#smtpPasswordEntry'), true);
makeTextValidator($('#webHookUrlEntry'), true);
+ makeTextValidator($('#commandNotificationsEntry'), true);
/* number validators */
makeNumberValidator($('#streamingPortEntry'), 1024, 65535, false, false, true);
$('#preserveMoviesSelect').change(updateConfigUi);
$('#emailNotificationsSwitch').change(updateConfigUi);
$('#webHookNotificationsSwitch').change(updateConfigUi);
+ $('#commandNotificationsSwitch').change(updateConfigUi);
$('#workingScheduleSwitch').change(updateConfigUi);
$('#storageDeviceSelect').change(function () {
$('#webHookHttpMethod').parents('tr:eq(0)').each(markHide);
}
+ if (!$('#commandNotificationsSwitch').get(0).checked) {
+ $('#commandNotificationsEntry').parents('tr:eq(0)').each(markHide);
+ }
+
/* working schedule switch */
if (!$('#workingScheduleSwitch').get(0).checked) {
$('#workingScheduleSwitch').parent().next('table.settings').find('tr.settings-item').each(markHide);
'web_hook_notifications_enabled': $('#webHookNotificationsSwitch')[0].checked,
'web_hook_notifications_url': $('#webHookUrlEntry').val(),
'web_hook_notifications_http_method': $('#webHookHttpMethod').val(),
+ 'command_notifications_enabled': $('#commandNotificationsSwitch')[0].checked,
+ 'command_notifications_exec': $('#commandNotificationsEntry').val(),
/* working schedule */
'working_schedule': $('#workingScheduleSwitch')[0].checked,
$('#webHookNotificationsSwitch')[0].checked = dict['web_hook_notifications_enabled'];
$('#webHookUrlEntry').val(dict['web_hook_notifications_url']);
$('#webHookHttpMethod').val(dict['web_hook_notifications_http_method']);
+ $('#commandNotificationsSwitch')[0].checked = dict['command_notifications_enabled'];
+ $('#commandNotificationsEntry').val(dict['command_notifications_exec']);
/* working schedule */
$('#workingScheduleSwitch')[0].checked = dict['working_schedule'];
</td>
<td><span class="help-mark" title="the HTTP method to use when requesting the web hook URL">?</span></td>
</tr>
+ <tr class="settings-item advanced-setting">
+ <td colspan="100"><div class="settings-item-separator"></div></td>
+ </tr>
+ <tr class="settings-item advanced-setting">
+ <td class="settings-item-label"><span class="settings-item-label">Run A Command</span></td>
+ <td class="settings-item-value"><input type="checkbox" class="styled notifications" id="commandNotificationsSwitch"></td>
+ <td><span class="help-mark" title="enable this if you want to execute a command whenever a motion event is detected">?</span></td>
+ </tr>
+ <tr class="settings-item advanced-setting">
+ <td class="settings-item-label"><span class="settings-item-label">Command</span></td>
+ <td class="settings-item-value"><input type="text" class="styled notifications" id="commandNotificationsEntry" placeholder="command..."></td>
+ <td><span class="help-mark" title="a command to be executed when motion is detected; multiple commands can be separated by a semicolon; the following special tokens are accepted: %Y = year, %m = month, %d = date, %H = hour, %M = minute, %S = second, %q = frame number">?</span></td>
+ </tr>
</table>
<div class="settings-section-title hidden"><input type="checkbox" class="styled section working-schedule" id="workingScheduleSwitch">Working Schedule</div>