esphome / issues

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

missing strptime function for rp2040 platform #6171

Open zencow opened 3 weeks ago

zencow commented 3 weeks ago

The problem

when compiling for a rpipicow device, I got the following error:

/config/esphome/zenp02.yaml: In lambda function:
/config/esphome/zenp02.yaml:1188:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1188 |         strptime(id(fin01).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime

Which version of ESPHome has the issue?

ESPHome 2024.7.3

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

Home Assistant Core 2024.6.4 / Home Assistant OS 12.4

What platform are you using?

RP2040

Board

Raspberry Pi Pico W

Component causing the issue

lambda

Example YAML snippet

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

## I2C bus
i2c:
  sda: 20
  scl: 21
  scan: true
  id: bus_a
  frequency: 800kHz

time:
  - platform: homeassistant
    id: homeassistant_time

text_sensor:
  - platform: homeassistant
    entity_id: timer.timer01
    id: fin01
    attribute: finishes_at
    internal: true
  - platform: homeassistant
    id: timer01
    entity_id: timer.timer01

font:
  - file: 'fonts/consola.ttf'
    id: font3
    size: 12

display:
## external SSD1306 OLED (SH1106?)
  - platform: ssd1306_i2c
    id: oled_display
    model: "SSD1306 128x64"
    address: 0x3D
    contrast: "1%"
    rotation: 90
    flip_x: false
    flip_y: false
    offset_y: 96
    offset_x: 0
    external_vcc: true
    update_interval: 1.0s
    lambda: |-
      struct tm tm_ha_time_utc{};
      time_t t_now_utc;

      tm_ha_time_utc = id(homeassistant_time).utcnow().to_c_tm(); // Get current time in a tm struct
      t_now_utc = mktime(&tm_ha_time_utc);

      if (id(timer01).state == "active" && id(fin01).has_state()) {
        struct tm tm_finish{};
        double remain;
        int remain_h, remain_m, remain_s;

        strptime(id(fin01).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
        remain = difftime(mktime(&tm_finish), t_now_utc); // Calculate difference in seconds

        remain_h = (int) remain/3600;
        remain_m = (int) (remain - 3600*remain_h)/60;
        remain_s = (int) remain - 3600*remain_h - 60*remain_m;         

        it.printf(32, 0, id(font3), TextAlign::TOP_CENTER, "%02d:%02d:%02d", remain_h, remain_m, remain_s);
      }

Anything in the logs that might be useful for us?

INFO ESPHome 2024.7.3
INFO Reading configuration /config/esphome/zenp02.yaml...
INFO Detected timezone 'America/Los_Angeles'
INFO Generating C++ source...
INFO Generating PIO assembly code
INFO Compiling app...
Processing zenp02 (board: rpipicow; framework: arduino; platform: https://github.com/maxgerhardt/platform-raspberrypi.git)
--------------------------------------------------------------------------------
HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash
 - framework-arduinopico @ 1.30702.0 (3.7.2) 
 - tool-pioasm-rp2040-earlephilhower @ 5.100300.230216 (10.3.0) 
 - 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
Dependency Graph
|-- WiFi @ 1.0.0
|-- LEAmDNS @ 1.2
|-- Updater @ 1.0
|-- noise-c @ 0.1.4
|-- Wire @ 1.0
|-- MD5Builder @ 1.0.0
|-- lwIP-Ethernet @ 1
|-- lwIP_CYW43 @ 1
|-- SPI @ 1.0
Compiling .pioenvs/zenp02/src/main.cpp.o
Archiving .pioenvs/zenp02/lib2c6/libLittleFS.a
Archiving .pioenvs/zenp02/lib31a/libPicoOTA.a
Compiling .pioenvs/zenp02/lib26c/Updater/Updater.cpp.o
Compiling .pioenvs/zenp02/lib107/WiFi/BearSSLHelpers.cpp.o
Compiling .pioenvs/zenp02/lib107/WiFi/CertStoreBearSSL.cpp.o
Compiling .pioenvs/zenp02/lib107/WiFi/WiFiClass.cpp.o
Archiving .pioenvs/zenp02/lib26c/libUpdater.a
Compiling .pioenvs/zenp02/lib107/WiFi/WiFiClient.cpp.o
Compiling .pioenvs/zenp02/lib107/WiFi/WiFiClientSecureBearSSL.cpp.o
/config/esphome/zenp02.yaml: In lambda function:
/config/esphome/zenp02.yaml:1188:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1188 |         strptime(id(fin01).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
/config/esphome/zenp02.yaml:1202:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1202 |         strptime(id(fin02).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
/config/esphome/zenp02.yaml:1216:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1216 |         strptime(id(fin03).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
/config/esphome/zenp02.yaml:1230:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1230 |         strptime(id(fin04).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
/config/esphome/zenp02.yaml:1244:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1244 |         strptime(id(fin05).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
/config/esphome/zenp02.yaml:1258:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1258 |         strptime(id(fin06).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
/config/esphome/zenp02.yaml:1272:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1272 |         strptime(id(fin07).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
/config/esphome/zenp02.yaml:1286:9: error: 'strptime' was not declared in this scope; did you mean 'strftime'?
 1286 |         strptime(id(fin08).state.c_str(), "%Y-%m-%dT%T%z", &tm_finish); // Convert string to time struct
      |         ^~~~~~~~
      |         strftime
Compiling .pioenvs/zenp02/lib107/WiFi/WiFiMulti.cpp.o
Compiling .pioenvs/zenp02/lib107/WiFi/WiFiNTP.cpp.o
*** [.pioenvs/zenp02/src/main.cpp.o] Error 1
========================= [FAILED] Took 36.62 seconds =========================

Additional information

I was trying to run working code from one of my esp32 nodes on a pico w. I'm guessing that the function strptime has not been implemented in the rp2040 platform.

On my esp32 node, this code displays the countdowns of running timers from Home Assistant on an oled display. I wanted it running on the pico that has the start/stop buttons for those timers. If the strptime function is implemented, that would be a step towards parity with the esp32 code.

zencow commented 3 weeks ago

should this actually be filed against maxgerhardt/platform-raspberrypi instead?