Home Assistant Community

Change LCD Text with Home Assistant switch problem

#1

Hi all!

Im trying to create a Kiln temperature sensor for my wife with an lcd display. One of the functions I want is to create a timer that starts when a switch is turned on in home assistant. And then display the time that has passed on the lcd screen.

EDIT: At this time I don’t have a timer configured yet. I just want the switch to change the text on the LCD screen. (One problem at the time, right?)

The problem is that whenever i turn on the switch in home assistant nothing happens and the switch turns itself back off.

What am I doing wrong?

This is my config:

esphome:
  name: kiln
  platform: ESP8266
  board: nodemcu

wifi:
  ssid: !secret ssid
  password: !secret ssid_pass

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_pass

ota:
  password: !secret ota_pass


# SPI BUS HUB
spi:
  miso_pin: D5 #MISO = SO
  clk_pin: D6 #SCk 
  
i2c:
  sda: D2
  scl: D1

sensor:
  - platform: max31855
    name: "Kiln Temperature"
    cs_pin: D7 #CS
    update_interval: 30s
    id: kiln_temp
    
  - platform: wifi_signal
    name: "Kiln Sensor WiFi signal"
    update_interval: 60s

  - platform: uptime
    name: "Kiln Sensor uptime"

text_sensor:
  - platform: version
    name: "Kiln Sensor ESPHome version"
    
time:
  - platform: homeassistant
    id: homeassistant_time
    
switch:
  - platform: template
    name: "Kiln Timer Switch"
    id: start_stop_timer


display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27 
    lambda: |-
      it.strftime(12,0, "%H:%M:%S", id(homeassistant_time).now());
      it.printf(0, 1, "Oven: %.1f C", id(kiln_temp).state);
      it.printf(0, 2, "--------------------");
      if (id(start_stop_timer).state) {
        it.print(0, 3, "state: ON");
      } else {
        it.print(0, 3, "state: OFF");
      }
#2

You might need to show us the timer configuration in home assistant?

#3

At this time I don’t have a timer configured yet. I just wanted to check whether the text on the LCD screen would change when I toggle the switch in the front end.

I configured a switch in the ESP config:

switch:
  - platform: template
    name: "Kiln Timer Switch"
    id: start_stop_timer

This should change the text on the screen:

display:
  - platform: lcd_pcf8574
    ...
    lambda: |-
      ...
      if (id(start_stop_timer).state) {
        it.print(0, 3, "state: ON");
      } else {
        it.print(0, 3, "state: OFF");
      }

But on the LCD nothing happens and the switch in the front end turns itself back off after a second or two.