Custom component with multiple sensors?

Hi

If you create a custom sensor, use the HomeAssistant API, and the definition in the yaml file looks like:

  - platform: custom
    lambda: |-
      auto k382Lx7 = new K382Lx7(id(uart_bus));
      App.register_component(k382Lx7);
      return {
        k382Lx7->totEnergyIn_sensor, 
        k382Lx7->totEnergyOut_sensor, 
        k382Lx7->EnergyInHiRes_sensor, 
        k382Lx7->EnergyOutHiRes_sensor, 
        k382Lx7->CurrentPowerIn_sensor
};  

Would it somehow be possible only to update individual sensors - instead of everything at once ? For example, if no new reading exists on k382Lx7->EnergyInHiRes_sensor - the corresponding sensor:

      - name: "${friendly_short} Energy In HiRes"
        unit_of_measurement: "kWh"
        accuracy_decimals: 3
        device_class: energy
        state_class: total_increasing 

Should not be updated in Home Assistant ?

Regards
Brian

Could you use filters on the individual sensors?

So you update them all internally on the ESP, but reduce what is sent to HA.

The code in the - platform: custom lambda only gets executed once to initialize the sensors. The sensors themselves get updated when .publish_state(newValue) is executed in the custom component.