{"id":2221,"date":"2023-02-27T09:58:19","date_gmt":"2023-02-27T15:58:19","guid":{"rendered":"https:\/\/lab.rapternet.us\/?p=2221"},"modified":"2023-02-17T17:51:42","modified_gmt":"2023-02-17T23:51:42","slug":"home-assistant-picture-elements-card","status":"publish","type":"post","link":"https:\/\/lab.rapternet.us\/?p=2221","title":{"rendered":"Home Assistant Picture-Elements Card"},"content":{"rendered":"\n<p>I&#8217;ve seen the picture elements cards in home assistant dashboard screenshots from time to time and was always interested into how they did it. Digging into it, as with most things home assistant, it&#8217;s pretty easy to do, and of course can be as complex as you see fit. Here I&#8217;ll be setting up a simple picture elements card for my air quality sensors.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>The home assistant picture elements cards require a link to a picture, so it can&#8217;t just be a picture local to your home assistant setup, it also needs to be externally accessible and linkable. To do this, we first need to setup the www folder in home assistant. This folder can be created in VS Code as shown below. It is in the root directory of the configuration folder.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"1024\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2022\/12\/image-527x1024.png\" alt=\"\" class=\"wp-image-2222\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2022\/12\/image-527x1024.png 527w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2022\/12\/image-154x300.png 154w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2022\/12\/image.png 612w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><figcaption class=\"wp-element-caption\">Created folder and Test File in VS Code<\/figcaption><\/figure>\n\n\n\n<p>Once the www folder is created, home assistant needs to be restarted. For this I just rebooted the VM I have running it. Images can be uploaded to the folder using VS Code as well, just drag and drop in the folder. Once they&#8217;re in the folder, they can be accessed externally as shown (case does matter).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">then can access your hass.local:8123\/local\/image-name.PNG<\/pre>\n\n\n\n<p>Now that the images are uploaded, you can create the picture elements card with the image, and start adding sensors or UI elements to the image. This is all done in YAML, and locations are in % on the image so things scale well between devices. Below is my air quality sensor picture elements card. This positions a number of sensors around a floor plan of my house.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">type: picture-elements<br>elements:<br>  - type: state-badge<br>    title: ''<br>    entity: sensor.particulate_matter_2_5um_5<br>    style:<br>      top: 30%<br>      left: 15%<br>  - type: state-badge<br>    title: ''<br>    entity: sensor.particulate_matter_2_5um_4<br>    style:<br>      top: 20%<br>      left: 80%<br>  - type: state-badge<br>    title: ''<br>    entity: sensor.particulate_matter_2_5um_2<br>    style:<br>      top: 70%<br>      left: 25%<br>  - type: state-badge<br>    title: ''<br>    entity: sensor.particulate_matter_2_5um<br>    style:<br>      top: 75%<br>      left: 65%<br>image: http:\/\/192.168.1.254:8123\/local\/upstairs-electrical.PNG<br><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>This worked really well for visualizing the airflow and air quality around my house. This makes it far easier to see what&#8217;s going on that a list of sensor outputs in the UI (even with them all named for their rooms).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.home-assistant.io\/dashboards\/picture-elements\" data-type=\"URL\" data-id=\"https:\/\/www.home-assistant.io\/dashboards\/picture-elements\">Picture Elements Documentation<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve seen the picture elements cards in home assistant dashboard screenshots from time to time and was always interested into how they did it. Digging into it, as with most things home assistant, it&#8217;s pretty easy to do, and of course can be as complex as you see fit. Here I&#8217;ll be setting up a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lab.rapternet.us\/?p=2221\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Home Assistant Picture-Elements Card&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[39,14,49],"class_list":["post-2221","post","type-post","status-publish","format-standard","hentry","category-how-to","tag-home-assistant","tag-quick-bites","tag-smart-home"],"_links":{"self":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2221"}],"version-history":[{"count":7,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2221\/revisions"}],"predecessor-version":[{"id":2763,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/2221\/revisions\/2763"}],"wp:attachment":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}