I have 2 snmp sensors set up to read out the modem state of my LTE router (easy 1 or 0) and to read out the cell technology (2g, 3g, LTE).
I already have a template set up (no earthly idea how I figured it out though, I am still working on it) to translate the cell tech numbers to readable format as so:
friendly_name: "Cell Technology"
value_template: >-
{% set mapper = {
'0' : 'Disconnected',
'1' : 'Disconnected',
'2' : '2 GPRS',
'3' : '3 Edge',
'4' : '4 UMTS',
'5' : 'HSDPA+',
'6' : '6 3G HSDPA',
'7' : '7 3G HSUPA',
'8' : 'LTE' } %}
{% set state = states.sensor.wr11_wan_tech.state %}
{{ mapper[state] if state in mapper else 'Disconnected' }}
icon_template: >-
{% set mapper = {
'0' : 'mdi:signal-off',
'1' : 'mdi:signal-off',
'2' : '2 GPRS',
'3' : '3 Edge',
'4' : '4 UMTS',
'5' : 'HSDPA+',
'6' : '6 3G HSDPA',
'7' : '7 3G HSUPA',
'8' : 'mdi:signal-cellular-3' } %}
{% set state = states.sensor.wr11_wan_tech.state %}
{{ mapper[state] if state in mapper else 'mdi:signal-off' }}
But whenever the modem disconnects, the last cell tech persists so I’d love to find out how to set up a template that shows the cell tech text if the modem is connected and displays “Disconnected” when the modem is disconnected.
As a bonus I’d love it if the icons could be yellow when connected and grey when the modem is disconnected.
Many thanks for the help!