Customizing SSID

Goodmorning All,

I’m trying to accomplish that when i’m not connected to my wifi or any known wifi, it doesn’t show ‘Not_Connected’ but instead says something like ‘5G’.

After some trail and error i’ve accomplished that part, but now it always shows ‘5G’ even when i’m on my home wifi

    [[[
      var l = states['sensor.iphone_van_maurice_ssid'].state;
      if (l = 'not_connected') { l = '5G' }
      return `<ha-icon
        icon="mdi:wifi-arrow-up-down"
        style="width: 40px; height: 20px; vertical-align: 11%; color: deepskyblue;">
        </ha-icon><span> <span style="color: var(--text-color-sensor);">${l}</span></span>`
    ]]]

So what i would like to see is that it always shows the connected wifi, and only when not connected to any wifi it shows 5G

What am i missing?

This should do the trick:


  [[[
    var ssid = states['sensor.iphone_van_maurice_ssid'].state;
    var type = states['sensor.iphone_van_maurice_connection_type'].state;
    
    if (type != 'Wi-Fi') { ssid = '5G' }
    else { ssid }
    return `<ha-icon
      icon="mdi:wifi-arrow-up-down"
      style="width: 40px; height: 20px; vertical-align: 11%; color: deepskyblue;">
      </ha-icon><span style="color: var(--text-color-sensor);">${ssid}</span>`
  ]]]

1 Like

Hi @pedolsky ;

Thanks for the quick reply.
I tied it but this gives me a weird error:

Configuratiefouten ontdekt:

    tab characters must not be used in indentation (72:1)

     69 |       - justify-self: start
     70 | custom_fields:
     71 |   Wifi: |
     72 | →[[[
    ------^
     73 | →  var ssid = states['sensor.ip ...
     74 |       var type = states['sensor ...

I also think i might gave some wrong/strange information. Eerly day :confused:

The line i added: if (l = 'not_connected') { l = '5G' } makes it a bit weird. Before i added this line, when my phone connected to wifi it just showed the wifi name. Exactly what i wanted. But when i’m on my cellular it shows “not_connected”.
Basicly when i’m not on a known wifi network, so i’m using my 5G, it needs to show that instead of not_connected.

Does this make sense?

I can’t encounter any hidden characters. Can you delete them? Anyway, the suggested way seems clear, I think.
Maybe stupid question, but have you checked your phone settings twice? Is Apples private mode activated?

As far as i know my settings are okay, because it always shows me the correct wi-fi and location.

But; i’m trying to understand the config you made.

    var ssid = states['sensor.iphone_van_maurice_ssid'].state;
    var type = states['sensor.iphone_van_maurice_connection_type'].state;
    
    if (type != 'Wi-Fi') { ssid = '5G' }
    else { ssid }

Isn’t this just telling that if my type = wifi it has to show 5G?

If it’s not in a known WiFi area, then it shows „5G“, otherwise it shows the connected WiFi.

I’ll have to excuse me. It’s working.
After editing it with Notepad++ it’s correct.

Somehow when copy/pasting it went wrong.

Thanks!. Happy Days :smiley:

Glad to hear!