WiFi RSSI Device Class

Hi,

I noticed under MQTT you can have a sensor with the class of ‘Battery’, this is nice because the icon changes based on the value.

I have created a ESP8266 device that reports its own WiFi signal strength, this is published to MQTT. It would be great to have a WiFi RSSI class that measures in ‘dBm’ and changes the icon based on strength.

The negative value of dBm is somewhat confusing for basic users.
I think signal displayed with the bars might be helpful

Is this worth while?

I am actually doing that with the custom template card… the MQTT sensor reports strength from 0-100 but using a template you can convert to dBm and then set the icon according to the strength. I have my Lovelace code for how to do it in that thread for the 100% Templatable something… search 100% template and you’ll see it

David how did you do this template card. I want to show the dbm in the negative form but MQTT shows the RSSI as a positive number. I saw where you did the section in your lovelace for “MQTT & Wifi Connections” but I could not figure out how to convert that from the Lovelace file format to the UI format but from I see it will show the -dB value in the card correct?

I use the custom config-template card

          - type: 'custom:config-template-card'
            variables:
              - states['sensor.sonoff1_2914_status'].attributes['MqttCount']
              - states['sensor.sonoff1_2914_status'].attributes['WiFi LinkCount']
              - states['sensor.sonoff1_2914_status'].state
              - states['sensor.sonoff2_3110_status'].attributes['MqttCount']
              - states['sensor.sonoff2_3110_status'].attributes['WiFi LinkCount']
              - states['sensor.sonoff2_3110_status'].state
              - states['sensor.sonoff5_1083_status'].attributes['MqttCount']
              - states['sensor.sonoff5_1083_status'].attributes['WiFi LinkCount']
              - states['sensor.sonoff5_1083_status'].state
              - states['sensor.sonoff6_3719_status'].attributes['MqttCount']
              - states['sensor.sonoff6_3719_status'].attributes['WiFi LinkCount']
              - states['sensor.sonoff6_3719_status'].state
              - states['sensor.nodemcu_lounge_status'].attributes['MqttCount']
              - states['sensor.nodemcu_lounge_status'].attributes['WiFi LinkCount']
              - states['sensor.nodemcu_lounge_status'].state
            entities:
              - sensor.sonoff1_2914_status
              - sensor.sonoff2_3110_status
              - sensor.sonoff5_1083_status
              - sensor.sonoff6_3719_status
              - sensor.nodemcu_lounge_status
            card:
              type: 'custom:hui-entities-card'
              title: MQTT & Wifi Connections
              show_header_toggle: false
              entities:
                - entity: sensor.sonoff1_2914_status
                  name: "${'Coffee' + '\xa0'.repeat(16) + 'MQTT ' + vars[0] + '\xa0'.repeat(4) + 'WiFi ' + vars[1] + '\xa0'.repeat(3) + ((parseInt(vars[2]) / 2) - 100 ) + '\xa0' + 'dBm' + '\xa0'.repeat(3) + ( vars[2] >= 100 ? 'Excellent' : vars[2] >= 80 ? 'Good' : vars[2] >= 60 ? 'Fair' : 'Weak' )}"
                  icon: "${vars[2] >= 100 ? 'mdi:wifi' : vars[2] >= 80 ? 'mdi:wifi-strength-3' : vars[2] >= 60 ? 'mdi:wifi-strength-2' : 'mdi:wifi-strength-1' }"
                - entity: sensor.sonoff2_3110_status
                  name: "${'Toothbrush' + '\xa0'.repeat(7) + 'MQTT ' + vars[3] + '\xa0'.repeat(4) + 'WiFi ' + vars[4] + '\xa0'.repeat(3) + ((parseInt(vars[5]) / 2) - 100 ) + '\xa0' +  'dBm' + '\xa0'.repeat(3) + ( vars[5] >= 100 ? 'Excellent' : vars[5] >= 80 ? 'Good' : vars[5] >= 60 ? 'Fair' : 'Weak' )}"
                  icon: "${vars[5] >= 100 ? 'mdi:wifi' : vars[5] >= 80 ? 'mdi:wifi-strength-3' : vars[5] >= 60 ? 'mdi:wifi-strength-2' : 'mdi:wifi-strength-1' }"
                - entity: sensor.sonoff5_1083_status
                  name: "${'Garage' + '\xa0'.repeat(15) + 'MQTT ' + vars[6] + '\xa0'.repeat(4) + 'WiFi ' + vars[7] + '\xa0'.repeat(3) + ((parseInt(vars[8]) / 2) - 100 ) + '\xa0' +  'dBm' + '\xa0'.repeat(3) + ( vars[8] >= 100 ? 'Excellent' : vars[8] >= 80 ? 'Good' : vars[8] >= 60 ? 'Fair' : 'Weak' )}"
                  icon: "${vars[8] >= 100 ? 'mdi:wifi' : vars[8] >= 80 ? 'mdi:wifi-strength-3' : vars[8] >= 60 ? 'mdi:wifi-strength-2' : 'mdi:wifi-strength-1' }"
                - entity: sensor.sonoff6_3719_status
                  name: "${'Alarm' + '\xa0'.repeat(17) + 'MQTT ' + vars[9] + '\xa0'.repeat(4) + 'WiFi ' + vars[10] + '\xa0'.repeat(3) + ((parseInt(vars[11]) / 2) - 100 ) + '\xa0' +  'dBm' + '\xa0'.repeat(3) + ( vars[11] >= 100 ? 'Excellent' : vars[11] >= 80 ? 'Good' : vars[11] >= 60 ? 'Fair' : 'Weak' )}"
                  icon: "${vars[11] >= 100 ? 'mdi:wifi' : vars[11] >= 80 ? 'mdi:wifi-strength-3' : vars[11] >= 60 ? 'mdi:wifi-strength-2' : 'mdi:wifi-strength-1' }"
                - entity: sensor.nodemcu_lounge_status
                  name: "${'Weather' + '\xa0'.repeat(13) + 'MQTT ' + vars[12] + '\xa0'.repeat(4) + 'WiFi ' + vars[13] + '\xa0'.repeat(3) + ((parseInt(vars[14]) / 2) - 100 ) + '\xa0' +  'dBm' + '\xa0'.repeat(3) + ( vars[14] >= 100 ? 'Excellent' : vars[14] >= 80 ? 'Good' : vars[14] >= 60 ? 'Fair' : 'Weak' )}"
                  icon: "${vars[14] >= 100 ? 'mdi:wifi' : vars[14] >= 80 ? 'mdi:wifi-strength-3' : vars[14] >= 60 ? 'mdi:wifi-strength-2' : 'mdi:wifi-strength-1' }"

image

Oh thanks that worked great!! Exactly what I was trying to do but you are way better the all the coding than I am.

Now I took what you had to work the device I needed it for but not getting a result am I doing it wrong? This is an manually entered card in the Lovelace UI on the dashboard so things maybe out of order some.

type: 'custom:config-template-card'
variables:
  - states['washer_monitor_sensor_status'].attributes['MqttCount']
  - states['washer_monitor_sensor_status'].attributes['WiFi LinkCount']
  - states['washer_monitor_sensor_status'].state
entities:
  - sensor.washer_monitor_sensor_status
card:
  type: 'custom:hui-entities-card'
  entities:
    - entity: sensor.washer_monitor_sensor_status
      name: "${'Washer' + '\_'.repeat(16) + 'MQTT ' + vars[0] + '\_'.repeat(4) + 'WiFi ' + vars[1] + '\_'.repeat(3) + ((parseInt(vars[2]) / 2) - 100 ) + '\_' + 'dBm' + '\_'.repeat(3) + ( vars[2] >= 100 ? 'Excellent' : vars[2] >= 80 ? 'Good' : vars[2] >= 60 ? 'Fair' : 'Weak' )}"
title: Washer Wifi Connections
show_header_toggle: false

Did you check your sensor has those status attributes? That is how my sonoff switches flashed with Tasmota have them.

Yeah it shows the attributes under the status part of the sensor. I am using Tasmata too on this Sonoff S31 plug. I renamed it for wifi strength but it should be all the attributes or am I missing something?

need to check you have the name right… if you do it will work… see here is my states for one of mine


See how that maps to the template in Lovelace

Ah found it type on my part. When I copied the sensor name it did not copy the “sensor.xxxxx” part. Awesome working great now. I can you pull up time off that attributes too, I see it there but how would you change the code to pull that?

Thanks a bunch for the help, you are the code master…lol

Just duplicate the format of the other attributes… Just remember var[0] is the first variable and there are 3 variables in my example for each sensor so thus var 0-2 so if you add another one it’s var[3] - just follow the format of the other ones.

Ok got it thanks