{"id":1166,"date":"2020-05-26T21:30:56","date_gmt":"2020-05-26T19:30:56","guid":{"rendered":"http:\/\/www.thelins.se\/johan\/blog\/?p=1166"},"modified":"2020-05-26T21:30:56","modified_gmt":"2020-05-26T19:30:56","slug":"photoframe-hack","status":"publish","type":"post","link":"https:\/\/www.thelins.se\/johan\/blog\/2020\/05\/photoframe-hack\/","title":{"rendered":"Photoframe Hack"},"content":{"rendered":"\n<p>Sometimes you just want to get something done. Something for yourself.<\/p>\n\n\n\n<p>You do not intend it to be reused, or even pretty.<\/p>\n\n\n\n<p>You build a tool.<\/p>\n\n\n\n<p>My tool was a photoframe with some basic overlays. I wanted the family calendar, some weather information (current temperature + forecast), time, and the next bus heading for the train station.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082112-1024x768.jpg\" alt=\"\" class=\"wp-image-1167\" srcset=\"https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082112-1024x768.jpg 1024w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082112-300x225.jpg 300w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082112-768x576.jpg 768w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082112-1536x1152.jpg 1536w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082112-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To make this acceptable in a home environment, I built it as a photoframe. You can find the sources in the <a href=\"https:\/\/github.com\/e8johan\/hassframe-ui\">hassframe-ui<\/a> repository on my github.<\/p>\n\n\n\n<p>A hidden feature is that if you tap the screen, a home automation control panel slides up. That way you can control all the lights, as well as heat in the garage and an AC in the bedroom. Very convenient.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082134-1024x768.jpg\" alt=\"\" class=\"wp-image-1168\" srcset=\"https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082134-1024x768.jpg 1024w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082134-300x225.jpg 300w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082134-768x576.jpg 768w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082134-1536x1152.jpg 1536w, https:\/\/www.thelins.se\/johan\/blog\/wp-content\/uploads\/2020\/05\/IMG_20200409_082134-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>All this is built using QML. Three somewhat useful models are available:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/e8johan\/hassframe-ui\/blob\/master\/IcalModel.qml\">IcalModel<\/a>, taking a URL and parsing whatever it gets back as ICAL data. It is a very naive parser and does not care about things such as time zones and other details.<\/li><li><a href=\"https:\/\/github.com\/e8johan\/hassframe-ui\/blob\/master\/YrWeatherModel.qml\">YrWeatherModel<\/a>, uses <a href=\"https:\/\/yr.no\">yr.no<\/a>&#8216;s <a href=\"https:\/\/hjelp.yr.no\/hc\/en-us\/articles\/360009342833-XML-weather-forecasts\">public APIs<\/a> to pull out a weather forecast for a given location.<\/li><li><a href=\"https:\/\/github.com\/e8johan\/hassframe-ui\/blob\/master\/BusStopModel.qml\">ButStopModel<\/a>, uses the APIs from resrobot to look for departures to the train station from two bus stops close to my home and then merge the results into a model.<\/li><\/ul>\n\n\n\n<p>I also have a bunch of REST calls to my local <a href=\"https:\/\/www.home-assistant.io\/\">home assistant<\/a> server. Most of these reside in the <a href=\"https:\/\/github.com\/e8johan\/hassframe-ui\/blob\/master\/HassButton.qml\">HassButton<\/a> class, but I also get the current temperature from there. These are hardcoded for my local network, so needs refactoring to be used outside of my LAN.<\/p>\n\n\n\n<p>All of these interfaces require API keys of one kind or another &#8211; be it a proper key, or a secret URL. These are <a href=\"https:\/\/github.com\/e8johan\/hassframe-ui\/blob\/master\/main.cpp#L32\">pulled from environment variables<\/a> in <code>main.cpp<\/code> and then exposed to QML. That way, you can reuse the components without having to share your secrets.<\/p>\n\n\n\n<p>All in all the code is quite hacky. Especially <code>main.qml<\/code>. I refactor out parts from there now and then, but the photoframe works, so its not anything that I prioritize.<\/p>\n\n\n\n<p>Currently it runs on a Raspberry Pi on top of Raspbian. I want to build an optimized Yocto image making it less hacky and more pre-packaged. Perhaps there will be a rainy day this summer and I&#8217;ll get around to it. Burkhard has prepared the <a href=\"https:\/\/www.embeddeduse.com\/2020\/05\/26\/qt-embedded-systems-1-build-linux-image-with-yocto\/\">instructions needed<\/a> over at <a href=\"https:\/\/www.embeddeduse.com\/\">embedded use<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you just want to get something done. Something for yourself. You do not intend it to be reused, or even pretty. You build a tool. My tool was a photoframe with some basic overlays. I wanted the family calendar, some weather information (current temperature + forecast), time, and the next bus heading for the &hellip; <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2020\/05\/photoframe-hack\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Photoframe Hack<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6,4,7,9],"tags":[],"class_list":["post-1166","post","type-post","status-publish","format-standard","hentry","category-embedded","category-linux","category-qt","category-raspberrypi","category-yocto"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/1166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/comments?post=1166"}],"version-history":[{"count":1,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/1166\/revisions"}],"predecessor-version":[{"id":1172,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/1166\/revisions\/1172"}],"wp:attachment":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/media?parent=1166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/categories?post=1166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/tags?post=1166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}