Just wondering if the code below found on the forums could be modified to display signal strength for my Unifi Protect cameras?
sensor:
- platform: wifi_signal
id: wifi_sig
name: Signal
update_interval: 60s
text_sensor:
- platform: template
name: "Wifi Bars"
entity_category: diagnostic
lambda: |-
if (id(wifi_sig).state >= -30) {
return (std::string) "4";
} else if (id(wifi_sig).state < -30 && id(wifi_sig).state >= -67) {
return (std::string) "3";
} else if (id(wifi_sig).state < -67 && id(wifi_sig).state >= -70) {
return (std::string) "2";
} else if (id(wifi_sig).state < -70 && id(wifi_sig).state >= -80) {
return (std::string) "1";
} else {
return (std::string) "0";
}
update_interval: 60s
Mikefila
(Mike Fila)
August 13, 2024, 8:22pm
2
The code that you posted is for esphome. Is that what you are using?
Not using esphome. Didn’t know how easy it would be to modify code, Just would like to see something other dmb which is what the integration reports the signal strength in
You can create a template sensor to read the dBm value and convert to percentages, but it won’t show in the device page. Just change the sensor name for whatever yours is. Percentages based on: Conversion of signal strength in dBm to percentage in WiFi Explorer - Intuitibits
{% set signal = states('sensor.blaidd_enclosure_cam_1_wifi_signal_strength') | int %}
{% if signal >= -20 %}
100
{% elif signal >= -21 %}
99
{% elif signal >= -24 %}
98
{% elif signal >= -27 %}
97
{% elif signal >= -29 %}
96
{% elif signal >= -31 %}
95
{% elif signal >= -33 %}
94
{% elif signal >= -34 %}
93
{% elif signal >= -36 %}
92
{% elif signal >= -37 %}
91
{% elif signal >= -39 %}
90
{% elif signal >= -40 %}
89
{% elif signal >= -41 %}
88
{% elif signal >= -42 %}
87
{% elif signal >= -43 %}
86
{% elif signal >= -44 %}
85
{% elif signal >= -45 %}
84
{% elif signal >= -46 %}
83
{% elif signal >= -47 %}
82
{% elif signal >= -48 %}
81
{% elif signal >= -49 %}
80
{% elif signal >= -50 %}
79
{% elif signal >= -51 %}
78
{% elif signal >= -52 %}
76
{% elif signal >= -53 %}
75
{% elif signal >= -54 %}
74
{% elif signal >= -55 %}
73
{% elif signal >= -56 %}
71
{% elif signal >= -57 %}
70
{% elif signal >= -58 %}
69
{% elif signal >= -59 %}
67
{% elif signal >= -60 %}
66
{% elif signal >= -61 %}
64
{% elif signal >= -62 %}
63
{% elif signal >= -63 %}
61
{% elif signal >= -64 %}
60
{% elif signal >= -65 %}
58
{% elif signal >= -66 %}
56
{% elif signal >= -67 %}
55
{% elif signal >= -68 %}
53
{% elif signal >= -69 %}
51
{% elif signal >= -70 %}
50
{% elif signal >= -71 %}
48
{% elif signal >= -72 %}
46
{% elif signal >= -73 %}
44
{% elif signal >= -74 %}
42
{% elif signal >= -75 %}
40
{% elif signal >= -76 %}
38
{% elif signal >= -77 %}
36
{% elif signal >= -78 %}
34
{% elif signal >= -79 %}
32
{% elif signal >= -80 %}
30
{% elif signal >= -81 %}
28
{% elif signal >= -82 %}
26
{% elif signal >= -83 %}
24
{% elif signal >= -84 %}
22
{% elif signal >= -85 %}
20
{% elif signal >= -86 %}
17
{% elif signal >= -87 %}
15
{% elif signal >= -88 %}
13
{% elif signal >= -89 %}
10
{% elif signal >= -90 %}
8
{% elif signal >= -91 %}
6
{% elif signal >= -92 %}
3
{% elif signal >= -93 %}
1
{% else %}
1
{% endif %}
thanks for this. Seems to have an issue right with first line
missed comma between flow collection entries (1:2)
1 | {% set signal = states('sensor.bl …
------^
Weird. I copy/pasted directly what I posted and it’s working fine for me.
it won’t show in the device page.
If you set up the template sensor in the GUI you can now assign a device for it to appear in
I read your instructions wrong. I will try again later
Oh nice. I totally missed that.