Meraki MT30 Button Wi-Fi QR Code Generator

Use a Meraki MT30 button to enabled/disable a Meraki Wi-Fi SSID and generate a QR code allowing users to join the Wi-Fi network.

Note:
Only Open and PSK Authentication modes are supported at this time.

If applicable, the password (and corresponding QR code) depend on password policy chosen. Options include:

  1. Maintain the existing password
  2. Randomize the password
  3. Randomly select from a list of valid passwords

Contacts

  • Trevor Maco

Solution Components

  • Meraki MT30
  • Flask
  • Python 3.11

Prerequisites

MT30 Button

Ensure a MT30 button is claimed and licensed in the Meraki Org. Follow the button setup and installation guide here

Meraki API Keys

In order to use the Meraki API, you need to enable the API for your organization first. After enabling API access, you can generate an API key. Follow these instructions to enable API access and generate an API key:

  1. Login to the Meraki dashboard
  2. In the left-hand menu, navigate to Organization > Settings > Dashboard API access
  3. Click on Enable access to the Cisco Meraki Dashboard API
  4. Go to My Profile > API access
  5. Under API access, click on Generate API key
  6. Save the API key in a safe place. The API key will only be shown once for security purposes, so it is very important to take note of the key then. In case you lose the key, then you have to revoke the key and a generate a new key. Moreover, there is a limit of only two API keys per profile.

For more information on how to generate an API key, please click here.

Note: You can add your account as Full Organization Admin to your organizations by following the instructions here.

Make Local Application Reachable over the Internet

The script requires being reachable over an internet accessible URL to receive the Meraki MT30 Webhook events. Therefore, it can be deployed on different IaaS platforms like Heroku, Amazon Web Services Lambda, Google Cloud Platform (GCP) etc. . For simplicity, we use the ngrok tool here.

  1. Download ngrok on the official website.
  2. Extract the folder files
  3. Run the ngrok.exe by double-clicking on the file
  4. Type the command ngrok http 5000 and press enter
  5. Note the https redirect URL for a later step

Installation/Configuration

Meraki Dashboard

It is required to define a Webhook HTTP server and to configure a MT30 button automation in the Meraki Dashboard for this integration.

Configure the Webhook in the Meraki Dashboard:

  1. Go to Network-wide > Alerts

  2. Add an HTTP server in Webhooks: HTTP servers section:

    1. Fill in a name for your webhook
    2. Add [ngrok https url]/button-press in the URL field
    3. Choose and fill in a shared secret

Configure a Meraki MT30 Button Automation

  1. Go to Sensors > Configure:Automations
  2. Click the New Automation button
  3. Fill in a name for the automation and click Next
  4. Choose the Button sensor and click Next
  5. Choose the Any Press trigger and click Next
  6. Check the Toggle SSID action, and select the SSID
  7. Check the Send a Webhook command action and add the previously defined Webhook HTTP server as Webhook recipient.
  8. Click Next
  9. Select the Always schedule and click Next
  10. Select all MT30 buttons to apply the automation to and click Next
  11. Check the preview and press Finish and Save

Script setup

  1. Clone this repository with git clone [repository name]
  2. Rename the .env_sample file to .env. Rename config_sample.py to config.py.
  3. Add Meraki API key, Webhook shared secret, Meraki org name, Meraki network name (containing SSID), and SSID name to environment variables located in .env.
MERAKI_API_KEY = ""
SHARED_SECRET = ""
ORG_NAME = ""
NETWORK_NAME = ""
SSID_NAME = ""
  1. Select password policy and provide list of usable passwords (if option 3 is selected) in config.py
# Password methodology choice. Only applicable to SSIDs that use PSK. See Available options:
# 1. Same Password (set originally in Meraki Dashboard) -> Default Option
# 2. Random Password (Randomly generate password)
# 3. Password List (Randomly select from PASSWORD_LIST - must have at least 1 password in list, passwords must
# conform to Meraki SSID password policy: >= 8 alphanumeric characters, etc.)
PASSWORD_POLICY = 1
PASSWORD_LIST = ['sample1', 'sample2']
  1. Set up a Python virtual environment. Make sure Python 3 is installed in your environment, and if not, you may download Python here. Once Python 3 is installed in your environment, you can activate the virtual environment with the instructions found here.
  2. Install the requirements with pip3 install -r requirements.txt

Usage

To run the program, use the command:

$ flask run

Press the MT30 button, and the automation workflow will trigger.

Navigate to the hosted URL for the flask app (for ex: the ngrok url if running locally), and you will see a QR code generated for the SSID (assuming the SSID was disabled before):

Note: it can take up to 30 seconds for the workflow to complete. Please refresh the page if webpage display has not updated.

If the new SSID state is disabled, the following will be displayed:

If this is the first QR code created for the SSID, the following will be displayed:

Note: Created QR codes can be found under static > qr_codes > [ssid name].png

Screenshots

/IMAGES/0image.png

LICENSE

Provided under Cisco Sample Code License, for details see LICENSE

CODE_OF_CONDUCT

Our code of conduct is available here

CONTRIBUTING

See our contributing guidelines here

DISCLAIMER:

Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use.
You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.

View code on GitHub
  • Owner

  • Contributors

  • Categories

  • Products

    Meraki
  • Programming Languages

    CSS
  • License

    Other

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.