Skip to content

Commit f4c3708

Browse files
committed
Add PirInfo pushes
1 parent 1475486 commit f4c3708

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

reolink_aio/baichuan/baichuan.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,25 @@ def _parse_xml(self, cmd_id: int, xml: str, payload: bytes = b"", mess_id: int |
889889
if "ir_state" in data:
890890
self.http_api._ir_settings.setdefault(channel, {})["state"] = data["ir_state"].capitalize()
891891

892+
elif cmd_id == 212: # PirInfo
893+
if mess_id is None:
894+
return
895+
channel = mess_id % 256 - 1
896+
if channel < 0 or channel > 100:
897+
return
898+
channels.add(channel)
899+
data = get_keys_from_xml(
900+
root,
901+
{
902+
"enable": ("enable", int),
903+
"sensiValue": ("sensitive", int),
904+
"reduceFalseAlarm": ("reduceAlarm", int),
905+
"interval": ("interval", int),
906+
"intervalSecMax": ("interval_max", int),
907+
},
908+
)
909+
self.http_api._pir.setdefault(channel, {}).update(data)
910+
892911
elif cmd_id == 217: # Email
893912
channel = self._get_channel_from_xml_element(root)
894913
if channel is None:
@@ -1074,7 +1093,7 @@ def _parse_xml(self, cmd_id: int, xml: str, payload: bytes = b"", mess_id: int |
10741093
if cmd_id_modified == 342 and channel is not None:
10751094
self._loop.create_task(self.GetAllAiAlarm(channel))
10761095
return
1077-
if cmd_id_modified not in {26, 56, 70, 208, 217, 232, 264, 527, 529, 531, 549, 551}:
1096+
if cmd_id_modified not in {26, 56, 70, 208, 212, 217, 232, 264, 527, 529, 531, 549, 551}:
10781097
return
10791098
self._loop.create_task(self._send_and_parse(cmd_id_modified, channel))
10801099
return
@@ -3378,18 +3397,7 @@ async def SetNetPort(self, **kwargs) -> None:
33783397
@http_cmd("GetPirInfo")
33793398
async def GetPirInfo(self, channel: int, **_kwargs) -> None:
33803399
"""Get the Pir settings"""
3381-
mess = await self.send(cmd_id=212, channel=channel)
3382-
data = get_keys_from_xml(
3383-
mess,
3384-
{
3385-
"enable": ("enable", int),
3386-
"sensiValue": ("sensitive", int),
3387-
"reduceFalseAlarm": ("reduceAlarm", int),
3388-
"interval": ("interval", int),
3389-
"intervalSecMax": ("interval_max", int),
3390-
},
3391-
)
3392-
self.http_api._pir.setdefault(channel, {}).update(data)
3400+
await self._send_and_parse(212, channel)
33933401

33943402
@http_cmd("SetPirInfo")
33953403
async def SetPirInfo(self, **kwargs) -> None:

0 commit comments

Comments
 (0)