Skip to content

Commit 822d07c

Browse files
authored
Add FeederFunctions (#37)
add OPFeedBook SET (Add, Delete) & GET add OPFeedManual SET add OPFeedHistory GET (Delete)
1 parent c004606 commit 822d07c

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,67 @@ This script will persistently attempt to connect to camera at `CAMERA_IP`, will
627627
./monitor.py <CAMERA_IP> <CAMERA_NAME> <FILE_PATH>
628628
```
629629

630+
## OPFeederFunctions
631+
632+
These functions are to handle the pet food dispenser when available.
633+
You can see it with :
634+
635+
```python
636+
>>> cam.get_system_capabilities()['OtherFunction']['SupportFeederFunction']
637+
True
638+
```
639+
640+
<details>
641+
<summary>OPFeedManual</summary>
642+
643+
```python
644+
>>> cam.set_command("OPFeedManual", {"Servings": 1})
645+
{'Name': 'OPFeedManual', 'OPFeedManual': {'Feeded': 1, 'NotFeeding': 0}, 'Ret': 100, 'SessionID': '0x38'}
646+
```
647+
648+
Servings is the number of portions
649+
650+
</details>
651+
652+
<details>
653+
<summary>OPFeedBook</summary>
654+
655+
```python
656+
>>> cam.get_command("OPFeedBook")
657+
{'FeedBook': [{'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '03:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '09:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '06:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '15:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '12:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '21:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '18:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 1, 'Time': '00:00:00'}, {'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 5, 'Time': '01:00:00'}]}
658+
```
659+
660+
```python
661+
>>> cam.set_command("OPFeedBook", {"Action": "Delete", "FeedBook": [{'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 5, 'Time': '01:00:00'}]})
662+
{'Name': 'OPFeedBook', 'Ret': 100, 'SessionID': '0x00000018'}
663+
```
664+
665+
```python
666+
>>> cam.set_command("OPFeedBook", {"Action": "Add", "FeedBook": [{'Enable': 1, 'RecDate': '2018-04-01', 'RecTime': '12:19:18', 'Servings': 5, 'Time': '01:00:00'}]})
667+
{'Name': 'OPFeedBook', 'Ret': 100, 'SessionID': '0x00000018'}
668+
```
669+
670+
</details>
671+
672+
<details>
673+
<summary>OPFeedHistory</summary>
674+
675+
```python
676+
>>> cam.get_command("OPFeedHistory")
677+
{'FeedHistory': [{'Date': '2022-08-29', 'Servings': 1, 'Time': '18:49:45', 'Type': 2}, {'Date': '2022-08-26', 'Servings': 3, 'Time': '07:30:12', 'Type': 1}]}
678+
```
679+
680+
Type 1 : automatic
681+
682+
Type 2 : manual
683+
684+
```python
685+
>>> cam.set_command("OPFeedHistory", {"Action": "Delete", "FeedHistory": [{'Date': '2022-08-29', 'Servings': 1, 'Time': '19:40:01', 'Type': 2}]})
686+
{'Name': 'OPFeedHistory', 'Ret': 100, 'SessionID': '0x00000027'}
687+
```
688+
689+
</details>
690+
630691
## Troubleshooting
631692

632693
```python

dvrip.py

+21
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ class DVRIPCam(object):
6464
"SystemFunction": 1360,
6565
"SystemInfo": 1020,
6666
}
67+
OPFEED_QCODES = {
68+
"OPFeedBook": {
69+
"SET": 2300,
70+
"GET": 2302,
71+
},
72+
"OPFeedManual": {
73+
"SET": 2304,
74+
},
75+
"OPFeedHistory": {
76+
"GET": 2306,
77+
"SET": 2308,
78+
},
79+
}
6780
KEY_CODES = {
6881
"M": "Menu",
6982
"I": "Info",
@@ -533,6 +546,10 @@ def set_info(self, command, data):
533546
return self.set_command(command, data, 1040)
534547

535548
def set_command(self, command, data, code=None):
549+
if not code:
550+
code = self.OPFEED_QCODES.get(command)
551+
if code:
552+
code = code.get("SET")
536553
if not code:
537554
code = self.QCODES[command]
538555
return self.send(
@@ -543,6 +560,10 @@ def get_info(self, command):
543560
return self.get_command(command, 1042)
544561

545562
def get_command(self, command, code=None):
563+
if not code:
564+
code = self.OPFEED_QCODES.get(command)
565+
if code:
566+
code = code.get("GET")
546567
if not code:
547568
code = self.QCODES[command]
548569

0 commit comments

Comments
 (0)