Entity_picture file format

Hi.
When i try to use a local file for the entity picture of a switch:

switch.nodon_msp31xx_micro_smart_plug_switch:
  friendly_name: nodon Remote Switch
  entity_picture: /local/nodon3.jpg

No image is displayed.
What are the requirements/restrictions for the format of the image?

Thanks in advance.

most importantly: place the file in the correct folder, or put differently: reference the correct folder you place the file in.
You’re sure you placed the file in /config/www/ ?

.jpg is displayed without issues. Might have to crop if the file is too large, otherwise you should be alright

Thanks for the reply.
must be onto something here, since i don’t have a www folder in my homeassistant installation.
(I have a virtual environment under a raspbian setup.)

Create one.

go to /home/homeassistant/.homeassistant and create a www folder under that directory.

Done. Still no joy. jpg is 295x288 pixels. Is this too big?

My bad, I thought you were trying to change the entity-picture of an item in lovelace…

What is your purpose? Do you want to change the picture of a switch?
if yes, then you must create a new template switch based on this one:

Nope, not lovelace but yes a button . Ok thanks, I’ll give it a try.

no need to create a template switch, you can simply customize if you desire to do so.

35

Do you want to change the picture in on and off states?

That would be a bonus! To illustrate what I’m trying to achieve a little better, this is what the switch looks like as standard:
2018-11-19%2014_43

And this is what happens when I try the customization in my first post:
2018-11-19%2014_40

I have a jpg of the actual switch which I would like to appear instead of the blue ‘lightening’ symbol.

ok, do you have custom-ui installed?
if so you can simply use this for starters, and use any mdi:icon you desire.

switch.sw_tv_auditorium_template:
  templates:
    icon: >
      if (state === 'on') return 'mdi:television';
      return 'mdi:television-off';

like this in frontend for On:

15

and Off:

22

this uses a few more options from custom-ui, but Im just showing what’s possible with a few lines of Yaml, and not have to create extra entities.

switch.sw_audio_auditorium_template:
  templates:
    icon: >
      if (state === 'on') return 'mdi:music';
      return 'mdi:music-off';
  show_last_changed: true
  confirm_controls_show_lock: true
  extra_badge:
    - entity_id: sensor.audio_auditorium_actueel
    - entity_id: sensor.audio_auditorium_totaal

you can change the default icon for a switch by using assumed_state: false.

Ok, so far so good. (Thanks guys!)
Got the jpg file to be shown instead of the stock symbol icon, (was a typo creating the www directory :roll_eyes:) but it seems to be truncated/trimmed to be a circular image instead of the square original. Is it possible to do anything about that?

I don’t have custom-ui installed (not that experienced with home assistant yet) but I can see the possibilities it offers

no that’s not possible. You can however shrink the file to a size you’re happy with when HA shows he circular cutout.

I always look for transparent .png files, or create them from my .jpg’s so HA can show them nicely in whichever theme you’re using, and no ugly whitespace is displayed when the picture doesn’t exactly fit

ok, good tip.
Many thanks for the help :slight_smile:

I can’t find the docs that specify hte format or limits for the image, but I think 295x288 is too big.
If you look at the base icons, they all come from http://materialdesignicons.com , they are on a much smaller scale.