Manually trigger custom component update

I created a custom component (with my very limited programming skills…) to read my Multical 401 district heating meter. It does a readout every 7200 seconds (2hrs): PollingComponent with update_interval defined.
ESPhHome yaml and custom component: https://github.com/jjansen85/esphome_multical401

I tried creating a button, in combination with the component.update action.
button:

  - platform: template
    name: ${friendly_name} Update Multical
    icon: mdi:update
    id: update_multical
    on_press:
      - logger.log: "Button pressed"   
      - component.update: multical

But this gives the error
ID 'multical' of type custom_component::CustomComponentConstructor doesn't inherit from PollingComponent. Please double check your ID is pointing to the correct value.
This goes a little bit above my knowledge :wink:

Does anyone know if it is possible to integrate an manual trigger to update sensor entities based on my custom component? Any hints are welcome :slight_smile:

Small (one time) kick. Anyone with an idea how to deal with this?

I’ve seen/used at least three different approaches. Unclear which is “best”. None were quite how you approached the .h linked so you might need to experiment.

Two examples;

lambda: |-
      hilink(id(uart_bus)).getmmwConf("get_all");
      return {};

or

- lambda: 'static_cast<LD2410 *>(ld2410)->queryParameters();'
1 Like

Although I do not completely understand ‘how’ it works… it works :wink: thanks!

# Multical Custom Sensor
custom_component:
- lambda: |-
    auto my_sensor = new Multical401(7200000, id(uart_tx), id(uart_rx), id(m_energy), id(m_volume), id(m_tin), id(m_tout), id(m_tdiff), id(m_power), id(m_flow), id(m_status));
    App.register_component(my_sensor);
    return {my_sensor};
  components:
    - id: multical 

button:
- platform: template
  name: ${friendly_name} Update Multical
  icon: mdi:update
  id: update_multical
  on_press:
    - logger.log: "Button pressed"   
    - lambda: 'static_cast<Multical401 *>(multical)->update();'

‘Critical’ was to add the

components:
    - id: multical