diff --git a/README.md b/README.md index 97347f5..f91b5ee 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ GET: - [X] Network -> FTP - [X] Network -> Push - [X] Network -> WIFI -- [ ] Alarm -> Motion +- [X] Alarm -> Motion - [X] System -> General - [X] System -> DST - [X] System -> Information diff --git a/api/APIHandler.py b/api/APIHandler.py index 7fa04b7..a62846a 100644 --- a/api/APIHandler.py +++ b/api/APIHandler.py @@ -6,6 +6,7 @@ from .network import NetworkAPIMixin from .system import SystemAPIMixin from .user import UserAPIMixin from .ptz import PtzAPIMixin +from .alarm import AlarmAPIMixin from resthandle import Request @@ -16,7 +17,8 @@ class APIHandler(SystemAPIMixin, DisplayAPIMixin, RecordingAPIMixin, ZoomAPIMixin, - PtzAPIMixin): + PtzAPIMixin, + AlarmAPIMixin): """ The APIHandler class is the backend part of the API, the actual API calls are implemented in Mixins. diff --git a/api/__init__.py b/api/__init__.py index a7db0e9..06bd9be 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -1,4 +1,4 @@ from .APIHandler import APIHandler -__version__ = "0.0.1" +__version__ = "0.0.2" VERSION = __version__ diff --git a/api/alarm.py b/api/alarm.py new file mode 100644 index 0000000..2f48efb --- /dev/null +++ b/api/alarm.py @@ -0,0 +1,11 @@ +class AlarmAPIMixin: + """API calls for getting device alarm information.""" + + def get_alarm_motion(self) -> object: + """ + Gets the device alarm motion + See examples/response/GetAlarmMotion.json for example response data. + :return: response json + """ + body = [{"cmd": "GetAlarm", "action": 1, "param": {"Alarm": {"channel": 0, "type": "md"}}}] + return self._execute_command('GetAlarm', body) diff --git a/examples/response/GetAlarmMotion.json b/examples/response/GetAlarmMotion.json new file mode 100644 index 0000000..56be0cc --- /dev/null +++ b/examples/response/GetAlarmMotion.json @@ -0,0 +1,150 @@ +[ + { + "cmd": "GetAlarm", + "code": 0, + "initial": { + "Alarm": { + "action": { "mail": 1, "push": 1, "recChannel": [0] }, + "channel": 0, + "enable": 1, + "schedule": { + "table": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + }, + "scope": { + "cols": 80, + "rows": 45, + "table": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + }, + "sens": [ + { + "beginHour": 0, + "beginMin": 0, + "endHour": 6, + "endMin": 0, + "sensitivity": 10 + }, + { + "beginHour": 6, + "beginMin": 0, + "endHour": 12, + "endMin": 0, + "sensitivity": 10 + }, + { + "beginHour": 12, + "beginMin": 0, + "endHour": 18, + "endMin": 0, + "sensitivity": 10 + }, + { + "beginHour": 18, + "beginMin": 0, + "endHour": 23, + "endMin": 59, + "sensitivity": 10 + } + ], + "type": "md" + } + }, + "range": { + "Alarm": { + "action": { "mail": "boolean", "push": "boolean", "recChannel": [0] }, + "channel": 0, + "enable": "boolean", + "schedule": { "table": { "maxLen": 168, "minLen": 168 } }, + "scope": { + "cols": { "max": 80, "min": 80 }, + "rows": { "max": 45, "min": 45 }, + "table": { "maxLen": 8159 } + }, + "sens": [ + { + "beginHour": { "max": 23, "min": 0 }, + "beginMin": { "max": 59, "min": 0 }, + "endHour": { "max": 23, "min": 0 }, + "endMin": { "max": 59, "min": 0 }, + "id": 0, + "sensitivity": { "max": 50, "min": 1 } + }, + { + "beginHour": { "max": 23, "min": 0 }, + "beginMin": { "max": 59, "min": 0 }, + "endHour": { "max": 23, "min": 0 }, + "endMin": { "max": 59, "min": 0 }, + "id": 1, + "sensitivity": { "max": 50, "min": 1 } + }, + { + "beginHour": { "max": 23, "min": 0 }, + "beginMin": { "max": 59, "min": 0 }, + "endHour": { "max": 23, "min": 0 }, + "endMin": { "max": 59, "min": 0 }, + "id": 2, + "sensitivity": { "max": 50, "min": 1 } + }, + { + "beginHour": { "max": 23, "min": 0 }, + "beginMin": { "max": 59, "min": 0 }, + "endHour": { "max": 23, "min": 0 }, + "endMin": { "max": 59, "min": 0 }, + "id": 3, + "sensitivity": { "max": 50, "min": 1 } + } + ], + "type": "md" + } + }, + "value": { + "Alarm": { + "action": { "mail": 1, "push": 1, "recChannel": [0] }, + "channel": 0, + "enable": 1, + "schedule": { + "table": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + }, + "scope": { + "cols": 80, + "rows": 45, + "table": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + }, + "sens": [ + { + "beginHour": 0, + "beginMin": 0, + "endHour": 6, + "endMin": 0, + "id": 0, + "sensitivity": 10 + }, + { + "beginHour": 6, + "beginMin": 0, + "endHour": 12, + "endMin": 0, + "id": 1, + "sensitivity": 10 + }, + { + "beginHour": 12, + "beginMin": 0, + "endHour": 18, + "endMin": 0, + "id": 2, + "sensitivity": 10 + }, + { + "beginHour": 18, + "beginMin": 0, + "endHour": 23, + "endMin": 59, + "id": 3, + "sensitivity": 10 + } + ], + "type": "md" + } + } + } +] diff --git a/setup.py b/setup.py index 614ea1c..70c8068 100644 --- a/setup.py +++ b/setup.py @@ -65,6 +65,7 @@ setup(name=NAME, 'api.recording', 'api.system', 'api.user', - 'api.zoom' + 'api.zoom', + 'api.alarm' ] )