Skip to content

Error Using Custom Global Type #2831

Open
@RebbePod

Description

@RebbePod

The problem

When including a header file with a custom class, the global type can't be set to that class.

This is the custom class I currently have in my header file:

    class CustomTime : public time::RealTimeClock {
    public:
    void setup() override;
    void update() override;
    void set_epoch_time(uint32_t epoch) { this->synchronize_epoch_(epoch); }

    protected:
    time_t time_;
    };

The error I get is shown below.

Which version of ESPHome has the issue?

2021.12.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32

Board

esp32doit-devkit-v1

Component causing the issue

globals:

Example YAML snippet

globals:
  - id: custom_global
    type: CustomTime

Anything in the logs that might be useful for us?

src/main.cpp:125:27: error: 'CustomTime' was not declared in this scope
 globals::GlobalsComponent<CustomTime> *custom_global;
                           ^
src/main.cpp:125:37: error: template argument 1 is invalid
 globals::GlobalsComponent<CustomTime> *custom_global;

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions