Skrip untuk mempublikasikan kuota broadband Andrews & Arnold / AAISP dan kecepatan sinkronisasi ke MQTT.
Ini menggunakan CHAOS API AAISP versi 2.
Berguna untuk mengintegrasikan dan menampilkan properti garis AAISP dalam aplikasi otomatisasi rumah, seperti Home Assistant atau openHAB.
Contoh menampilkan garis di Home Assistant...
Buat file konfigurasi, misalnya di /etc/aaisp-mqtt.conf, minimal yang dapat dijalankan tanpa autentikasi MQTT:
[aaisp]
username = aa@1
password = LongAccountPassword
[mqtt]
broker = 127.0.0.1
port = 1883
topic_prefix = aaisp
Anda juga dapat menentukan nama pengguna dan kata sandi MQTT secara opsional:
[aaisp]
username = aa@1
password = LongAccountPassword
[mqtt]
broker = 127.0.0.1
port = 1883
topic_prefix = aaisp
username = aaisp-service
password = AnotherLongPassword
Instal dependensi:
$ pip install -r requirements.txt
Jalankan layanan:
$ aaisp-to-mqtt.py /etc/aaisp-mqtt.conf
Ini akan menampilkan output debug yang mirip dengan:
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
Jadwalkan skrip melalui crontab untuk dijalankan setiap jam atau 30 menit.
Akun tunggal:
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
Untuk banyak akun:
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
Bangun image Docker dengan:
docker build -t aaisp-mqtt .
Jalankan kontainer dengan file konfigurasi yang terpasang pada volume:
docker run -d -v <path_to_config>:/app/config.cfg --name AAISPmqtt aaisp-mqtt
TODO
MIT
Menemukan bug? membuka masalah.