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
待辦事項
麻省理工學院
發現錯誤?打開一個問題。