Solved: ESPHOME not able to display Home Assistant value

I am trying to get a temperature value from Home Assistant that I want to present on a Max7219 Digit Display. But looking over my YAML and comparing other examples I can’t get it to work so hoping someone might help me out. It currently display’s 0.0°C. Without “has_state” would display “nan”. Time appears fine. See my YAML and Log below.

ESPHOME YAML;

esphome:
  name: dendisplay
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pswd
  power_save_mode: none

  ap:
    ssid: " Display Fallback Hotspot"
    password: !secret esphome_pswd

captive_portal:

logger:

api:
  password: !secret esphome_pswd

ota:
  password: !secret esphome_pswd

web_server:
  port: 80

spi:
  clk_pin: D5
  mosi_pin: D7

font:
  - file: "pixelmix.ttf"
    id: digit_font8
    size: 8
  - file: "pixelmix.ttf"
    id: digit_font6
    size: 6
    glyphs:
    - ' '
    - '@'
    - '*'
    - '!'
    - '"'
    - '%'
    - (
    - )
    - +
    - ','
    - '-'
    - .
    - '0'
    - '1'
    - '2'
    - '3'
    - '4'
    - '5'
    - '6'
    - '7'
    - '8'
    - '9'
    - ':'
    - A
    - B
    - C
    - D
    - E
    - F
    - G
    - H
    - I
    - J
    - K
    - L
    - M
    - N
    - O
    - P
    - Q
    - R
    - S
    - T
    - U
    - V
    - W
    - X
    - Y
    - Z
    - _
    - a
    - b
    - c
    - d
    - e
    - f
    - g
    - h
    - i
    - j
    - k
    - l
    - m
    - n
    - o
    - p
    - q
    - r
    - s
    - t
    - u
    - v
    - w
    - x
    - y
    - z
    - °
    
    
display:
  - platform: max7219digit
    id: max7219digitdisplay
    cs_pin: D8
    num_chips: 8
    intensity: 1
    update_interval: 100ms
    lambda: |-
      it.strftime(0, 0, id(digit_font8), "%H:%M:%S", id(hass_time).now()); 
      it.printf(65, 0, id(digit_font6), TextAlign::TOP_RIGHT, "%.1f°C", id(outside_temp).has_state());
        
time:
  - platform: homeassistant
    id: hass_time
    timezone: EST+5EDT,M3.2.0/2,M11.1.0/2 

sensor:
  - platform: homeassistant
    name: "Outside Temperature"
    id: outside_temp
    entity_id: sensor.rear_porch_sensor_temperature_measurement
    internal: true

status_led:
    pin:
      number: GPIO2

Log;

[14:15:22][C][status_led:019]: Status LED:
[14:15:22][C][status_led:020]:   Pin: GPIO2 (Mode: OUTPUT)
[14:15:22][C][wifi:443]: WiFi:
[14:15:22][C][wifi:303]:   SSID: 'VikingBlod'[redacted]
[14:15:22][C][wifi:304]:   IP Address: 192.168.1.235
[14:15:22][C][wifi:306]:   BSSID: 00:11:32:9D:E1:29[redacted]
[14:15:22][C][wifi:307]:   Hostname: 'dendisplay'
[14:15:22][C][wifi:311]:   Signal strength: -44 dB ▂▄▆█
[14:15:22][C][wifi:315]:   Channel: 2
[14:15:22][C][wifi:316]:   Subnet: 255.255.255.0
[14:15:22][C][wifi:317]:   Gateway: 192.168.1.1
[14:15:22][C][wifi:318]:   DNS1: 192.168.1.177
[14:15:22][C][wifi:319]:   DNS2: (IP unset)
[14:15:22][C][spi:081]: SPI bus:
[14:15:22][C][spi:082]:   CLK Pin: GPIO14 (Mode: OUTPUT)
[14:15:22][C][spi:084]:   MOSI Pin: GPIO13 (Mode: OUTPUT)
[14:15:22][C][spi:085]:   Using HW SPI: NO
[14:15:22][C][logger:185]: Logger:
[14:15:22][C][logger:186]:   Level: DEBUG
[14:15:22][C][logger:187]:   Log Baud Rate: 115200
[14:15:22][C][logger:188]:   Hardware UART: UART0
[14:15:22][C][homeassistant.time:010]: Home Assistant Time:
[14:15:22][C][homeassistant.time:011]:   Timezone: 'EST+5EDT,M3.2.0/2,M11.1.0/2'
[14:15:22][C][max7219DIGIT:046]: MAX7219DIGIT:
[14:15:22][C][max7219DIGIT:047]:   Number of Chips: 8
[14:15:22][C][max7219DIGIT:048]:   Intensity: 1
[14:15:22][C][max7219DIGIT:049]:   Scroll Mode: 0
[14:15:22][C][max7219DIGIT:050]:   Scroll Speed: 250
[14:15:22][C][max7219DIGIT:051]:   Scroll Dwell: 1000
[14:15:22][C][max7219DIGIT:052]:   Scroll Delay: 1000
[14:15:22][C][max7219DIGIT:053]:   CS Pin: GPIO15 (Mode: OUTPUT)
[14:15:22][C][max7219DIGIT:054]:   Update Interval: 0.1s
[14:15:22][C][captive_portal:169]: Captive Portal:
[14:15:22][C][web_server:131]: Web Server:
[14:15:22][C][web_server:132]:   Address: dendisplay.local:80
[14:15:22][C][ota:029]: Over-The-Air Updates:
[14:15:22][C][ota:030]:   Address: dendisplay.local:8266
[14:15:22][C][ota:032]:   Using Password.
[14:15:22][C][api:095]: API Server:
[14:15:22][C][api:096]:   Address: dendisplay.local:6053
[14:15:22][C][homeassistant.sensor:024]: Homeassistant Sensor 'Outside Temperature'
[14:15:22][C][homeassistant.sensor:024]:   Unit of Measurement: ''
[14:15:22][C][homeassistant.sensor:024]:   Accuracy Decimals: 1
[14:15:22][C][homeassistant.sensor:025]:   Entity ID: 'sensor.rear_porch_sensor_temperature_measurement'

At the time that log was taken, no value seems to have been reported from HA to the esp device for sensor.rear_porch_sensor_temperature_measurement. When it does, you’ll see something like

[09:43:00][D][sensor:092]: 'outside_temperature': Sending state 17.30000  with 1 decimals of accuracy

I guess I didn’t monitor the log long enough, took some time to get the message.

[16:05:36][D][homeassistant.sensor:019]: 'sensor.rear_porch_sensor_temperature_measurement': Got state 3.40
[16:05:36][D][sensor:092]: 'Outside Temperature': Sending state 3.40000  with 1 decimals of accuracy

So it appears I am getting the data but it’s not outputting to the display.

Contined searching and found the example located here. Changed my lama statement and it now works.

    lambda: |-
      it.strftime(0, 0, id(digit_font8), "%H:%M:%S", id(hass_time).now()); 
      if (id(outside_temp).has_state()) {
        it.printf(65, 0, id(digit_font6), TextAlign::TOP_RIGHT, "%.1f°C", id(outside_temp).state);
      }
        
1 Like