Setting device picture to local file

I just started using homeassistant, and I am loving it so far. I am trying to get started with presence detection using device tracker. I have successfully connected to my iPhone using iCloud. The documentation indicates that the known_devices.yaml configuration file accepts a URL for each device to be used as the entity picture. Is it possible to use a local file instead?

I tried setting the picture value in known_devices.yaml to the absolute file path to the image with no luck. Terminal outputs the following:

INFO:homeassistant.components.http:"GET /Users/Mafachu/Pictures/homeassistant/Mafachu.jpg HTTP/1.1" 404 -

I am running homeassistant on my Mac.

Thanks!

I found the solution to this. Local paths can be used by referring to /local/* which points to the /www/ subdirectory inside the homeassistant configuration directory:

# known_devices.yaml

mafachu:
  name: Mafachu
  mac:
  picture: /local/images/Mafachu.jpg
  track: yes
  hide_if_away: no

which points to:

/Users//.homeassistant/www/images/Mafachu.jpg

4 Likes

Good to know! I was thinking about this for my setup also.

Thank you for pointing this out, because it doesn’t seem to be documented obviously in the places one might expect.

In my case the only directory that seems to fit your description is /usr/local/lib/python3.4/site-packages/homeassistant/components/frontend/www_static/images/ and that doesn’t seem to work.

If you don’t happen to know the answer could you suggest where to look for this?

EDIT: you can create the www directory in .homeassistant if it’s not there.

For those of you wondering how to do this in Hass.io, you can simply create the www -folder in /config/ and refer to somefile.jpg under /config/www/somefile.jpg with as /local/somefile.jpg in the YAML config file.

I recommend creating separate folders for images and other resources under www.

3 Likes

So… I am trying to make this work in Hassio. I have a .png file created and saved in /config/WWW/heater.png.

I have tried both of the following in my customize.yaml:

switch.bathroom_heater:
  entity_picture: /local/heater.png
#  icon: /local/heater.png

The file is user/group/world readable as is the directory WWW. I get just a blank spot where the icon should appear.

Any ideas?

i have an entry that works, the picture lives in www as yours does above and my entry in customisations is :-
entity_picture: /local/acute_angle.png
have you played around with the picture ?
If so it may be your browsers cache, try clearing that out (ensure it’s for the last week or so (I got caught that way once, it only cleared the last 3 hours)
Also HA seems to put a vignetting mask over any picture so you only get a round image, would that affect what you are seeing ?
Mutt

I can live with the shape… I still cannot make it load, should I be able to call up the image on a web page from the hassio install? Something like www.house.com:8123/heater.png or www.house.com/heater.png?

It appears that the file is some how not visible to the system. Multiple reboots, file in /config/www with 777 perms.

http://192.168.1.6:8123/local/heater.jpg

returns a 404 error

The actual file location will not be viewable. Imagine the security implications.
So the actual file will either be hardcoded to www as an inclusion in the web server or mapped through from the python backend.
You have done everything correctly it should show.
The only thing I can think of is that your yam is off i.e. Spacing
Try multiple config customisations with different pics and see what you get, remember 2 space offsets
Mutt

I have it solved… Not sure what it was, may have been the WWW vs. www.

Thanks for the clues!

Now if it could only change colors when state changes.

image

Yeah … yaml is a sneaky barsteward that way, capitals not allowed anywhere, I should have spotted that but W looks very like w without context/easy comparison unlike (say) a and A
Well chalk that one up to experience
Mutt

I think the WWW vs www have to do with Linux file systems, unlike Windows, the file system considers wWw WwW www and WWW different paths, wherein Windows they would point to the same path.