Skip to content

natm/aaisp-to-mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AAISP to MQTT Service

A script to publish Andrews & Arnold / AAISP broadband quota and sync rates to MQTT.

It uses version 2 of AAISPs CHAOS API.

Useful for integrating and displaying AAISP line properties in home automation applications, such as Home Assistant or openHAB.

Workflow

Use cases

  • Displaying line properties in Home Assistant / openHAB
  • Asking Amazon Alexa Echo for the remaining quota
  • Flashing a light in the office when the downstream sync rate drops
  • Sending line info to Crouton

Example showing lines in Home Assistant...

Screenshot

Screenshot

Configuration

Create a config file, for example in /etc/aaisp-mqtt.conf, minimal viable with no MQTT authentication:

[aaisp]
username = aa@1
password = LongAccountPassword

[mqtt]
broker = 127.0.0.1
port = 1883
topic_prefix = aaisp

You can also optionally specify MQTT username and password:

[aaisp]
username = aa@1
password = LongAccountPassword

[mqtt]
broker = 127.0.0.1
port = 1883
topic_prefix = aaisp
username = aaisp-service
password = AnotherLongPassword

Install the dependencies:

$ pip install -r requirements.txt

Run the service:

$ aaisp-to-mqtt.py /etc/aaisp-mqtt.conf

It will display debug output similar to:

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: gb12@a.1, el6@a.1, el6@a.2
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

Schedule the script via a crontab to run every hour or 30 minutes.

Topics

Single account:

aaisp/$lines                                    32891
aaisp/$logins                                   gb12@a.1
aaisp/$version                                  0.1
aaisp/login/gb12@a.1/postcode                   SA65 9RR
aaisp/login/gb12@a.1/quota/monthly              100000000000
aaisp/login/gb12@a.1/quota/monthly/human        100 GB
aaisp/login/gb12@a.1/quota/remaining            84667320096
aaisp/login/gb12@a.1/quota/remaining/human      84.67 GB
aaisp/login/gb12@a.1/syncrate/down              5181000
aaisp/login/gb12@a.1/syncrate/down/human        5.18 MB
aaisp/login/gb12@a.1/syncrate/up                1205000
aaisp/login/gb12@a.1/syncrate/up/human          1.21 MB

For multiple accounts:

aaisp/$lines                                    32891,37835,37964
aaisp/$logins                                   gb12@a.1,el6@a.1,el6@a.2
aaisp/$version                                  0.1
aaisp/login/el6@a.1/postcode                    SA62 5EY
aaisp/login/el6@a.1/quota/monthly               1000000000000
aaisp/login/el6@a.1/quota/monthly/human         1 TB
aaisp/login/el6@a.1/quota/remaining             752408843915
aaisp/login/el6@a.1/quota/remaining/human       752.41 GB
aaisp/login/el6@a.1/syncrate/down               68083000
aaisp/login/el6@a.1/syncrate/down/human         68.08 MB
aaisp/login/el6@a.1/syncrate/up                 19999000
aaisp/login/el6@a.1/syncrate/up/human           20 MB
aaisp/login/el6@a.2/postcode                    SA62 5EY
aaisp/login/el6@a.2/quota/monthly               1000000000000
aaisp/login/el6@a.2/quota/monthly/human         1 TB
aaisp/login/el6@a.2/quota/remaining             819343151266
aaisp/login/el6@a.2/quota/remaining/human       819.34 GB
aaisp/login/el6@a.2/syncrate/down               74425000
aaisp/login/el6@a.2/syncrate/down/human         74.42 MB
aaisp/login/el6@a.2/syncrate/up                 19978000
aaisp/login/el6@a.2/syncrate/up/human           19.98 MB
aaisp/login/gb12@a.1/postcode                   SA65 9RR
aaisp/login/gb12@a.1/quota/monthly              100000000000
aaisp/login/gb12@a.1/quota/monthly/human        100 GB
aaisp/login/gb12@a.1/quota/remaining            84667320096
aaisp/login/gb12@a.1/quota/remaining/human      84.67 GB
aaisp/login/gb12@a.1/syncrate/down              5181000
aaisp/login/gb12@a.1/syncrate/down/human        5.18 MB
aaisp/login/gb12@a.1/syncrate/up                1205000
aaisp/login/gb12@a.1/syncrate/up/human          1.21 MB

Docker

Build the Docker image with:

docker build -t aaisp-mqtt .

Run the container with a volume mounted config file:

docker run -d -v <path_to_config>:/app/config.cfg --name AAISPmqtt aaisp-mqtt

Setup

TODO

License

MIT

Contributing guidelines

  • Fork the repo
  • Create a branch
  • Make your changes
  • Open a pull request back from your branch to master in this repo

Found a bug? open an issue.

About

A daemon to send AAISP circuit details to MQTT

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published