esphome / issues

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

custom sensor code not working after upgrade to 2024.2.1 (custom .h file) #5535

Closed baudneo closed 8 months ago

baudneo commented 8 months ago

The problem

Immediately after upgrading, my sensors no longer report data from custom code. The logger isn working for the custom code either. It seems like the custom code isnt run at all.

Which version of ESPHome has the issue?

2024.2.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.2.3

What platform are you using?

ESP32

Board

esp-wrover-kit

Component causing the issue

includes: and sensor:custom

Example YAML snippet

esphome:
  name: vue-utility
  friendly_name: vue-utility-connect
  platform: ESP32
  board: esp-wrover-kit
  includes:
      - emporia_vue_utility.h

# This UART connects to the MGM111 ZigBee chip
uart:
  id: emporia_uart
  rx_pin: GPIO21
  tx_pin: GPIO22
  baud_rate: 115200

sensor:
  - platform: custom
    lambda: |-
      auto vue = new EmporiaVueUtility(id(emporia_uart));
      App.register_component(vue);
      return {vue->W, vue->kWh_net, vue->kWh_consumed};
    sensors:
        - name: "House Watts"
          id: house_watts
          unit_of_measurement: "W"
          accuracy_decimals: 2
          state_class: measurement
          device_class: power
          # Report every  30s or when +/- 1 watt
          # The meter seems to update every 30 seconds for watts
          filters:
              - or:
                  - throttle: 30s
                  - delta: 1  # <- watts
                  - lambda: |-
                      if (id(fast_reporting)) return(x);
                      return {};
          on_raw_value:
              then:
                  lambda: |-
                      ESP_LOGI("Vue", "Watts = %0.2f", x);

        - name: "House Net kWh"
          id: house_kwh
          unit_of_measurement: "kWh"
          accuracy_decimals: 3
          state_class: total_increasing
          device_class: energy
          # Reduce the rate of reporting the value to
          # once every 5 minutes and/or when 0.1 kwh
          # have been consumed, unless the fast_reporting
          # button has been pushed
          filters:
              - or:
                  - throttle: 5min
                  - delta: 0.1 # <- kWh
                  - lambda: |-
                      if (id(fast_reporting)) return(x);
                      return {};
          on_raw_value:
              then:
                  lambda: |-
                      ESP_LOGI("Vue", "kWh = %0.3f", x);

        - name: "House Consumed kWh"
          id: house_consumed_kwh
          unit_of_measurement: "kWh"
          accuracy_decimals: 3
          state_class: total_increasing
          device_class: energy
          filters:
              - or:
                  - throttle: 5min
                  - delta: 0.1  # <- kWh
                  - lambda: |-
                      if (id(fast_reporting)) return(x);
                      return {};
          on_raw_value:
              then:
                  lambda: |-
                      ESP_LOGI("Vue", "Consumed kWh = %0.3f", x);

Anything in the logs that might be useful for us?

Nothing in the logs I can find during compile and upload or HASS logs.

Additional information

I can include a link to the custom .h file if needed.

ssieb commented 8 months ago

github issues are not for custom components. Come ask on the esphome discord server or one of the forums for help.