TheStigh
(TheStigh)
February 13, 2020, 7:58pm
1
Hi,
Have a MQTT sensor with a value (in this case -99)
Tried this in dev-template and it works.
{% set rssi_level = states("sensor.mate_30_pro_rssi_level")|float %}
{% if rssi_level == -99 %}
mdi:sim-off
{% else %}
{% if rssi_level >= -90 %}
mdi:signal-cellular-outline
{% elif rssi_level > -60 %}
mdi:signal-cellular-1
{% elif rssi_level > -30 %}
mdi:signal-cellular-2
{% else %}
mdi:signal-cellular-3
{% endif %}
{% endif %}
Completed the sensor setup:
- platform: mqtt
name: Mate 30 Pro RSSI Level
state_topic: "monitor/stue/monitor_stigh_mate30/rssi"
icon_template: >-
{% set rssi_level = states("sensor.mate_30_pro_rssi_level")|float %}
{% if rssi_level == -99 %}
mdi:sim-off
{% else %}
{% if rssi_level >= -90 %}
mdi:signal-cellular-outline
{% elif rssi_level > -60 %}
mdi:signal-cellular-1
{% elif rssi_level > -30 %}
mdi:signal-cellular-2
{% else %}
mdi:signal-cellular-3
{% endif %}
{% endif %}
…then the entire sensor fails…
Can’t figure out what is wrong
petro
(Petro)
February 13, 2020, 8:01pm
2
chnage float to int. Other than that, it looks good. But… just looked at the docs and it looks like icon_template isn’t a valid field for mqtt sensors. So that’sprobably your problem.
2 Likes
jocnnor
(Jim O'Connor)
February 13, 2020, 8:04pm
3
Was just about to hit the reply button saying the same thing as you…again.
@TheStigh Leave your MQTT sensor as is and create a template sensor if you want a template_icon. You can use the mqtt sensor for the majority of the template sensor fields.
petro
(Petro)
February 13, 2020, 8:04pm
4
Hah, I was just giving you shit the other day, don’t worry about it
1 Like
TheStigh
(TheStigh)
February 13, 2020, 8:04pm
5
Hi @petro ,
Of course it’s you answering first Happy you’re around!
Hummm… perhaps just make a new template sensor of this sensor then?
TheStigh
(TheStigh)
February 13, 2020, 8:05pm
6
Haha, was typing to petro when you replied … yeap, I will.
petro
(Petro)
February 13, 2020, 8:07pm
7
Actually, just change the device class to signal_strength
device_class: signal_strength
should change the icon without the need to create the template.
1 Like
TheStigh
(TheStigh)
February 13, 2020, 8:18pm
8
@petro , supported by mqtt platform?
petro
(Petro)
February 13, 2020, 8:19pm
9
Yep, every sensor supports device_class
1 Like
TheStigh
(TheStigh)
February 13, 2020, 8:20pm
10
- platform: mqtt
name: Value Mate 30 Pro RSSI Level
device_class: signal_strength
state_topic: "monitor/stue/monitor_stigh_mate30/rssi"
Testing - rebooting now
TheStigh
(TheStigh)
February 13, 2020, 8:46pm
11
Using device_class, give it full signal at -99
Will restart my monitor-service and see when it actually connects…
TheStigh
(TheStigh)
February 14, 2020, 12:55am
12
@petro , @jocnnor
It kind’a works, but the negative value might cause the issues…
I never get the signal bar to increase, whatever the value is.
I’ve also tried to re-arrange the order, having -90 at the top.
I’m also uncertain if I say >= -90
what is bigger? -80 or -100 ? In my mind -80 is bigger than -90…
Any ideas?
- platform: template
sensors:
monitor_mate_30_pro_rssi_stue:
friendly_name: Mate 30 Pro RSSI Stue
unit_of_measurement: 'dBm'
value_template: '{{ states("sensor.value_mate_30_pro_rssi_stue") }}'
icon_template: >-
{% set rssi_level = states("sensor.value_mate_30_pro_rssi_stue") | int %}
{% if rssi_level == -99 %}
mdi:sim-off
{% else %}
{% if rssi_level >= -20 %}
mdi:signal-cellular-3
{% elif rssi_level >= -40 %}
mdi:signal-cellular-2
{% elif rssi_level >= -65 %}
mdi:signal-cellular-1
{% elif rssi_level <= -90 %}
mdi:signal-cellular-outline
{% else %}
{% endif %}
{% endif %}
jocnnor
(Jim O'Connor)
February 14, 2020, 1:16am
13
You have a gap from -90 to -65 where the template will return nothing.
icon_template: >-
{% set rssi_level = states("sensor.value_mate_30_pro_rssi_stue") | int %}
{% if rssi_level == -99 %}
mdi:sim-off
{% else %}
{% if rssi_level >= -20 %}
mdi:signal-cellular-3
{% elif rssi_level >= -40 %}
mdi:signal-cellular-2
{% elif rssi_level >= -65 %}
mdi:signal-cellular-1
{% else %}
mdi:signal-cellular-outline
{% endif %}
{% endif %}
1 Like
TheStigh
(TheStigh)
February 14, 2020, 1:21am
14
Still, even if the signal are between -20 and -40 I never get other icon than mdi:signal-cellular-outline
Can it be that it doesn’t read correctly what’s inside the if’s ?
Can it be the negative value ?
jocnnor
(Jim O'Connor)
February 14, 2020, 2:26am
15
I assume so…it all works fine in the template editor with negative values.
Try adding:
entity_id:
- sensor.value_mate_30_pro_rssi_stue
I don’t know what to say. It all seems right to me…
1 Like
TheStigh
(TheStigh)
February 14, 2020, 8:26pm
16
Resolved Thnx @jocnnor and @petro
One of the sensor consist of
- platform: mqtt
name: Value Mate 30 Pro RSSI Stue
device_class: signal_strength
state_topic: "monitor/stue/monitor_stigh_mate30/rssi"
- platform: template
sensors:
monitor_mate_30_pro_rssi_stue:
friendly_name: Mate 30 Pro RSSI Stue
unit_of_measurement: 'dBm'
value_template: '{{ states("sensor.value_mate_30_pro_rssi_stue") }}'
icon_template: >-
{% set rssi_level = states("sensor.value_mate_30_pro_rssi_stue") | int %}
{% if -1 > rssi_level > -30 %}
mdi:signal-cellular-3
{% elif -31 >= rssi_level > -50 %}
mdi:signal-cellular-2
{% elif -51 >= rssi_level > -70 %}
mdi:signal-cellular-1
{% elif -71 >= rssi_level > -98 %}
mdi:signal-cellular-outline
{% else %}
mdi:signal-off
{% endif %}
petro
(Petro)
February 14, 2020, 8:27pm
17
fyi according to most things I’ve read about RSSI, anything better than -50 is ‘the most bars’.
TheStigh
(TheStigh)
February 14, 2020, 8:30pm
18
Well, such short distances in this house, so I kind of wanted full bars on very high signal.
Next task will be to make a math calculation to find out what room you are in.
It is possible, theoretically to be connected to all monitors (4 pcs), so to have a sensor showing what room you actually are in should be a calculation.
1 Like
jocnnor
(Jim O'Connor)
February 14, 2020, 8:33pm
19
Triangulation using wifi access points…love it!