[GH-ISSUE #56] Setting up the QR-Code functionality (Homeassistant Addon) #26

Closed
opened 2026-05-07 00:17:54 +02:00 by BreizhHardware · 7 comments

Originally created by @0xvisualiris on GitHub (Jan 5, 2025).
Original GitHub issue: https://github.com/glenndehaan/unifi-voucher-site/issues/56

Originally assigned to: @glenndehaan on GitHub.

The question

Hello together,
I found this GitHub project and installed the UniFi Voucher Site on my homeassistant as an addon. Everything works really well. But I can't figure it out, how to enable the QR - Code functionality. Maybe I missed it in the docs or something like that. If anyone can help me, would be really nice!

cheers

Originally created by @0xvisualiris on GitHub (Jan 5, 2025). Original GitHub issue: https://github.com/glenndehaan/unifi-voucher-site/issues/56 Originally assigned to: @glenndehaan on GitHub. ### The question Hello together, I found this GitHub project and installed the UniFi Voucher Site on my homeassistant as an addon. Everything works really well. But I can't figure it out, how to enable the QR - Code functionality. Maybe I missed it in the docs or something like that. If anyone can help me, would be really nice! cheers
BreizhHardware 2026-05-07 00:17:54 +02:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@glenndehaan commented on GitHub (Jan 5, 2025):

Hi @0xvisualiris,

The QR codes are used within the Email and Print functions (So within the UI they are not displayed). If you have one or both setup but don't see the QR code then you are probably missing:

# The UniFi SSID where guests need to connect to (Used within templating and 'Scan to Connect')
UNIFI_SSID: ''
# The UniFi SSID WPA/WPA2/WPA3 Password (Can be ignored for 'Open' networks) (Used within templating and 'Scan to Connect')
UNIFI_SSID_PASSWORD: ''

Only the UNIFI_SSID is required here if you have an Open network. If not then you also need to assign UNIFI_SSID_PASSWORD.

Let me know if this works for you.

Kind regards,
Glenn

<!-- gh-comment-id:2571750382 --> @glenndehaan commented on GitHub (Jan 5, 2025): Hi @0xvisualiris, The QR codes are used within the Email and Print functions (So within the UI they are not displayed). If you have one or both setup but don't see the QR code then you are probably missing: ```yaml # The UniFi SSID where guests need to connect to (Used within templating and 'Scan to Connect') UNIFI_SSID: '' # The UniFi SSID WPA/WPA2/WPA3 Password (Can be ignored for 'Open' networks) (Used within templating and 'Scan to Connect') UNIFI_SSID_PASSWORD: '' ``` Only the `UNIFI_SSID` is required here if you have an Open network. If not then you also need to assign `UNIFI_SSID_PASSWORD`. Let me know if this works for you. Kind regards, Glenn
Author
Owner

@aroundmyroom commented on GitHub (Jan 8, 2025):

Tried it today with iOS, I get an QR code, but my iPhone ( (photo-app)) states 'no valid etc.. '
however, when using QR-Reader app I see that it can read the QR code. but it won't auto-connect through the camera option

image

when using a tool like: https://qrfy.com/ I am able to use the created QR code without password/encryption for the open network.

image

<!-- gh-comment-id:2577662961 --> @aroundmyroom commented on GitHub (Jan 8, 2025): Tried it today with iOS, I get an QR code, but my iPhone ( (photo-app)) states 'no valid etc.. ' however, when using QR-Reader app I see that it can read the QR code. but it won't auto-connect through the camera option ![image](https://github.com/user-attachments/assets/da30964f-a182-473a-bf88-46ecd0e66687) when using a tool like: https://qrfy.com/ I am able to use the created QR code without password/encryption for the open network. ![image](https://github.com/user-attachments/assets/3cdb2ce5-17e3-45ef-9a99-88c6597b359d)
Author
Owner

@aroundmyroom commented on GitHub (Jan 8, 2025):

update: there is an issue for open networks, below sample codes qr.js is working in my environment for open networks

/**
 * Import vendor modules
 */
const QRCode = require('qrcode');

/**
 * Import own modules
 */
const log = require('./log');
const variables = require('./variables');

/**
 * Generates a QR code from the UniFi SSID (Scan to Connect)
 *
 * @param buffer
 * @return {Promise<unknown>}
 */
module.exports = (buffer = false) => {
    return new Promise((resolve) => {
        const ssid = variables.unifiSsid;
        const password = variables.unifiSsidPassword;

        // Determine the QR code content based on whether the network is open or secured
        const qrContent = password
            ? `WIFI:S:${ssid};T:WPA;P:${password};;`  // Secured network
            : `WIFI:S:${ssid};;`;                    // Open network

        if (!buffer) {
            QRCode.toDataURL(qrContent, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
                if (err) {
                    log.error(`[Qr] Error while generating code!`);
                    log.error(err);
                    return resolve(null);
                }

                resolve(url);
            });
        } else {
            QRCode.toBuffer(qrContent, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
                if (err) {
                    log.error(`[Qr] Error while generating code!`);
                    log.error(err);
                    return resolve(null);
                }

                resolve(buffer);
            });
        }
    });
};

Does work and generates a valid QR for open networks without PWD and encryption is Free, the reason why it failed was that the P variable was not allowed for open networks
WIFI:S:;;;; and not WIFI:S:;;P:;;

In my script I created a variable UNIFI_SSID_PASSWORD = '' so that above could work

<!-- gh-comment-id:2577735113 --> @aroundmyroom commented on GitHub (Jan 8, 2025): update: there is an issue for open networks, below sample codes qr.js is working in my environment for open networks ``` /** * Import vendor modules */ const QRCode = require('qrcode'); /** * Import own modules */ const log = require('./log'); const variables = require('./variables'); /** * Generates a QR code from the UniFi SSID (Scan to Connect) * * @param buffer * @return {Promise<unknown>} */ module.exports = (buffer = false) => { return new Promise((resolve) => { const ssid = variables.unifiSsid; const password = variables.unifiSsidPassword; // Determine the QR code content based on whether the network is open or secured const qrContent = password ? `WIFI:S:${ssid};T:WPA;P:${password};;` // Secured network : `WIFI:S:${ssid};;`; // Open network if (!buffer) { QRCode.toDataURL(qrContent, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => { if (err) { log.error(`[Qr] Error while generating code!`); log.error(err); return resolve(null); } resolve(url); }); } else { QRCode.toBuffer(qrContent, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => { if (err) { log.error(`[Qr] Error while generating code!`); log.error(err); return resolve(null); } resolve(buffer); }); } }); }; ``` Does work and generates a valid QR for open networks without PWD and encryption is Free, the reason why it failed was that the P variable was not allowed for open networks WIFI:S:<SSID>;;;; and not WIFI:S:<SSID>;;P:;; In my script I created a variable UNIFI_SSID_PASSWORD = '' so that above could work
Author
Owner

@0xvisualiris commented on GitHub (Jan 8, 2025):

Hey @glenndehaan :),

thanks for the fast answer. I configured it with the mail and now I get the QR - Code. Only problem is now, that I got the same error as the other people wrote with "no valid information found".

I also run my guest wifi with the hotspot portal so it's open for everyone. Would be nice if you can dig into it.

Thank you!
Cheers! :)

<!-- gh-comment-id:2578072014 --> @0xvisualiris commented on GitHub (Jan 8, 2025): Hey @glenndehaan :), thanks for the fast answer. I configured it with the mail and now I get the QR - Code. Only problem is now, that I got the same error as the other people wrote with "no valid information found". I also run my guest wifi with the hotspot portal so it's open for everyone. Would be nice if you can dig into it. Thank you! Cheers! :)
Author
Owner

@glenndehaan commented on GitHub (Jan 8, 2025):

Hi @aroundmyroom,

You are correct it seems that the previous code got merged out when I was implementing the password option for someone else.

@0xvisualiris @aroundmyroom With version 4.5.2 that was just released this should now be resolved.

<!-- gh-comment-id:2578325670 --> @glenndehaan commented on GitHub (Jan 8, 2025): Hi @aroundmyroom, You are correct it seems that the previous code got merged out when I was implementing the password option for someone else. @0xvisualiris @aroundmyroom With version 4.5.2 that was just released this should now be resolved.
Author
Owner

@aroundmyroom commented on GitHub (Jan 8, 2025):

@glenndehaan no problem, I've updated the code and its working with the git code.
Thanks.

<!-- gh-comment-id:2578351382 --> @aroundmyroom commented on GitHub (Jan 8, 2025): @glenndehaan no problem, I've updated the code and its working with the git code. Thanks.
Author
Owner

@glenndehaan commented on GitHub (Jan 9, 2025):

Closing this issue since this is confirmed working

<!-- gh-comment-id:2580944522 --> @glenndehaan commented on GitHub (Jan 9, 2025): Closing this issue since this is confirmed working
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/unifi-voucher-site#26
No description provided.