esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

Compilation failed when using Rtttl as a dependency #4971

Closed kvj closed 1 year ago

kvj commented 1 year ago

The problem

I'm working on a custom component, and I'm getting error while using rtttl component as a dependency. All other components I'm using do not cause any compilation errors.

Details:

I declare schema as follows:

from esphome.components import ..., rtttl

CONFIG_SCHEMA = (
    cv.Schema({
        cv.GenerateID(): cv.declare_id(_cls),
        cv.GenerateID(CONF_DISPLAY): cv.use_id(nextion.Nextion),
        # ...
        cv.GenerateID(CONF_RTTTL): cv.use_id(rtttl.Rtttl),
    })
    .extend(cv.COMPONENT_SCHEMA)
)

then I'm able to get the reference via

await cg.get_variable(config[CONF_RTTTL])

but when I'm trying to declare a field or make a method in the c++ code like

esphome::rtttl::Rtttl *rtttl_player;

I'm getting the compile error

src/esphome/components/nspanel_ng/nspanel_ng.h:18:18: error: 'rtttl' in namespace 'esphome' does not name a type                                                                       
         esphome::rtttl::Rtttl *rtttl_player;                         

I'm declaring a bunch of other references e.g. display, switches and everything works as expected. I've checked generated main.cpp and esphome.h files they look okay, rtttl.h is included (as the necessary component is in yaml). The yaml looks like this:


rtttl:
  id: buzzer
  output: buzzer_out

output:
  - platform: ledc
    id: buzzer_out
    pin:
      number: 21

I've ruled out most obvious reasons why the namespace isn't visible, and I'm running out of ideas. And yes, I've tried to remove .esphome/ folder and re-compile the project

Which version of ESPHome has the issue?

2023.9.3

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

Not relevant

What platform are you using?

ESP32

Board

esp32dev / Sonoff NSPanel

Component causing the issue

rtttl

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

nielsnl68 commented 1 year ago

This question can be better asked on discord.

ssieb commented 1 year ago

Right, issues with custom or external components aren't for github unless it's caused by an actual bug in esphome.

kvj commented 1 year ago

Right, issues with custom or external components aren't for github unless it's caused by an actual bug in esphome.

Hard to say :) Could be a bug in esphome, could be a bug in internal rtttl component