Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error with switch, no error with light #26

Open
Paulpanther opened this issue Dec 21, 2024 · 1 comment
Open

Compile error with switch, no error with light #26

Paulpanther opened this issue Dec 21, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Paulpanther
Copy link

I have a simple configuration, mostly copied from the example.

  name: wasserzyklus
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32dev
  flash_size: 4MB
  framework:
    type: esp-idf
    version: 5.2.1
    platform_version: 6.7.0
    sdkconfig_options:
      CONFIG_COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_LWIP_MAX_SOCKETS: "16"
      CONFIG_MBEDTLS_HKDF_C: y

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  - platform: esphome
    password: ""

wifi:
  ssid: "removed"
  password: "removed"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wasserzyklus Fallback Hotspot"
    password: "removed here, but present in config"

captive_portal:

switch:
  - platform: gpio
    id: wasser_switch
    pin: GPIO5
    name: "Wasserzyklus"

external_components:
  source: github://rednblkx/HAP-ESPHome@main
  refresh: 0s

homekit:
  switch:
    - id: wasser_switch

homekit_base:
  meta:
    name: "Wasserzyklus"
    manufacturer: "Paul"

When compiling I get the following errors

                 from src/esphome/components/homekit/HAPAccessory.cpp:1:
src/esphome/components/homekit/switch.hpp:17:12: error: 'map' in namespace 'std' does not name a template type
   17 |       std::map<AInfo, const char*> accessory_info = {{NAME, NULL}, {MODEL, "HAP-SWITCH"}, {SN, NULL}, {MANUFACTURER, "rednblkx"}, {FW_REV, "0.1"}};
      |            ^~~
src/esphome/components/homekit/switch.hpp:8:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
    7 | #include <hap_apple_chars.h>
  +++ |+#include <map>
    8 | 
src/esphome/components/homekit/switch.hpp:56:20: error: 'std::map' has not been declared
   56 |       void setInfo(std::map<AInfo, const char*> info) {
      |                    ^~~
src/esphome/components/homekit/switch.hpp:56:28: error: expected ',' or '...' before '<' token
   56 |       void setInfo(std::map<AInfo, const char*> info) {
      |                            ^
src/esphome/components/homekit/switch.hpp: In member function 'void esphome::homekit::SwitchEntity::setInfo(int)':
src/esphome/components/homekit/switch.hpp:57:14: error: 'map' is not a member of 'std'
   57 |         std::map<AInfo, const char*> merged_info;
      |              ^~~
src/esphome/components/homekit/switch.hpp:57:14: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
src/esphome/components/homekit/switch.hpp:57:23: error: expected primary-expression before ',' token
   57 |         std::map<AInfo, const char*> merged_info;
      |                       ^
src/esphome/components/homekit/switch.hpp:57:25: error: expected primary-expression before 'const'
   57 |         std::map<AInfo, const char*> merged_info;
      |                         ^~~~~
src/esphome/components/homekit/switch.hpp:58:9: error: 'merged_info' was not declared in this scope
   58 |         merged_info.merge(info);
      |         ^~~~~~~~~~~
src/esphome/components/homekit/switch.hpp:58:27: error: 'info' was not declared in this scope
   58 |         merged_info.merge(info);
      |                           ^~~~
src/esphome/components/homekit/switch.hpp:59:33: error: 'class esphome::homekit::SwitchEntity' has no member named 'accessory_info'
   59 |         merged_info.merge(this->accessory_info);
      |                                 ^~~~~~~~~~~~~~
src/esphome/components/homekit/switch.hpp:60:15: error: 'class esphome::homekit::SwitchEntity' has no member named 'accessory_info'
   60 |         this->accessory_info.swap(merged_info);
      |               ^~~~~~~~~~~~~~
src/esphome/components/homekit/switch.hpp: In member function 'void esphome::homekit::SwitchEntity::setup()':
src/esphome/components/homekit/switch.hpp:64:29: error: 'accessory_info' was not declared in this scope
   64 |             .model = strdup(accessory_info[MODEL]),
      |                             ^~~~~~~~~~~~~~
Compiling .pioenvs/wasserzyklus/src/esphome/components/logger/logger_esp8266.cpp.o
Compiling .pioenvs/wasserzyklus/src/esphome/components/logger/logger_host.cpp.o
*** [.pioenvs/wasserzyklus/src/esphome/components/homekit/HAPAccessory.cpp.o] Error 1
src/esphome/components/homekit_base/HAPRootComponent.cpp: In constructor 'esphome::homekit::HAPRootComponent::HAPRootComponent(const char*, const char*, std::map<esphome::homekit::AInfo, const char*>)':
src/esphome/components/homekit_base/HAPRootComponent.cpp:48:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   48 |                 .hw_rev = "1.0",
      |                           ^~~~~
src/esphome/components/homekit_base/HAPRootComponent.cpp:52:13: warning: missing initializer for member 'hap_acc_cfg_t::hw_finish' [-Wmissing-field-initializers]
   52 |             };
      |             ^
src/esphome/components/homekit_base/HAPRootComponent.cpp:49:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   49 |                 .pv = "1.1.0",
      |                       ^~~~~~~

when I use light instead of switch (again, like in the example), everything works fine.

System: MacOS 14.6.1, ESPHome 2024.12.2 (installed via homebrew). cmake 3.16.4

Did I make a configuration error, or is this actually a bug?

@Paulpanther Paulpanther added the bug Something isn't working label Dec 21, 2024
rednblkx added a commit that referenced this issue Dec 23, 2024
<map> needs to be included since other includes don't always have it
@rednblkx
Copy link
Owner

Hi,

thanks for reporting, yes, it's a bug, should be good now, let me know if anything else.

Cheers

@rednblkx rednblkx added stale and removed stale labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants