Hi All
I have a switch that I would like to display in the lambda in esphome if it’s on or not.
I’ve tried to just use the switch directly, but is that possible? Or do I need to create a sensor that holds the state of the switch to be able to display the state?
This is the config I have so far:
substitutions:
device_name: kitchendisplay
esphome:
name: kitchendisplay
platform: ESP8266
board: d1_mini
wifi:
ssid: "ssid"
password: "pw"
# Enable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
ota:
password: "pw"
text_sensor:
- platform: version
name: "${device_name} ESPHome Version"
- platform: wifi_info
ip_address:
name: "${device_name} ip"
ssid:
name: "${device_name} ssid"
- platform: homeassistant
id: pumprunning
entity_id: switch.vandsten
internal: true
sensor:
- platform: wifi_signal
name: '${device_name} WiFi Signal'
update_interval: 60s
accuracy_decimals: 0
- platform: uptime
name: '${device_name} Uptime'
unit_of_measurement: days
update_interval: 300s
accuracy_decimals: 1
filters:
- multiply: 0.000011574
- platform: homeassistant
id: pooltemp
entity_id: sensor.pool_temperature
internal: true
time:
- platform: homeassistant
id: homeassistant_time
font:
- file: "comic.ttf"
id: comic
size: 20
- file: "calibrib.ttf"
id: headline
size: 30
- file: "calibri.ttf"
id: normaltext
size: 20
- file: "calibri.ttf"
id: temptext
size: 50
spi:
clk_pin: D0
mosi_pin: D1
display:
- platform: waveshare_epaper
rotation: 90
cs_pin: D2
dc_pin: D6
busy_pin: D7
reset_pin: D5
model: 2.90in
full_update_every: 300
lambda: |-
it.printf(148, 0, id(headline), TextAlign::TOP_CENTER, "Fribert smarthome");
it.strftime(296, 40, id(normaltext), TextAlign::BASELINE_RIGHT, "%H:%M", id(homeassistant_time).now());
it.printf(0, 70, id(temptext), TextAlign::BASELINE_LEFT, "Pool:");
it.printf(0, 120, id(temptext), TextAlign::BASELINE_LEFT, "Pump:");
if (id(pooltemp).has_state()) {
it.printf(220, 70, id(temptext), TextAlign::BASELINE_RIGHT, "%.1f°C", id(pooltemp));
}
it.printf(220, 120, id(temptext), TextAlign::BASELINE_RIGHT, "%s", id(pumprunning).state.c_str());
But the pump state is not printing anything to the display.