Skip to content

m5stickc plus

Landon Rohatensky edited this page Jun 29, 2023 · 5 revisions
esphome:
  name: m5stickcexample
  friendly_name: m5stickcexample

esp32:
  board: m5stick-c
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

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

substitutions:
  friendly_name: "homeThingM5StickPlus"

external_components:
  - source:
      type: git
      url: https://gitlab.com/geiseri/esphome_extras.git
    refresh: 0s
    components: [axp192]
  - source:
      type: git
      url: https://github.com/landonr/homeThing
      ref: main
    refresh: 0s
    components: [homeThing]
  - source:
      type: git
      url: https://github.com/landonr/esphome-components
      ref: main
    refresh: 0s
    components: [
      homeassistant_component,
      homeassistant_media_player,
      media_player_source,
      media_player_source_sonos,
      media_player_source_spotify,
      media_player_source_custom
    ]

packages:
  remote_package:
    url: https://github.com/landonr/homeThing
    ref: main
    files: [
      common/device_base.yaml, # defines api, ota, free memory and uptime sensor
      common/fonts.yaml, # default font
      common/icon_fonts.yaml # material icons
    ]
    refresh: 0s

i2c:
   - id: bus_a
     sda: GPIO21
     scl: GPIO22
     scan: true
   - id: bus_b
     sda: GPIO0
     scl: GPIO26
     scan: true

axp192:
  id: axp
  i2c_id: bus_a
  address: 0x34
  update_interval: 60s
  charge_voltage: 4150mV
  dcdc1_voltage: 3300mv
  dcdc3_voltage: 1.5V

sensor:
    # AXP192 power management - must be present to initialize TFT power on
  - platform: axp192
    axp192_id: axp
    id: battery_percent
    type: battery_power
    name: "${friendly_name} Battery Percent"

# internal LED
light:
  - platform: monochromatic
    output:  builtin_led
    name: Led
    id: led1
    internal: True
  - platform: monochromatic
    output: axp_ldo3
    name: "${friendly_name} Backlight"
    id: backlight
    restore_mode: ALWAYS_ON 

output:
  - platform: ledc
    pin: 10
    inverted: true
    id: builtin_led
  - platform: axp192
    axp192_id: axp
    output: ldo3
    id: axp_ldo3  

binary_sensor:
  - platform: axp192
    axp192_id: axp
    type: charge_indicate
    id: axp_charger
    name: "Charger"
  - platform: gpio
    pin:
      number: GPIO37
      inverted: true
    name: Button A
    on_click:
      min_length: 5ms
      max_length: 350ms
      then:
        lambda: |-
            id(homeThingMenu)->rotaryScrollClockwise(0);
            auto call = id(led1).turn_on();
            call.set_transition_length(0);
            call.perform();
    on_multi_click:
    - timing:
        - ON for at least 0.5s
      then:
      - lambda: |-
          id(homeThingMenu)->buttonPressUp();
    on_release:
      then:
        - light.turn_off: led1
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    name: Button B
    on_press:
      then:
      - lambda: |-
          id(homeThingMenu)->buttonPressSelect();
          auto call = id(led1).turn_on();
          call.set_transition_length(0);
          call.perform();
    on_release:
      then:
        - light.turn_off: led1

deep_sleep:
  id: deep_sleep_
  wakeup_pin: 37
  wakeup_pin_mode: INVERT_WAKEUP

switch:
  - platform: axp192
    axp192_id: axp
    output: ldo3
    name: LDO3
    internal: true
  - platform: template
    name: "${friendly_name} Sleep Toggle"
    id: sleep_toggle
    optimistic: true
    on_turn_on:
      then:
        - light.turn_off:
            id: backlight
            transition_length: 0s
        - delay: 0.5s
        - deep_sleep.enter:
            id: deep_sleep_

spi:
  clk_pin: GPIO13
  mosi_pin: GPIO15

display:
  - platform: st7789v
    model: TTGO_TDisplay_135x240
    id: my_display
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    rotation: 0
    update_interval: 3600s
    lambda: |-
      id(homeThingMenu)->draw_menu_screen();
      return;

media_player_source_sonos:
  id: sonos

media_player_source_spotify:
  id: spotty

media_player_source_custom:
  - id: fav_playlists
    name: playlists
    sources:
      name: idk
      media_id: spotify:playlist:2uzbATYxs9V8YQi5lf89WG
      media_type: playlist

media_player:
  - platform: homeassistant_media_player
    name: Beam
    entity_id: "media_player.beam"
    id: media_player_beam
    type: speaker
    sources:
      - id: sonos
        type: sonos
      - id: spotty
        type: spotify
      - id: fav_playlists
        type: custom
    commands:
      name: "group all"
      command:
        - homeassistant.service:
            service: script.sonos_group_all

homeassistant_media_player:
  id: media_group_component
  media_players:
    - id: media_player_beam
      type: speaker

homeThing:
  id: homeThingMenu
  settings:
    mode: 2_button
  sleep_switch: sleep_toggle
  backlight: backlight
  media_player_group: media_group_component
  display: my_display
  on_redraw:
    then:
      component.update: my_display
  display_state:
    font_small: small_font
    font_medium: medium_font
    font_large: large_font
    font_large_heavy: large_heavy_font
    font_material_large: material_font_large
    font_material_small: material_font_small
    font_logo: home_thing_logo
    draw_now_playing_bottom_menu: True

Media Players

Speakers

Screens

Receivers

  • Yamaha

Smart home devices

  • Lights
  • Switches
  • Text Sensors

HomeThing

Clone this wiki locally