esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

Arduino port expander cannot compile #2847

Open cicinovec opened 2 years ago

cicinovec commented 2 years ago

The problem

When trying to compile code with arduino port expander, it cannot compile

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?

2021.12.3

What platform are you using?

ESP8266

Board

ESP8266 + Arduino Nano

Component causing the issue

arduino port expander

Example YAML snippet

esphome:
  name: bedroom_plants_and_led
  platform: ESP8266
  board: nodemcu
  includes:
  - arduino_port_expander.h

wifi:
  ssid: "Devices"
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bedroom Plants"
    password: !secret wifi_password

captive_portal:

# Enable Home Assistant API
api:

ota:

i2c:
  id: i2c_bus

logger:
  level: DEBUG

# define the port expander hub, here we define one with id 'expander1',
# but you can define many
custom_component:
  - id: expander1
    lambda: |-
      auto expander = new ArduinoPortExpander((i2c_bus), 0x08, true);
      return {expander};

# define analog sensors
sensor:
  - platform: custom
    lambda: |-
      return {ape_analog_input(expander1, 0),  // 1 = A1
              ape_analog_input(expander1, 1),
              ape_analog_input(expander1, 2),
              ape_analog_input(expander1, 3)};
    sensors:
      - name: Aglaonema Crete
        id: analog_a0
        unit_of_measurement: "%"
        icon: "mdi:water-percent"
        accuracy_decimals: 0
        filters:
          # update every 60s
          - throttle: 60s
          - calibrate_linear:
            # Map 0.0 (from sensor) to 0.0 (true value)
            - 550.0 -> 5.0
            - 350.0 -> 100.0
      - name: Sansevieria Friends
        id: analog_a1
        unit_of_measurement: "%"
        icon: "mdi:water-percent"
        accuracy_decimals: 0
        filters:
          # update every 60s
          - throttle: 60s
          - calibrate_linear:
            # Map 0.0 (from sensor) to 0.0 (true value)
            - 550.0 -> 5.0
            - 350.0 -> 100.0
      - name: Chlorophytum Ocean
        id: analog_a2
        unit_of_measurement: "%"
        icon: "mdi:water-percent"
        accuracy_decimals: 0
        filters:
          # update every 60s
          - throttle: 60s
          - calibrate_linear:
            # Map 0.0 (from sensor) to 0.0 (true value)
            - 550.0 -> 5.0
            - 350.0 -> 100.0
      - name: Scindapsus Epipremnum aureum
        id: analog_a3
        unit_of_measurement: "%"
        icon: "mdi:water-percent"
        accuracy_decimals: 0
        filters:
          # update every 60s
          - throttle: 60s
          - calibrate_linear:
            # Map 0.0 (from sensor) to 0.0 (true value)
            - 550.0 -> 5.0
            - 350.0 -> 100.0
  - platform: bh1750
    name: "Bedroom Light intensity"
    address: 0x23
    measurement_duration: 254
    resolution: 1.0
    update_interval: 60s

light:
  - platform: neopixelbus
    type: GRB
    pin: GPIO14
    num_leds: 60
    variant: WS2812X
    name: "Bedroom LED light"
    id: bedroom_led
    effects:
      - random:
          name: Random Effect With Custom Values
          transition_length: 5s
          update_interval: 7s
      - automation:
          name: Reading light bedroom
          sequence:
            - light.addressable_set:
                id: bedroom_led
                red: 100%
                green: 65%
                blue: 0%
      - addressable_rainbow:
          name: Rainbow Effect With Custom Values
          speed: 10
          width: 3
      - addressable_color_wipe:
          name: Color Wipe Effect With Custom Values
          colors:
            - red: 100%
              green: 100%
              blue: 0%
              num_leds: 5
            - red: 0%
              green: 0%
              blue: 0%
              num_leds: 5
          add_led_interval: 1000ms
          reverse: True
      - strobe:
          name: Police effect
          colors:
            - state: True
              brightness: 100%
              red: 100%
              green: 0%
              blue: 0%
              duration: 500ms
            - state: False
              duration: 50ms
            - state: True
              brightness: 100%
              red: 0%
              green: 0%
              blue: 100%
              duration: 500ms

Anything in the logs that might be useful for us?

Compiling /data/bedroom_plants_and_led/.pioenvs/bedroom_plants_and_led/lib67b/ESP8266WiFi/ESP8266WiFiSTA-WPS.cpp.o
In file included from src/main.cpp:48:0:
src/arduino_port_expander.h:108:36: error: expected ')' before '*' token
   ArduinoPortExpander(I2CComponent *parent, uint8_t address, bool vref_default = false) : I2CDevice(parent, address)
                                    ^
src/arduino_port_expander.h: In member function 'virtual void ArduinoPortExpander::loop()':
src/arduino_port_expander.h:134:97: error: no matching function for call to 'ArduinoPortExpander::read_bytes(int, uint8_t*, int, int)'
       if (this->read_bytes(APE_CMD_DIGITAL_READ, const_cast<uint8_t *>(this->read_buffer_), 3, 1))
                                                                                                 ^
src/arduino_port_expander.h:134:97: note: candidates are:
In file included from src/esphome/components/bh1750/bh1750.h:5:0,
                 from src/esphome.h:15,
                 from src/main.cpp:3:
src/esphome/components/i2c/i2c.h:68:8: note: bool esphome::i2c::I2CDevice::read_bytes(uint8_t, uint8_t*, uint8_t)
   bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len) {
        ^
src/esphome/components/i2c/i2c.h:68:8: note:   candidate expects 3 arguments, 4 provided
src/esphome/components/i2c/i2c.h:73:55: note: template<unsigned int N> esphome::optional<std::array<unsigned char, N> > esphome::i2c::I2CDevice::read_bytes(uint8_t)
   template<size_t N> optional<std::array<uint8_t, N>> read_bytes(uint8_t a_register) {
                                                       ^
src/esphome/components/i2c/i2c.h:73:55: note:   template argument deduction/substitution failed:
In file included from src/main.cpp:48:0:
src/arduino_port_expander.h:134:97: note:   candidate expects 1 argument, 4 provided
       if (this->read_bytes(APE_CMD_DIGITAL_READ, const_cast<uint8_t *>(this->read_buffer_), 3, 1))
                                                                                                 ^
src/arduino_port_expander.h: In member function 'uint16_t ArduinoPortExpander::analogRead(uint8_t)':
src/arduino_port_expander.h:233:116: error: no matching function for call to 'ArduinoPortExpander::read_bytes(uint8_t, uint8_t*, int, int)'
     bool ok = this->read_bytes((uint8_t)(CMD_ANALOG_READ_A0 + pin), const_cast<uint8_t *>(this->read_buffer_), 2, 1);
                                                                                                                    ^
src/arduino_port_expander.h:233:116: note: candidates are:
In file included from src/esphome/components/bh1750/bh1750.h:5:0,
                 from src/esphome.h:15,
                 from src/main.cpp:3:
src/esphome/components/i2c/i2c.h:68:8: note: bool esphome::i2c::I2CDevice::read_bytes(uint8_t, uint8_t*, uint8_t)
   bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len) {
        ^
src/esphome/components/i2c/i2c.h:68:8: note:   candidate expects 3 arguments, 4 provided
src/esphome/components/i2c/i2c.h:73:55: note: template<unsigned int N> esphome::optional<std::array<unsigned char, N> > esphome::i2c::I2CDevice::read_bytes(uint8_t)
   template<size_t N> optional<std::array<uint8_t, N>> read_bytes(uint8_t a_register) {
                                                       ^
src/esphome/components/i2c/i2c.h:73:55: note:   template argument deduction/substitution failed:
In file included from src/main.cpp:48:0:
src/arduino_port_expander.h:233:116: note:   candidate expects 1 argument, 4 provided
     bool ok = this->read_bytes((uint8_t)(CMD_ANALOG_READ_A0 + pin), const_cast<uint8_t *>(this->read_buffer_), 2, 1);
                                                                                                                    ^
/config/esphome/bedroom-plant-and-light.yaml: In lambda function:
/config/esphome/bedroom-plant-and-light.yaml:35:68: error: no matching function for call to 'ArduinoPortExpander::ArduinoPortExpander(esphome::i2c::ArduinoI2CBus*&, int, bool)'
       auto expander = new ArduinoPortExpander((i2c_bus), 0x08, true);
                                                                    ^
/config/esphome/bedroom-plant-and-light.yaml:35:68: note: candidates are:
In file included from src/main.cpp:48:0:
src/arduino_port_expander.h:105:7: note: ArduinoPortExpander::ArduinoPortExpander()
 class ArduinoPortExpander : public Component, public I2CDevice
       ^
src/arduino_port_expander.h:105:7: note:   candidate expects 0 arguments, 3 provided
src/arduino_port_expander.h:105:7: note: ArduinoPortExpander::ArduinoPortExpander(const ArduinoPortExpander&)
src/arduino_port_expander.h:105:7: note:   candidate expects 1 argument, 3 provided
src/arduino_port_expander.h:105:7: note: ArduinoPortExpander::ArduinoPortExpander(ArduinoPortExpander&&)
src/arduino_port_expander.h:105:7: note:   candidate expects 1 argument, 3 provided
/config/esphome/bedroom-plant-and-light.yaml:36:23: error: could not convert '{expander}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::Component*>'
       return {expander};
                       ^
Compiling /data/bedroom_plants_and_led/.pioenvs/bedroom_plants_and_led/lib67b/ESP8266WiFi/ESP8266WiFiSTA.cpp.o
Compiling /data/bedroom_plants_and_led/.pioenvs/bedroom_plants_and_led/lib67b/ESP8266WiFi/ESP8266WiFiScan.cpp.o
Compiling /data/bedroom_plants_and_led/.pioenvs/bedroom_plants_and_led/lib67b/ESP8266WiFi/WiFiClient.cpp.o
/config/esphome/bedroom-plant-and-light.yaml:37:3: warning: control reaches end of non-void function [-Wreturn-type]

   ^
*** [/data/bedroom_plants_and_led/.pioenvs/bedroom_plants_and_led/src/main.cpp.o] Error 1
========================= [FAILED] Took 12.66 seconds =========================

Additional information

Worked before, one of the last updates caused the issue. cannot point out which one

oxan commented 2 years ago

Your custom component needs to be updated to be compatible with the changes in 2021.10.

cicinovec commented 2 years ago

What exactly should I change? I took the example from EspHome page

oxan commented 2 years ago

@glmnet This seems to be an issue in your gist linked from the cookbook.