esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

Lambda in set_pulse_total on RP2040 gives error #4099

Open Coornh opened 1 year ago

Coornh commented 1 year ago

The problem

Hello, First of all great work with the support of RP2040!

I'm trying to use the PR2040, but when I include the set_pulse_total with lambda the compilation fails.

This works:

    - service: reset_pulse_total
      then:
        - pulse_meter.set_total_pulses:
            id: water_meter_pulses
            value: 0

This doesn't:

    - service: set_pulse_total
      variables:
        new_pulse_total: int
      then:
        - pulse_meter.set_total_pulses:
            id: water_meter_pulses
            value: !lambda 'return new_pulse_total;'

I don't why, according to this example: Pulse Counter Sensor

Which version of ESPHome has the issue?

2022.12.8

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?

RP2040

Board

rpipicow

Component causing the issue

No response

Example YAML snippet

esphome:
  name: rpi-pico-2

rp2040:
  board: rpipicow
  framework:
    # Required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged
    platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "-"
  services:
    - service: set_pulse_total
      variables:
        new_pulse_total: int
      then:
        - pulse_meter.set_total_pulses:
            id: water_meter_pulses
            value: !lambda 'return new_pulse_total;'
    - service: reset_pulse_total
      then:
        - pulse_meter.set_total_pulses:
            id: water_meter_pulses
            value: 0
ota:
  password: "-"

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

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: "Rpi-Pico-2 Fallback Hotspot"
    password: "xG6Gw41FDcG0"

# https://esphome.io/components/sensor/pulse_meter.html
sensor:
  - platform: pulse_meter
    pin: GPIO12
    name: "Water Pulse Meter"
    id: water_meter_pulses
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    total:
      name: "Water Meter Total"
      unit_of_measurement: "m³"
      id: water_meter_total
      accuracy_decimals: 3
      device_class: water
      state_class: total_increasing
      icon: "mdi:water"
      filters:
        - multiply: 0.001

Anything in the logs that might be useful for us?

INFO Reading configuration /config/esphome/rpi-pico-2.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing rpi-pico-2 (board: rpipicow; framework: arduino; platform: https://github.com/maxgerhardt/platform-raspberrypi.git)
--------------------------------------------------------------------------------
HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash
 - framework-arduinopico @ 1.20604.0 (2.6.4) 
 - tool-rp2040tools @ 1.0.2 
Flash size: 2.00MB
Sketch size: 1.00MB
Filesystem size: 1.00MB
Maximium Sketch size: 1044480 EEPROM start: 0x101ff000 Filesystem start: 0x100ff000 Filesystem end: 0x101ff000
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- WiFi @ 1.0.0
|   |-- Updater @ 1.0
|   |   |-- MD5Builder @ 1.0.0
|   |   |-- LittleFS @ 0.1.0
|   |   |-- PicoOTA @ 1.0.0
|   |   |   |-- LittleFS @ 0.1.0
|   |-- MD5Builder @ 1.0.0
|   |-- lwIP-Ethernet @ 1
|   |   |-- lwIP_CYW43 @ 1
|   |   |   |-- SPI @ 1.0
|   |   |-- SPI @ 1.0
|   |-- lwIP_CYW43 @ 1
|   |   |-- SPI @ 1.0
|   |-- SPI @ 1.0
|-- LEAmDNS @ 1.2
|   |-- lwIP-Ethernet @ 1
|   |   |-- lwIP_CYW43 @ 1
|   |   |   |-- SPI @ 1.0
|   |   |-- SPI @ 1.0
|   |-- WiFi @ 1.0.0
|   |   |-- Updater @ 1.0
|   |   |   |-- MD5Builder @ 1.0.0
|   |   |   |-- LittleFS @ 0.1.0
|   |   |   |-- PicoOTA @ 1.0.0
|   |   |   |   |-- LittleFS @ 0.1.0
|   |   |-- MD5Builder @ 1.0.0
|   |   |-- lwIP-Ethernet @ 1
|   |   |   |-- lwIP_CYW43 @ 1
|   |   |   |   |-- SPI @ 1.0
|   |   |   |-- SPI @ 1.0
|   |   |-- lwIP_CYW43 @ 1
|   |   |   |-- SPI @ 1.0
|   |   |-- SPI @ 1.0
|-- Updater @ 1.0
|   |-- MD5Builder @ 1.0.0
|   |-- LittleFS @ 0.1.0
|   |-- PicoOTA @ 1.0.0
|   |   |-- LittleFS @ 0.1.0
|-- noise-c @ 0.1.4
|   |-- libsodium @ 1.10018.1
|-- MD5Builder @ 1.0.0
Compiling /data/rpi-pico-2/.pioenvs/rpi-pico-2/src/main.cpp.o
Linking /data/rpi-pico-2/.pioenvs/rpi-pico-2/firmware.elf
/data/cache/platformio/packages/toolchain-rp2040-earlephilhower/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld: /data/rpi-pico-2/.pioenvs/rpi-pico-2/src/main.cpp.o: in function `_ZN7esphome3api15UserServiceBaseIJlEE15execute_serviceERKNS0_21ExecuteServiceRequestE':
main.cpp:(.text._ZN7esphome3api15UserServiceBaseIJlEE15execute_serviceERKNS0_21ExecuteServiceRequestE[_ZN7esphome3api15UserServiceBaseIJlEE15execute_serviceERKNS0_21ExecuteServiceRequestE]+0x28): undefined reference to `_ZN7esphome3api21get_execute_arg_valueIlEET_RKNS0_22ExecuteServiceArgumentE'
/data/cache/platformio/packages/toolchain-rp2040-earlephilhower/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld: /data/rpi-pico-2/.pioenvs/rpi-pico-2/src/main.cpp.o: in function `_ZN7esphome3api15UserServiceBaseIJlEE28encode_list_service_responseEv':
main.cpp:(.text._ZN7esphome3api15UserServiceBaseIJlEE28encode_list_service_responseEv[_ZN7esphome3api15UserServiceBaseIJlEE28encode_list_service_responseEv]+0x2a): undefined reference to `_ZN7esphome3api19to_service_arg_typeIlEENS0_5enums14ServiceArgTypeEv'
collect2: error: ld returned 1 exit status
*** [/data/rpi-pico-2/.pioenvs/rpi-pico-2/firmware.elf] Error 1
========================= [FAILED] Took 15.98 seconds =========================

Additional information

No response

hirppa10 commented 1 year ago

I'm having the same issue