esphome / issues

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

Changes to custom output component not reflected when using Dashboard #4439

Closed nealcarney closed 1 year ago

nealcarney commented 1 year ago

The problem

Changes to my custom output component will not be reflected in new firmware when updating from HA Dashboard, using either USB or WiFi. If I do manual install via download and then update with ESPHome Web, the changes will be reflected.

  1. Created node with custom output component.
  2. Installed firmware with USB = works fine.
  3. Made changes to custom output component.
  4. Installed firmware with USB = does not reflect changes.
  5. Installed firmware with ESPHome Web = reflected the changes.

Original my_output.h:

#include "esphome.h"
using namespace esphome;

class MyCustomFloatOutput : public Component, public FloatOutput {
    public:
    void setup() override {
        // This will be called by App.setup()
        pinMode(23, OUTPUT);
    }

    void write_state(float state) override {
        // state is the amount this output should be on, from 0.0 to 1.0
        // we need to convert it to an integer first
        int value = state * 10;
        ESP_LOGD("lambda", "Hello World v1");
    }
};

Revised my_output.h:

#include "esphome.h"
using namespace esphome;

class MyCustomFloatOutput : public Component, public FloatOutput {
    public:
    void setup() override {
        // This will be called by App.setup()
        pinMode(23, OUTPUT);
    }

    void write_state(float state) override {
        // state is the amount this output should be on, from 0.0 to 1.0
        // we need to convert it to an integer first
        int value = state * 10;
        ESP_LOGD("lambda", "Hello World v2");
    }
};

Log after creating original code and installing from Dashboard with USB:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[I][logger:259]: Log initialized
[C][ota:469]: There have been 1 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[D][fan:092]: 'maxxfan' - Sending state:
[D][fan:093]:   State: OFF
[D][fan:095]:   Speed: 0
[D][lambda:015]: Hello World v1

Log after modifying custom output component and installing with USB:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[I][logger:259]: Log initialized
[C][ota:469]: There have been 1 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[D][fan:092]: 'maxxfan' - Sending state:
[D][fan:093]:   State: OFF
[D][fan:095]:   Speed: 0
[D][lambda:015]: Hello World v1

Log after modifying custom output component and installing with ESPHome Web:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[I][logger:259]: Log initialized
[C][ota:469]: There have been 1 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[D][fan:092]: 'maxxfan' - Sending state:
[D][fan:093]:   State: OFF
[D][fan:095]:   Speed: 0
[D][lambda:015]: Hello World v2

Which version of ESPHome has the issue?

2023.4.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.4.1

What platform are you using?

ESP32

Board

wemos_d1_mini32

Component causing the issue

Output

Example YAML snippet

esphome:
  name: test1
  friendly_name: Test1
  includes: my_output.h

globals:
  - id: actual_fan_speed
    type: int
    restore_value: no
    initial_value: '1'

fan:
    - platform: speed
      id: maxxfan
      output: custom_float
      speed_count: 10 

output:
  - platform: custom
    type: float 
    lambda: |-
      auto my_custom_float_output  = new MyCustomFloatOutput();
      App.register_component(my_custom_float_output );
      return {my_custom_float_output };
    outputs:
      id: custom_float

Anything in the logs that might be useful for us?

No response

Additional information

No response

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.