Hi,
I’m playing with TTGO display running ESPhome. I have it running just fine but I’m struggling with one issue and I was hoping that someone her know how to address it or came across something similar in their HA journeys.
My Display will be acting as a basic Alarm display monitor - basically displaying if Alarm is on or off.
I have my alarms managed with automations
The bit I am struggling is I want to show in green when my siren automation is disabled (off state)
and in red when it is enabled (on state)
This is my config:
esphome:
name: alarm-display
platform: ESP32
board: featheresp32
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
- ssid: !secret wifi2_ssid
password: !secret wifi_password
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
font:
- file: "Helvetica.ttf"
id: helvetica_24
size: 24
binary_sensor:
- platform: gpio
pin:
number: GPIO0
inverted: true
name: ${devicename}top push
id: tdisplay_button_input_0
- platform: gpio
pin:
number: GPIO35
inverted: true
id: tdisplay_button_input_1
name: ${devicename}bottom push
switch:
- platform: restart
name: ${devicename} restart
text_sensor:
- platform: homeassistant
id: alarm1
entity_id: automation.alarm1
name: "Alarm Door"
- platform: homeassistant
id: alarm2
entity_id: automation.alarm2
name: "iPhone Notification"
- platform: homeassistant
id: alarm3
entity_id: automation.alarm3
name: "Siren"
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
display:
- platform: st7789v
backlight_pin: GPIO4
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 270
lambda: |-
it.printf(4, 0, id(helvetica_24), id(my_yellow), "Door Alarm: %s", id(alarm1).state.c_str());
it.printf(4, 28, id(helvetica_24), id(my_yellow), "Voice notification: %s", id(alarm2).state.c_str());
if (id(alarm3).state=off) {
it.printf(4, 56, id(helvetica_24), id(my_green), "Siren: %s", id(alarm3).state.c_str());
} else {
it.printf(4, 56, id(helvetica_24), id(my_red), "Siren: %s", id(alarm3).state.c_str());
}
When I try to install that code on my display in ESPhome I get this error:
/config/esphome/alarm-display-szopa.yaml: In lambda function:
/config/esphome/alarm-display-szopa.yaml:119:25: error: 'off' was not declared in this scope
if (id(alarm3).state=off) {
^
Compiling /data/alarm-display-szopa/.pioenvs/alarm-display-szopa/lib64d/WiFi/WiFiClient.cpp.o
Archiving /data/alarm-display-szopa/.pioenvs/alarm-display-szopa/lib528/libAsyncTCP-esphome.a
Compiling /data/alarm-display-szopa/.pioenvs/alarm-display-szopa/lib64d/WiFi/WiFiGeneric.cpp.o
*** [/data/alarm-display-szopa/.pioenvs/alarm-display-szopa/src/main.cpp.o] Error 1
========================= [FAILED] Took 20.18 seconds =========================
Any ideas how to address this issue?
Thanks