epiniguin
(Evgeny Pinigin)
June 25, 2022, 1:13pm
1
MQTT sensors do not have an icon_template attribute.
tom_l
June 25, 2022, 1:44pm
2
They do support device classes though.
What is your sensor, there may be a class that fits?
epiniguin
(Evgeny Pinigin)
June 25, 2022, 2:04pm
3
These are UV sensor and rain sensors: rain per hour(mm/hour) and rain for 24hours(mm).
I want to change an icon depending from the sensor state.
icon_template: >-
{% if value | float(0) > 0 %}
mdi:umbrella-outline
{% else %}
mdi:umbrella-closed-outline
{% endif %}
tom_l
June 25, 2022, 2:07pm
4
Ok, neither of those have a suitable device class.
Don’t forget to vote for your own request.
1 Like
fredck
(Fred)
November 27, 2023, 10:19am
5
For following feature request has been closed in 2019 by a bot:
opened 04:44PM - 30 Apr 19 UTC
closed 11:46AM - 07 Oct 19 UTC
integration: mqtt
integration: mqtt_template
stale
**Home Assistant release with the issue:**
0.92.1
**Last working Home Assist… ant release (if known):**
Related to 0.88 started to warn about extra keys not supported by the platform.
**Operating environment (Hass.io/Docker/Windows/etc.):**
hassio
**Component/platform:**
[MQTT Template sensor](https://www.home-assistant.io/components/sensor.mqtt/)
**Description of problem:**
Using the `icon_template` key still works, but throws a warning in the log.
```
Your configuration contains extra keys that the platform does not support.
Please remove [icon_template]. (See /config/sensors/system.yaml, line 35).
```
Functionality might break in the future? So, it is working as designed as the current MQTT Template Sensor does not provide a ```icon_template``` key.
However, the ability to change the icon dynamically based on received information over MQTT is very valuable. Using a separate template sensor is not a solution as the extracted attributes from payload do not transfer over to the template sensor.
Please add native support for `icon_template` to MQTT Template Sensor to prevent breaking change in the future.
**yaml example:**
```yaml
sensor:
- platform: mqtt
name: "Window Suggestion"
# Following line cause warning in log
icon_template: "{{ value_json.icon }}"
state_topic: "nodered/suggestion/window"
value_template: "{{ value_json.suggestion }}"
json_attributes_topic: "nodered/suggestion/window"
```
petro
(Petro)
November 27, 2023, 1:27pm
6
Well, this is where you put in feature requests, not in issues on github. Issues are for bugs.
Cyberbeni
(Benedek Kozma)
February 18, 2024, 12:14am
7
template.binary_sensor.icon supports templates
mqtt.binary_sensor.icon doesn’t
that seems like a bug
Here is a working version (just copy pasting stuff from template_entity.py): Comparing home-assistant:dev...Cyberbeni:mqtt-template-icon · home-assistant/core · GitHub
petro
(Petro)
February 18, 2024, 1:00am
8
Those are 2 separate integrations…
Cyberbeni
(Benedek Kozma)
February 18, 2024, 9:33am
9
The bug is that it is not defined in 1 place that any entity that you define in yaml has an icon attribute that accepts templates.
petro
(Petro)
February 18, 2024, 12:11pm
10
That’s not how the development in HA works. Sorry. Every integration implements it’s own functionality. This is a feature request. You’re welcome to argue me all you want, but that is the simple truth.
Secondly, if you implement json_attributes_template on your mqtt entity, you can provide a template for all attributes. If you include icon
, it’ll work just like an icon_template
.
Dan_Hajduk
(Dan Hajduk)
October 13, 2024, 9:23pm
11
Is there any news about this? icon_templete would be really nice to have for an MQTT device.