Guest wifi card with QR code

This is my first attempt at creating a card for my guest wifi network.
QR code and switch comes from Unifi and the image via a Picture Entity Card

wifi_card

If you want to duplicate this card…

This card is based the on unifi access points and integration. the latest Unifi integration supports the wifi QR code (by default disabled)

Unifi integration has a entity for the

  • QR code
  • switch for every SSID
  • Users connected
    XXX in de code below is the name of your Wifi SSID

I use some custom cards you can install thrue HACS
custom:stack-in-card
custom:mushroom-template-card

and 2 images

type: custom:stack-in-card
title: Guest Wifi
mode: vertical
cards:
  - type: horizontal-stack
    cards:
      - type: picture-entity
        style: |
          ha-card {
            border: none;
          }
        entity: image.XXX_qr_code
        show_name: false
        show_state: false
      - type: picture-entity
        style: |
          ha-card {
            border: none;
          }
        entity: switch.XXX
        state_image:
          'on': /local/images/guest_wifi_on.jpg
          'off': /local/images/guest_wifi_off.jpg
        show_name: false
        show_state: false
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        primary: Users connected {{ states ('sensor.XXX')}}
        style: |
          ha-card {
            border: none;
          }
      - type: entities
        style: |
          ha-card {
            border: none;
          }
        entities:
          - switch.XXX

For the state image’s you have to supply your own path to the images
/local/ = config/www folder on your HA server

5 Likes

does it refresh on the next time you open the card itself after you’ve enabled the guest network through the switch?
or does the picture remain the same every single time?

And not less important, what QR are you showing and what is the desired config?

There are multiple ways to setup a guest network…
With and without a password on the ssid
and additionally with a password on a portal.

I assume this is the password for the SSID, and from my knowledge this does not change.

If my assumptiion is incorrect, would like to hear the setup and goal.

1 Like

Thanks for your reply.

The image for the QR code always stays the same as long as I don’t change the password.
the image I am referring to is that of the wifi symbol.
This image changes when turning the guest wifi hotspot on and off using the switch

See code below

 - type: picture-entity
        style: |
          ha-card {
            border: none;
          }
        entity: switch.gma
        state_image:
          'on': /local/images/wifi_on.jpg
          'off': /local/images/wifi_off.jpg
        show_name: false
        show_state: false  

It’s just a cosmetic flaw
Most people won’t even notice that the wifi symbol pictures don’t have the same style.

But I would like to know how image caching works in a UI/Dashboard card

I don’t have any technical details about it, but I’ve found that if a image is replaced on the background, I have to forcefully refresh the browser (ctrl+F5) and the new picture is shown.

It’s not clear to me if the picture actually changes when you set the wifi to on or off.

refresh the browser (ctrl+F5) and restart of Home assistant and some other tricks i know don’t work for me

as you can see in the animated GIF the image changes by toggling the SSID on and off

it toggles between two images and one of the images is old, I have a newer one in the www folder but it is not showing

Thank you for think along.

Try using different file names for the new ones and change to suit in the state_image section

1 Like

thx changing the name of the image also refreshed it in the cache.
Anyway, it solves my problem. Maybe one day I will learn how the underlying technology works

HI all,

i made and it work wonderfully :slight_smile:

Another question it is possible to make Alexa echo show to show QR Code by automation or Something else ?

Hello all,

Recently I deployed a unifi server and came accros this card.

The unify cloud server is 2fa included.
To use the addon from Unify i Homeassistant I needed to make a local account.

I obtain a lot of entities, switches and so on. Though when using this card, and toggle the wifi on or off i get the following error.

Failed to call service switch/turn_off. Call https://192.168.10.1:443/api/auth/login received 429: b’{“code”:“AUTHENTICATION_FAILED_LIMIT_REACHED”,“message”:“You've reached the login attempt limit”,“level”:“debug”}’

And toggle it to on,

Failed to call service switch/turn_on. Call https://192.168.10.1:443/proxy/network/api/s/default/rest/wlanconf/xxxxxxxxxxxxxxxxxxxxxxx50 received 401 Unauthorized

Someone can tell me what I am doing wrong?

Fyi, I run the latest homeassistant on a Synology Nas virtual machine.

All other switches are working by the way.

Regards Edwin.