Wemos clone display testing

only waste your time on this topic if your feeling generous :slight_smile:
im barely getting by with my understanding of home assistants inner workings.

the following code shows the string “smart display” and the time… but i cant get anything else to show up … i think im balsing up the printf parameters… can someoneeoint out the probably obvious mistake i have made??

esphome:
  name: wemos18650oled

esp8266:
  board: d1_mini

# Enable logging
logger:
#  level: VERY_VERBOSE


# Enable Home Assistant API
api:

ota:
  password: "5f0f41c4b9c3819005ac35e955ab7e51"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
#  manual_ip:
#    static_ip: 192.168.1.109
#    gateway: 192.168.1.1
#    subnet: 255.255.255.0

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

captive_portal:
sensor:
  - platform: wifi_signal
    name: "wemos18650oled ssi"
    update_interval: 60s

  - platform: adc
    pin: A0
    name: battery    
    update_interval: 5s
    
    
  - platform: homeassistant
    id: elec_usage
    entity_id: sensor.electricity_usage_2
    internal: false

  - platform: homeassistant
    id: elec_cost
    entity_id: sensor.dollarstodaydig
    internal: false      

time:
  - platform: homeassistant
    id: esptime    
    
    
text_sensor:    
  - platform: wifi_info
    ip_address:
      name: wemos18650oled IP Address
    ssid:
      name: wemos18650oled Connected SSID
    bssid:
      name: wemos18650oled Connected BSSID
    mac_address:
      name: wemos18650oled Mac Wifi Address
    scan_results:
      name: wemos18650oled Latest Scan Results
      
      
switch:
  - platform: gpio
    name: "wemos18650oled Devboard Led"
    inverted: true
    pin: 16 
  - platform: gpio
    name: "wemos18650oled espchip Led"
    inverted: true
    pin: 2 
    


    
i2c:
  sda: D1
  scl: D2
font:
  - file: "arial.ttf"
    id: my_font
    size: 10
display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
#    reset_pin: D0
    address: 0x3C
    lambda: |-
      it.printf(64, 0, id(my_font), TextAlign::TOP_CENTER, "Smart Display");
      it.strftime(0, 21, id(my_font), TextAlign::BASELINE_LEFT, "%H:%M", id(esptime).now());      
      if (id(elec_usage).has_state()) {
        it.printf(0, 32, id(my_font), TextAlign::TOP_RIGHT ,"power usage%f",  id(elec_usage).state);
      }
      if (id(elec_cost).has_state()) {
        it.printf(0, 43, id(my_font), TextAlign::BASELINE_RIGHT ,"power cost%f", id(elec_cost).state);
      }

What happens if you remove the if( ... has state() rows?

Yes, and try adding

web_server:
  port: 80
  include_internal: true

to your config, then look at its webpage to see what it thinks those sensors’ states are. Maybe they’re not ever successfully receiving them from HA.

cool, knew about logs… didnt know about that one…
but it outputs this


unless im missing something it should work?

but all i get is this

hahaha first thing i tried… but good suggestion… im kinda at that level… but yeah doesnt affect output to screen … still just get title and time

I don’t know if it makes a difference but you don’t have a space in "power usage%f".

Tyr this instead:
"power usage %.1f"

Here is the issue!
TextAlign::TOP_RIGHT.

You align the text on the right side and output the text on x =0, that means the text is left of the screen.

Edit: make it TextAlign::TOP_LEFT

doesnt appear to change anything on the screen or the logs

omg… this is what i get for stealing and mutilating code lol… cheers man

1 Like

Copy pasting, the crime that strikes back

cheers man, legend… lol while im at it … i get errors about no representation of the dollarsign in selected font (built in arial font) is this fixed with another font file?

Scroll down slightly to glyphs.

cheers man… guess sometimes i just need to step back and get another angle haha

legend man…im still learning and prototyping ideas, but all the great people like you out there make it possible…

1 Like