avwuff / esphome-wiegand

Simple ESPHome Wiegand custom component
30 stars 14 forks source link

Error in compiling #3

Closed mgiako closed 2 years ago

mgiako commented 2 years ago

Hi,

I'm trying to use your code.

I get this log during install:

INFO Reading configuration /config/esphome/rfid.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing rfid (board: esp01_1m; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|-- <ESPAsyncWebServer-esphome> 2.1.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DNSServer> 1.1.1
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
Compiling /data/rfid/.pioenvs/rfid/src/main.cpp.o
/config/esphome/rfid.yaml: In lambda function:
/config/esphome/rfid.yaml:32:40: error: 'D1' was not declared in this scope
     auto wiegand = new WiegandReader(D1, D2);
                                        ^
/config/esphome/rfid.yaml:32:44: error: 'D2' was not declared in this scope
     auto wiegand = new WiegandReader(D1, D2);
                                            ^
/config/esphome/rfid.yaml:34:22: error: could not convert '{wiegand}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::sensor::Sensor*>'
     return {wiegand};
                      ^
/config/esphome/rfid.yaml:35:3: warning: control reaches end of non-void function [-Wreturn-type]

   ^
*** [/data/rfid/.pioenvs/rfid/src/main.cpp.o] Error 1

and this is the config yaml:

esphome:
  includes:
    - wiegand_device.h
  name: rfid

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "26b2e63aaa38f2be4480f897e10808fd"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Rfid Fallback Hotspot"
    password: "aplfQezat3E4"

captive_portal:

sensor:
- platform: custom
  lambda: |-
    auto wiegand = new WiegandReader(D1, D2);
    App.register_component(wiegand);
    return {wiegand};

  sensors:
    name: "Card ID"
    on_value:
      then:
        - homeassistant.tag_scanned: !lambda |-
            char buf[16];
            sprintf(buf, "%.0f", x);
            std::string s = buf;
            return s;        

Can't understand what's wrong. Can you help me please?

mgiako commented 2 years ago

Never mind, find the issue. Sorry to bother you

balazs111 commented 1 year ago

Hello Mgiako,

I just wonder what was the solution?

Thank you