Thomas shares makes


lighting scene / mood control proof of concept

twatch running lighting scene selector

Lilygo twatch 2020 running simple lighting scene (mood) control proof of concept

I discovered a lovely smart watch development platform; the Lilygo t-watch 2020. It's an ESP32 based hackable watch, with a small capacitive touch display.

I had already played with the idea of building a small home automation control and status display that fits into the existing switch cover plate, so clicked the order button and leveraged the open source watch firmware to quickly hack together a proof of concept.


I created a small demonstration video to show you how it works.

The user interface features 5 tiles, each showing the icon of a scene, as a vertical list. You can navigate the list by swiping the UI up and down. The active lighting scene is highlighted in bright green (same color scheme as my main home automation touchscreen). Activating a scene can be done by ticking it.

The state of the control is synchronised with home assistant via MQTT.

The watch

Watch hardware

The watch features everything to make it a good remote control, except perhaps battery capacity. It's a bit small to use as such, but perhaps a bar shaped enclosure and larger lithium battery could fix that.

twatch features

Lilygo twatch 2020 feature sheet

Stock firmware

The stock firmware codebase that comes with the watch is pretty nice, it features

  • A modular codebase
  • use of the Arduino framework
  • platformio configuration files
  • use of libraries to make all hardware work
  • use of the embedded Light and Versatile Graphics Library as GUI toolkit
  • Example applications

Mechanical integration

I hope to integrate the display into a blind faceplate.

twatch running lighting scene selector

90's niko switchplate formfactor

I'm aiming for the more modern cover plates, which should be possible. But fitting it in the older (1990's style?) plates will be easier since it won't require removing the display from the chassis.

Niko wall socket

Modern Niko wall socket

I tried to remove the display panel from the watch a few times by applying heat to soften the glue. This is how smartphone glass panels are removed. That did not work with the amount of heat I dared applying. At least I didn't burn the display.

Proof of concept development

I pushed the hacked watch firmware to in case you want to have a look or replicate this.

As of 2020/12/24, it can be called 'proof of concept', with these issues still present:

  • The watch still sleeps, and after waking it up, it has to reconnect to WiFi and the MQTT broker
  • you can still uncheck the icons (implemented as checkable image buttons).
  • the green color (state indicator) (as server updates are received) is not reflected on the icons

Adding icon images

I have 5 lighting scenes, and each has an associated icon.

spotlight png

track-light icon converted to png and bucket-filled to white

I followed these steps to get them into the firmware

  • download the SVG vector art from the material design icons website
  • import into gimp at 180x180 resolution
  • bucket-fill the black parts to white
  • export as png
  • use img_conv.core.php to convert it to a c array
  • change the include "../lvgl/lvgl.h" line to include "lvgl/lvgl.h"

I used to convert the images to LVGL-supported C arrays:

php img_conv_core.php "name=book_open_page_variant&img=book-open-page-variant.png&format=c_array&cf=true_color_alpha"

development testing

to verify the watch sends status updates

mosquitto_sub -h hass -u mqtt -P mqttpass  -t twatch -v
mosquitto_pub -h hass -u mqtt -P mqttpass -t twatch -m "TV"

Integration with Home Assistant

I created two automations in Home Assistant that feed back the state of the watch UI and the state of the input_select to each other.

- alias: moodliving_mqtt_out
  - platform: state
    entity_id: input_select.mood_living
    service: mqtt.publish
      topic: "twatch"
      payload: "{{ states('input_select.mood_living') }}"
- alias: moodliving_mqtt_in
    - platform: mqtt
      topic: "twatch"
    service: input_select.select_option
      entity_id: input_select.mood_living
      option: "{{ trigger.payload }}"

Existing opensource touch UI's

If I were to take this project to the next level, building upon the work of existing open source home automation projects is essential.

ESPHOME firmware

I already use ESPHome a lot, for my standing desk tracking, LED strip lighting. It's a project that leverages code generation to enable a lot of sensors and actuators to work with DIY hardware.

ESPHome already supports graphical displays, and it would require adding LVGL support and support for generating templates with LVGL instructions to generate UI's.

HASP Home Automation switch plate

HA SwitchPlate is an established project that uses Nextion human-machine interface (HMI) modules together with ESP micro's to build a touchscreen. The UI's look a bit dated and setting it up quite involving.

HASP Open Hardware edition is a fork that gets rid of the proprietary touchscreen modules and uses the LVGL as well.

Liked something? Worked on something similar? Let me know what you think on Mastodon!
You can use your Mastodon account to reply to this post.

Reply to post

You can respond to this post with an account on the Fediverse or Mastodon. Since Mastodon is decentralized, you can use your existing account or create your account on a server of your choice.

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

Learn how @carlschwan wrote the code that loads Mastodon posts into this webpage here.

Follow me on Mastodon!