跳转到主要内容

Reolink NVR/cameras API包

项目描述


Reolink NVR/cameras API包

Sponsor Affiliate link Current version

《reolink_aio》Python包允许您将您的Reolink设备(NVR/摄像头)集成到您的应用程序中。

描述

这是一个实现Reolink IP NVR和摄像头API的包。它还提供了一个订阅Reolink ONVIF SWN事件的方式,以便可以通过webhook接收实时事件。

表达您的感激之情

如果您欣赏Reolink集成并希望支持其开发,请考虑赞助上游库或通过此联盟链接购买Reolink产品。

先决条件

  • Python 3.10

安装

pip3 install reolink-aio

或手动

git clone https://github.com/StarkillerOG/reolink_aio
cd reolink_aio/
pip3 install .

用法

from reolink_aio.api import Host
import asyncio

# Create a host-object (representing either a camera, or NVR with several channels)
host = Host('192.168.1.10', 80, 'user', 'mypassword')

# Obtain/cache NVR or camera settings and capabilities, like model name, ports, HDD size, etc:
await host.get_host_data()

# Get the subscribtion port and host-device name:
subscribtion_port =  host.onvif_port
name = host.nvr_name

# Obtain/cache states of features:
await host.get_states()

# Print some state value on the channel with index 0:
print(host.ir_enabled(0))

# Enable the infrared lights on the channel with index 1:
await host.set_ir_lights(1, True)

# Enable the spotlight on the channel with index 1:
await host.set_spotlight(1, True)

# Enable the siren on the channel with index 0:
await host.set_siren(0, True)

# Now subscribe to events, suppose our webhook url is http://192.168.1.11/webhook123
await host.subscribe('http://192.168.1.11/webhook123')

# After some minutes check the renew timer (keep the eventing alive):
if (host.renewTimer <= 100):
    await host.renew()

# Logout and disconnect
await host.disconnect()

示例

这是API使用的示例。在这种情况下,我们想要检索并打印NVR的MAC地址。

from reolink_aio.api import Host
import asyncio

async def print_mac_address():
    # initialize the host
    host = Host('192.168.1.109','admin', 'admin1234', port=80)
    # connect and obtain/cache device settings and capabilities
    await host.get_host_data()
    # check if it is a camera or an NVR
    print("It is an NVR: %s, number of channels: %s", host.is_nvr, host.num_channels)
    # print mac address
    print(host.mac_address)
    # close the device connection
    await host.logout()

if __name__ == "__main__":
    asyncio.run(print_mac_address())

致谢

这个库是基于以下工作的

作者

@starkillerOG: https://github.com/starkillerOG

贡献者

项目详情


发布历史 发布通知 | RSS源

下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解更多关于 安装包 的信息。

源代码分发

reolink_aio-0.9.11.tar.gz (60.3 kB 查看哈希值)

上传时间 源代码

构建分发

reolink_aio-0.9.11-py3-none-any.whl (58.5 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面