brianhanifin / esphome-config

My ESPHome configuration files for my ESP8266 / ESP32 plugs and boards for use with Home Assistant.
109 stars 20 forks source link

Compile issues with esphome 2022.2.1 #8

Closed bogdanr closed 2 years ago

bogdanr commented 2 years ago

Trying to compile this code in the latest esphome produces some errors such as these:


src/irrigation.h: In function 'bool scheduled_runtime(std::string)':
src/irrigation.h:10:22: error: 'homeassistant_time' was not declared in this scope
   10 |   auto time_now = id(homeassistant_time).now();
      |                      ^~~~~~~~~~~~~~~~~~
src/irrigation.h: In function 'std::string update_next_runtime(std::string)':
src/irrigation.h:41:22: error: 'homeassistant_time' was not declared in this scope
   41 |   auto time_now = id(homeassistant_time).now();
      |                      ^~~~~~~~~~~~~~~~~~
Compiling /data/sandbox/.pioenvs/sandbox/FrameworkArduino/Esp-version.cpp.o
*** [/data/sandbox/.pioenvs/sandbox/src/main.cpp.o] Error 1
brianhanifin commented 2 years ago

Do you have the time: section defined in your .yaml file? homeassistant_time is defined there. You can see it by following the link below.

https://github.com/brianhanifin/esphome-config/blob/dd1915797eed3db790a877f3a5f1bc555ae9c528/irrigation.yaml#L418

brianhanifin commented 2 years ago

I tried to recompile my code to check on this issue. However, I am running into an unrelated error already reported to to the ESPHome project.

The error you are reporting is consistent with an undeclared time object.

robsonke commented 2 years ago

I stumbled upon the same issue. Downgrading the framework version works for me (for the time being):

esp8266:
  board: esp01_1m
  framework:
    version: 2.7.4
brianhanifin commented 2 years ago

I recorded the fix on the ESPHome issue but forgot to report back here. The fix to irrigation.h (d30fa4f) was only committed a few days ago due to a problem with my desktop github config (which has now also been resolved).

Here are the steps I used to correct this issue:

  1. Open Irrigation.h.
  2. Removed line 2 using namespace std .
  3. Replaced string with std::string.
  4. Replaced vector with std::vector.