Custom icon in MQTT switch

Hi, I have just started using HA…what a great project! Thanks for starting it! I’m using a Controllino (a PLC based on Arduino) to control light/rollers in my home. I was able to connect controllino with HA using MQTT following the examples and tutorials. Everything work fine.

Now I’d like to customize the icon of the MQTT switches and I have tried something simialr:

switch:
 - platform: mqtt
   name: "R0"
   state_topic: "home/notte"
   command_topic: "home/notte/R0"
   payload_on: "1"
   payload_off: "0"
   optimistic: true
   retain: true
   icon: mdi:kettle

but it doesn’t work, when I include the last row “icon: …” all the mqtt switches disappear from the view and in the log file I found:

16-05-20 14:51:51 homeassistant.bootstrap: Invalid config for [switch.mqtt]: [icon] is an invalid option for [switch.mqtt]. Check: switch.mqtt->icon.

Any hint on how to set a custom icon for a MQTT switch? Is it possible?
Thanks for any comments!
Luigi

Hi,

I think you need customize your frontend with the term customize like that

switch:
- platform: mqtt
name: "R0"
state_topic: "home/notte"
command_topic: "home/notte/R0"
payload_on: "1"
payload_off: "0"
optimistic: true
retain: true

customize:
  switch.R0
     icon: mdi:kettle
     friendly_name: mySwitch

I hope that it will be helpful for you.
Regards

Have a look here:

1 Like

Ok thanks, I overlooked that the “customize:” section has to go under the “homeassistant:” section. Now with this properly set it works fine. Anyhow, it seems not possible to specify the “icon:” field within the switch element. Thanks for the support

Luigi

Did you try entity_picture instead? Icons should work in switch elements; the example page actually shows them in use. But you could also try the entity_picture property.

Hi Luigi, it’s not right to the topic but can you please help me with Controllino connection to HA? Where did you find the examples and tutorials? Thanks