Custom text sensor fails to compile after updating from 1.16.1 to 1.18.0

Tags: #<Tag:0x00007fc40f9fa058>

I now get an error when compiling. I suspect something needs to change in the python file, but I don’t know what. The error is:

src/main.cpp:16:1: error: 'empty_text_sensor' does not name a type
 empty_text_sensor::EmptyTextSensor *empty_text_sensor_emptytextsensor;
src/main.cpp: In function 'void setup()':
src/main.cpp:148:3: error: 'empty_text_sensor_emptytextsensor' was not declared in this scope
   empty_text_sensor_emptytextsensor = new empty_text_sensor::EmptyTextSensor();
src/main.cpp:148:43: error: 'empty_text_sensor' does not name a type
   empty_text_sensor_emptytextsensor = new empty_text_sensor::EmptyTextSensor();

To simplify for debug, I tried just using the “empty_text_sensor” code directly from That code is what my actual custom text sensor code is derived from. Both fail with the same “does not name a type” error message.

Maybe something broke with the " Add default device classes to sensor components" change to ESPHome?

Found the answer on discord. Turns out I need to add an empty file to my custom_component folder.

That led to the next problem that version 1.18.0 defaults to an old version of ArduinoJson-esphome. I had to modify the yaml to add a version tag to the library:

  name: caller_id_node
  platform: ESP32
  board: nodemcu-32s
    - "ArduinoJson-esphomelib @ ^6.15.2"

Now it’s back to working, even after updating ESPHome.