[go: up one dir, main page]

Skip to content

trip5/ESPHome-eInk-Boards

Repository files navigation

ESPHome-eInk-Boards

These projects are meant to display Weather conditions or Tasks using various Home Assistant integrations on eInk Boards running ESPHome.

image image

Home Assistant

Sensors

The Devices rely on using template sensors. If you haven't split your configuration.yaml yet, now isn't such a bad time to start because this will add hundreds of lines!

Put this in your configuration.yaml:

template: !include template.yaml

Anything in configuration.yaml under the template: heading must now be moved to template.yaml. Take a quick look here for some examples on an easy way to format template.yaml.

WeatherBoard

My Weatherboard code if heavily derived from Madelena Mak's Weatherman Dashboard and even more so from Stephan Wijman's updates on his blog. Big thanks to both.

This relies on the OpenWeatherMap integration to function. In its unedited form, requires 1 service: openweathermap (it seems onecall_daily and onecall_hourly are not relevant anymore). Read more about that here.

The simple YAML uses 2-hour increments to the hourly forecast but this is adjustable by variables. There are also notes in the code about how to change the datestamp if you don't prefer the formats I use. Other than those 2 points, there should not be much editing of the code to make it functional. Except, of course, for the waketimes. See the notes below and in the yaml.

HomeAssistant_template_weather.yaml

The dynamic YAML can use any times ahead of the current time (ie after midnight until 6am you can display hourly weather for 9 am, 12 noon, 3 pm, and 6pm). You may want to edit the times. Which days shown for the daily forecast are also dynamic.

HomeAssistant_template_weather_dynamic.yaml

Please note that in both versions, titles are now editable. Be sure your ESPHome YAML the characters you use are defined in the fonts section.

TasksBoard

This code is inspired by the above code but is dramatically different in many ways.

This uses Home Assistant's inbuilt todo lists as a base. Start with the shopping list if you must here. It can also use the official Google Tasks integration. Read more here. It can also use the official Google Calendar integration. Read more here. And of course, it can very likely use other integrations as well. I'd encourage you if you figure out how, to post your solution somewhere so you can help other people!

Unlike the WeatherBoard code, you will need to carefully edit certain sections of this to match what integrations you use, and the names of the lists and calendars you wish to appear, and how. Notes in the Jinja code look like this: {# comment #} and should be pretty helpful.

Certain events like holidays (which are pulled from a calendar), I wish only to appear on the top TO DO and never in UPCOMING, while other things will appear in UPCOMING but never in TO DO. Some things are pulled from certain to do lists and you may wish the board to indicate which list it's from (ie. "Check Oil" on the "Car Tasks" list may appear as "Car: Check Oil" on the board).

Please note my preferred time_pattern is every 3 minutes. It takes 2 runs to completely populate all the sensors. That means 6 minutes total. Keep that in mind if you decide to increase the value. Also, although it's not too intensive on the machine, it certainly isn't no work at all, so if your machine is weak (like a Pi), you may wish to increase the time.

Also, keep in mind that Home Assistant reloads Google Tasks and Calendar data every 15 minutes so in theory it could take 29 minutes for items to sync to HA. So if running a waketime at midnight or shortly after, today's TO DO may not be ready yet. Sidenote that you can reload todo lists and calendars manually with the service homeassistant.reload_config_entry if needed.

HomeAssistant_template_tasks.yaml

Waketimes

Companion to the data sensors above (and included in the YAMLs) are the Waketime sensors. The ESPHome will use deepsleep mode to preserve battery life. As long as deepsleep is enabled (ie. not specifically disabled by the Helpers), the devices will enter deepsleep (using almost no power) in-between screen refreshes. I have not tested the 10000mAh batteries fully but I expect for them to last about a year on a single charge.

Each of these sensors starts with a variable section wherein the daily wakeup schedule is entered as a list. Edit, remove, add lines like this {%- set waketimes = waketimes + ["00:05"] %} as you need to. Home Assistant will update an attribute of this sensor every minute with a calculation of how many seconds there are between the current time and the next wake time. Because this sensor is only updated every minute, the board will not be 100% accurate regarding its wakeup schedule, usually waking up about a minute earlier than expected. Also, the weather data sensor is only run every 5 minutes so if the board wakes up on the hour, the hourly forecast may not be entirely ready (this is why all the weatherboard wake times actually end with :05).

The thing to keep in mind here is that although the wakeup schedule is controlled by Home Assistant, the device will not be aware of the next wakeup time until it actually wakes up again. If, for some reason, you reset the device (ie. by pulling the battery or pressing the BOOT button the ESP32), the board will update immediately and refresh the display and go back to sleep until it's next scheduled wakeup time according to whatever number of seconds Home Assistant has calculated for it.

Helpers

Create two helpers in the Devices & Services for each device. These below names are how I use them in the ESPHome YAML later but you can (of course) use other names but be sure to edit the ESPHome YAML to match your sensor names.

The Disable Deep Sleep helper may be used to keep the ESP board from entering deep sleep mode. Useful for calibrating the battery or if you are planning on running from USB power.

The Disable Update helper is used to avoid screen refreshing. It is useful to have an automation turn it on and off, depending on who is home (no point in wasting a screen refresh if no one will see it).

WeatherBoard

input_boolean.eink_weatherboard_disable_deep_sleep
input_boolean.eink_weatherboard_disable_update

TasksBoard

input_boolean.eink_tasksboard_disable_deep_sleep
input_boolean.eink_tasksboard_disable_update

ESPHome

WeatherBoard

Because the YAML has plenty of notes scattered throughout it, I won't waste space here. Go through the YAML carefully and edit it according to your needs.

ESPHome_eink-weatherboard.yaml

TasksBoard

A note here that the list is somewhat dynamic. As more TO DO tasks are displayed, the UPCOMING list is pushed further down and will not attempt to display items that do not fit. If no TO DO items are available, it will have a default "Nothing today!" message that you may wish to edit. Again, there are plenty of notes scattered throughout the YAML so check it carefully.

Please note that you may see a missing glyph (always a black box ■) on your board. The solution is quite simple. Add the character to the glyphs lists in the ESPHome YAML. If you see an unknown character glyph (in the Gotham-Round fonts similar as ☒) instead, it means the font is missing that character. The solution is to either change the font, avoid using the character, or ignore it. For example, I have defined the South Korean Won currency symbol (₩) even though it is not present in the font. I'd rather see the ☒ instead of ■. Please note that I'm pretty sure Pillow (the element of ESPHome uses to encode characters into pictures) limits the number of glyphs. I believe it's 255.

ESPHome_eink-tasksboard.yaml

Building

Materials List

Waveshare E-Paper ESP32 Driver Board

image

image

When using most larger, newer displays, the switches should both be in the ON position. Check the specs to be sure. I also recommend removing the PWR LED with a blob of solder. It stays on, even when the device is in deepsleep mode. It isn't controlled by a GPIO.

Here's how to open the connector: lift up the darker lever with your fingernail (be gentle). To close it again, push down gently.

image

Power Board

image

This board is used to allow the ESP32 to monitor the battery power as well as make disconnecting the ESP32 Board and battery easy.

The board allows battery monitoring by connecting a 33K resistor between the 5V input pin and the ADC pin (GPIO34) and then a 100K resistor from ADC to ground. I also added a 1000uF capacitor between the 5V pin and ground. This seems to help ESP32s that may have trouble booting from a sagging battery. And of course, battery connections to the 5V input pin and ground.

The sockets are extras included with D1 Minis but I'm sure any sockets that have a 2.54 pitch will work fine. I also pulled out every pin next to a used pin in the sockets, mostly because on my first attempt, I shorted 5V to CMD which resulted in the board not booting. I left about 4 of 8 pins intact for stability.

A lot of the connections are made under the board by using the legs of the resistors and capacitors to meet the ends of the socket pins (which were then clipped and soldered to make them roundish). I used half of a resistor leg to hold the battery connector lead in place.

Charger

image

So simple, right? This allows you to check the approximate power of your battery as well as charging it. It's molasses-in-January speed charging but it works and it's extremely safe, simple, and compact. I doubt anyone will do something so silly as this but I'm including it to show my own preference. It is held together by 2-stage epoxy glue.

Alignment

image

First you'll need to align the display. The ESPHome YAML includes some rectangles you can uncomment to get some alignment rectangles. Line it up as such and then carefully flip it and put some masking tape down to keep it that way. Nevermind how the font looks in this picture. I was testing the OTF version of the fonts... TTF files are better.

Building

image

Carefully remove all the extra hooks and stand from the backboard. Then use a knife to make a cutout in the backboard a bit larger than the ESP32 board. This allows the power board to sit under the backboard and keep the ESP32 in place. A small cutout in the center at the bottom will allow the board to be removed and get around the D-ring that will be screwed in. The D-rings are about 1cm down and it's recommended to put the D-rings in the frame before continuing and make sure this backboard can be removed easily. Otherwise, the D-rings will lock the backboard in place. Also, drilling the holes for the D-rings can make dust that can easily work its way in between the e-ink screen and the clear plastic. Use a dust-blower if you can.

image

The stand that you took off the backboard can be used as shims to keep the e-ink screen and matte aligned inside the frame itself. Flip it around and check it's straight before taping it all down. I used 3M 233+ automotive tape because it seems to stick pretty well. Scotch tape and box tape are not recommended here.

This also allows the power board so some space so it isn't squished in-between the e-ink screen and the backboard. I also put some sticky felt down to keep the bottom pins of the power board from scratching the back of the e-ink screen. If you don't have felt, I recommend corrugated cardboard or thin foam.

image

The power board should fit about here.

image

Here's where everything finally comes together. The triangle shape of the paracord holds that big 10000mAh battery in place pretty well. There's a clear shot of the "showlace tightener" I use to pull the paracord tight. Also you can see a white bit cut out of what used to be the spacer at the front of the frame. This allows that bit to protect the battery from the screw heads and also the ability to take everything apart without removing the D-rings.

image

Later... I ended up using epoxy glue on velcro because sticky velcro tape doesn't stick to MDF board well (and super glue just soaks into the MDF). You could use masking tape to hold down the cable, too. I also ended up using picture hanging wire twisted tight around the top 2 D-rings. It's secure enough.

Update History

Date Release Notes
2024.08.10 Titles & daily forecast now possible to be dynamic
2024.08.04 Added the dynamic Home Assistant Weatherboard Template, added variables to both
2024.07.14 Fixes to ESPHome OTA & how sensors reported to HA
2024.05.25 First release

Download Gotham-Rounded Fonts (from this Github)

Gotham-Rounded-Book

Gotham-Rounded-Bold

Gotham-Rounded-Medium

Download MaterialDesign-Webfont (from Templarian's Github)

MaterialDesign-Webfont

Useful Links

The Waveshare E-Paper ESP32 Driver Board: https://www.waveshare.com/wiki/E-Paper_ESP32_Driver_Board

A long, ongoing thread regarding support for 3-color displays in ESPHome: esphome/feature-requests#239

Madelena Mak's Weatherman Dashboard : https://github.com/Madelena/esphome-weatherman-dashboard

Stephan Wijman's Weatherframe: https://blog.wijman.net/e-ink-weather-frame-with-esphome-and-home-assistant/

How to use the "new" way to call services in dev tools: https://community.home-assistant.io/t/debugging-templates-and-service-response-variables/617997

Paviro's ESPHome ePaper Calendar: https://github.com/paviro/ESPHome-ePaper-Calendar