aaisp to mqtt
1.0.0
用于将 Andrews & Arnold / AAISP 宽带配额和同步费率发布到 MQTT 的脚本。
它使用 AAISP CHAOS API 的版本 2。
对于在家庭自动化应用程序(例如 Home Assistant 或 openHAB)中集成和显示 AAISP 线路属性非常有用。
在 Home Assistant 中显示线条的示例...
创建一个配置文件,例如在 /etc/aaisp-mqtt.conf 中,无需 MQTT 身份验证即可实现最小可行:
[aaisp]
username = aa@1
password = LongAccountPassword
[mqtt]
broker = 127.0.0.1
port = 1883
topic_prefix = aaisp
您还可以选择指定 MQTT 用户名和密码:
[aaisp]
username = aa@1
password = LongAccountPassword
[mqtt]
broker = 127.0.0.1
port = 1883
topic_prefix = aaisp
username = aaisp-service
password = AnotherLongPassword
安装依赖项:
$ pip install -r requirements.txt
运行服务:
$ aaisp-to-mqtt.py /etc/aaisp-mqtt.conf
它将显示类似于以下内容的调试输出:
INFO [2016-11-16 01:24:07,069] Connecting to AAISP CHAOSv2 endpoint
INFO [2016-11-16 01:24:07,338] Got 3 circuits
INFO [2016-11-16 01:24:07,338] * Lines: 32891, 37835, 37964
INFO [2016-11-16 01:24:07,338] * Logins: [email protected], [email protected], [email protected]
INFO [2016-11-16 01:24:07,339] Connecting to MQTT broker mqtt.gorras.hw.esgob.com:1883
INFO [2016-11-16 01:24:07,345] Connected OK to MQTT
INFO [2016-11-16 01:24:07,346] Published version and index messages
INFO [2016-11-16 01:24:07,350] Published details for 3 circuits
INFO [2016-11-16 01:24:07,350] Disconnecting from MQTT
通过 crontab 安排脚本每小时或 30 分钟运行一次。
单一账户:
aaisp/$lines 32891
aaisp/$logins [email protected]
aaisp/$version 0.1
aaisp/login/[email protected]/postcode SA65 9RR
aaisp/login/[email protected]/quota/monthly 100000000000
aaisp/login/[email protected]/quota/monthly/human 100 GB
aaisp/login/[email protected]/quota/remaining 84667320096
aaisp/login/[email protected]/quota/remaining/human 84.67 GB
aaisp/login/[email protected]/syncrate/down 5181000
aaisp/login/[email protected]/syncrate/down/human 5.18 MB
aaisp/login/[email protected]/syncrate/up 1205000
aaisp/login/[email protected]/syncrate/up/human 1.21 MB
对于多个帐户:
aaisp/$lines 32891,37835,37964
aaisp/$logins [email protected],[email protected],[email protected]
aaisp/$version 0.1
aaisp/login/[email protected]/postcode SA62 5EY
aaisp/login/[email protected]/quota/monthly 1000000000000
aaisp/login/[email protected]/quota/monthly/human 1 TB
aaisp/login/[email protected]/quota/remaining 752408843915
aaisp/login/[email protected]/quota/remaining/human 752.41 GB
aaisp/login/[email protected]/syncrate/down 68083000
aaisp/login/[email protected]/syncrate/down/human 68.08 MB
aaisp/login/[email protected]/syncrate/up 19999000
aaisp/login/[email protected]/syncrate/up/human 20 MB
aaisp/login/[email protected]/postcode SA62 5EY
aaisp/login/[email protected]/quota/monthly 1000000000000
aaisp/login/[email protected]/quota/monthly/human 1 TB
aaisp/login/[email protected]/quota/remaining 819343151266
aaisp/login/[email protected]/quota/remaining/human 819.34 GB
aaisp/login/[email protected]/syncrate/down 74425000
aaisp/login/[email protected]/syncrate/down/human 74.42 MB
aaisp/login/[email protected]/syncrate/up 19978000
aaisp/login/[email protected]/syncrate/up/human 19.98 MB
aaisp/login/[email protected]/postcode SA65 9RR
aaisp/login/[email protected]/quota/monthly 100000000000
aaisp/login/[email protected]/quota/monthly/human 100 GB
aaisp/login/[email protected]/quota/remaining 84667320096
aaisp/login/[email protected]/quota/remaining/human 84.67 GB
aaisp/login/[email protected]/syncrate/down 5181000
aaisp/login/[email protected]/syncrate/down/human 5.18 MB
aaisp/login/[email protected]/syncrate/up 1205000
aaisp/login/[email protected]/syncrate/up/human 1.21 MB
使用以下命令构建 Docker 映像:
docker build -t aaisp-mqtt .
使用卷安装的配置文件运行容器:
docker run -d -v <path_to_config>:/app/config.cfg --name AAISPmqtt aaisp-mqtt
待办事项
麻省理工学院
发现错误?打开一个问题。