Installing ESPhome on GEEKMAGIC Smart Weather Clock (smalltv/pro)

Just want to say thanks to everyone! With your shared stuff I mixed up my first output on a geekmagic pro! Its a very basic output and it just shows 3 sensors.

  1. Current available solarpower (unused)
  2. Current power from landline
  3. Home Battery in %

Also you can tap on the touch area and the backlight will cycle through different brightness states.

I had some struggle to get esp home running in the first place, because web esphome was not able to connect, although it showed the device online. Finally I was able to flash a base image (legacy bin file) through the web interface of the stock firmware, which I quickly generated in homeassistant esphome. Now I can update wireless through homeassistant.

In case someone want to reuse my current progress, here is the code. I will now try to make it look nicer and make more use of the touch interface.

esphome:
  name: geektv
  friendly_name: GeekTV
  min_version: 2024.11.0
  name_add_mac_suffix: false
  on_boot:
    then:
      - light.turn_on:
          id: back_light
          brightness: 1.0
  #  - delay: 5s

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  baud_rate: 0

# enable web server
web_server:
  version: 3

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  - platform: esphome
    password: ""

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Geektv Fallback Hotspot"
    password: ""

captive_portal:


debug:
  update_interval: 5s

text_sensor:
  - platform: debug
    device:
      name: "Device Info"
    reset_reason:
      name: "Reset Reason"



# Define a PWM output on the ESP32
output:
  - platform: ledc
    pin: GPIO25
    inverted: True
    id: backlight_pwm

# Define a monochromatic, dimmable light for the backlight
light:
  - platform: monochromatic
    output: backlight_pwm
    name: "Display Backlight"
    id: back_light
    restore_mode: ALWAYS_ON
    on_turn_on:
      - light.turn_on:
          id: back_light
          brightness: 1.0  # Set initial brightness to 100% on power up

esp32_touch:
  # setup_mode: true

binary_sensor:
  - platform: esp32_touch
    name: "Touch Button"
    pin: GPIO32
    threshold: 1250
    id: gp32
    filters:
      # Small filter, to debounce the spurious events.
      - delayed_on: 10ms
      - delayed_off: 10ms
    on_click:
    - min_length: 10ms
      max_length: 500ms
      # Short touch to cycle through brightnesses
      then:
        - lambda: |-
            int current_brightness = id(back_light).current_values.get_brightness() * 100;
            current_brightness += 18;
            if (current_brightness > 100) {
              current_brightness = 5;
            }
            // Store the brightness value for later use
            id(current_brightness_variable).publish_state(current_brightness);
        - light.turn_on:
            id: back_light
            brightness: !lambda 'return id(current_brightness_variable).state / 100.0;'
        - logger.log: 
            level: info
            format: "Touch ON"
    - min_length: 500ms
      max_length: 2000ms
      then:
        - logger.log: "Long Touch"

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  interface: hardware
  id: spihwd

display:
  - platform: ili9xxx
    id: lcd_display
    model: st7789v
    spi_id: spihwd
    data_rate: 40MHz
    dc_pin: GPIO02
    reset_pin: GPIO04
    spi_mode: MODE3
    dimensions:
      width: 240
      height: 240
      offset_height: 0
      offset_width: 0
    invert_colors: true
    auto_clear_enabled: false
    update_interval: never

lvgl:

  log_level: INFO
  color_depth: 16
  bg_color: 0
  border_width: 0
  outline_width: 0
  #shadow_width: 0
  #text_font: unscii_16
  #align: center
  style_definitions:
    - id: font_style
      text_color: 0xFFFFFF
      bg_color: 0
      bg_opa: TRANSP
    - id: details_style
      text_font: MONTSERRAT_16
      text_color: 0xFFFFFF
      bg_color: 0
      bg_opa: TRANSP

  buffer_size: 25%
  widgets:
    - label:
        id: powerverschenkt_label
        text: "?"
        x: 35 
        y: 20
        #width: 100
        #text_align: CENTER
        styles: font_style
        text_font: MONTSERRAT_30 # override font size
        text_color: 0x00ff00

    - label:
        id: netzstrom_label
        text: "?"
        x: 35 
        y: 60
        #width: 100
        #text_align: CENTER
        styles: font_style
        text_font: MONTSERRAT_30 # override font size
        text_color: 0xff0000
 
    - label:
        id: battery_label
        text: "?"
        x: 35
        y: 100
        #width: 100
        text_color: 0xffffff
        #text_align: CENTER
        styles: font_style
        text_font: MONTSERRAT_30 # override font size
        
    - bar:
        id: battery_bar
        x: 120
        y: 120
        width: 90
        height: 6
        min_value: 0
        max_value: 100
        value: 0

    - image:
        src: icon_lightning
        #align: center
        image_recolor: 0x00ff00
        image_recolor_opa: 100% 
        y: 20
        x: 0

    - image:
        src: icon_transmission_tower
        #align: center
        image_recolor: 0xff0000
        image_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
        y: 60
        x: 0

    - image:
        src: battery_icon
        #align: center
        image_recolor: 0xffffff
        image_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
        y: 100
        x: 0

    - image:
        src: icon_home_assistant
        align: bottom_mid
        image_recolor: 0x838383
        image_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
        y: -10
        #x: 0

image:
  - file: mdi:battery-minus-variant
    id: battery_icon_minus
    resize: 35x35
    type: binary
  - file: mdi:battery
    id: battery_icon
    resize: 35x35
    type: binary
  - file: mdi:battery-plus-variant
    id: battery_icon_plus
    resize: 35x35
    type: binary
  - file: mdi:sun-wireless-outline
    id: icon_solar
    resize: 35x35
    type: binary
  - file: mdi:transmission-tower
    id: icon_transmission_tower
    resize: 35x35
    type: binary
  - file: mdi:lightning-bolt-circle
    id: icon_lightning
    resize: 35x35
    type: binary
  - file: mdi:home-assistant
    id: icon_home_assistant
    resize: 35x35
    type: binary

sensor:
  # DC Power
  - platform: homeassistant # or your actual sensor platform
    id: total_powerverschenkt
    unit_of_measurement: "Watt"    
    entity_id: sensor.zuruck_zum_netz_watt
    on_value:
      - lvgl.label.update:
          id: powerverschenkt_label
          text: !lambda |-
            return ("" + to_string(static_cast<int>(x)) + "W").c_str();

  # Forecast
  - platform: homeassistant # or your actual sensor platform
    id: total_netzstrom
    unit_of_measurement: "Watt" 
    entity_id: sensor.strom_vom_netz_watt
    on_value:
      - lvgl.label.update:
          id: netzstrom_label
          text: !lambda |-
            return ("" + to_string(static_cast<int>(x)) + "W").c_str();

  # Home Battery
  - platform: homeassistant
    id: battery_kepworth
    entity_id: sensor.kepworth_lifepo4_battery_soc
    unit_of_measurement: "%"
    on_value:
      - lvgl.label.update:
          id: battery_label
          text: !lambda |-
            return ("" + to_string(static_cast<int>(x)) + "%").c_str();
      - lvgl.bar.update:
          id: battery_bar
          value: !lambda |-
            return x;

  #- platform: uptime
  #  name: Uptime Sensor
  #  id: time_since_boot
  #  update_interval: 3s
  #  internal: True

  - platform: template
    id: current_brightness_variable
    name: "Current Brightness"
    unit_of_measurement: "%"
    accuracy_decimals: 0
    state_class: "measurement"


Update: Now cycle through brightness with touch button.

10 Likes