I have a text sensor that gets its value from home assistant, and another that should return a value to print on the display. There is a problem with the second sensor. Here is the code:
display:
platform: tm1638
id: tm1638_display
stb_pin: D3
clk_pin: D2
dio_pin: D1
intensity: 4
update_interval: 1s
lambda: |-
it.print (id(print_status).state.c_str());
text_sensor:
- platform: homeassistant
entity_id: "alarm_control_panel.alarmo"
id: alarm_status
- platform: template
id: print_status
lambda: |-
if (id(alarm_status).state == "disarmed") {
return "DISARMED";
} else {
return "ARMED";
}
update_interval: 1s
The lambda tests alarm_status, but gives these errors on the return values:
/config/esphome/alarmokeypad.yaml: In lambda function:
/config/esphome/alarmokeypad.yaml:36:16: error: could not convert '"DISARMED"' from 'const char [9]' to 'esphome::optional<std::__cxx11::basic_string<char> >'
36 | return "DISARMED";
| ^~~~~~~~~~
| |
| const char [9]
/config/esphome/alarmokeypad.yaml:38:16: error: could not convert '"ARMED"' from 'const char [6]' to 'esphome::optional<std::__cxx11::basic_string<char> >'
38 | return "ARMED";
| ^~~~~~~
| |
| const char [6]
*** [/data/alarmokeypad/.pioenvs/alarmokeypad/src/main.cpp.o] Error 1
How can I modify the return statements so that the display will print those values? Thanks for guidance.