Was previously using a custom component to read data from uart (the general uart_read_line_sensor.h file) and feed it to a text sensor. Since custom components are going away I found an example of how to do this using the debug component. However something with this file is causing the compiler/editor to throw a not helpful syntax error message. In the first line “esphome” has the red line under it and gives the message:
while parsing a block collection
in “/config/esphome/theater-projector.yaml”, line 49, column 3
expected , but found ‘?’
in “/config/esphome/theater-projector.yaml”, line 53, column 3
I have been trying everything I can think of to figure out what its not happy with but after several hours I haven’t found anything and would appreciate some help.
My yaml file:
esphome:
name: theater-projector
friendly_name: Theater Projector
esp32:
board: m5stack-core-esp32
framework:
type: arduino
# Enable logging
logger:
level: VERBOSE #makes uart stream available in esphome logstream
baud_rate: 0 #disable logging over uart
# Enable Home Assistant API
api:
encryption:
key: "**********"
ota:
- platform: esphome
password: "**********"
wifi:
ssid: !secret **********
password: !secret **********
domain: **********
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Theater-Projector"
password: "**********"
captive_portal:
uart:
tx_pin: GPIO19
rx_pin: GPIO22
baud_rate: 9600
# https://www.reddit.com/r/Esphome/comments/1js47go/serial_read_custom_component_to_external_component/?ref=share&ref_source=link
text_sensor:
- platform: template
name: "UART Readline"
id: uart_readline
update_interval: never
interval:
- interval: 10s
then:
- uart.write: "pwr?\r"
#- uart.write: [0x70, 0x77, 0x72, 0x3F, 0x0D]
debug:
direction: RX
dummy_receiver: true
after:
# Carriage Return (https://ss64.com/ascii.html)
delimiter: [0x0D]
timeout: 2000ms
sequence:
- lambda: |-
std::string uart_bytes(bytes.begin(), bytes.end());
id(uart_readline).publish_state(uart_bytes.c_str());
switch:
- platform: template
name: "Project Power"
lambda: |-
if ((id(uart_readline).state == ":PWR=01") || (id(uart_readline).state == ":PWR=02") || (id(uart_readline).state == ":PWR=03")) {
return true;
} else if((id(uart_readline).state == ":PWR=00") || (id(uart_readline).state == ":PWR=05")) {
return false;
} else {
return {};
}
icon: mdi:projector
turn_on_action:
- uart.write: "PWR ON\r"
turn_off_action:
- uart.write: "PWR OFF\r"