How to configure the publication of an esphome sensor to HA?

Hello ,
I have created a sensor in esphome . This sensor has an update_interval of 1 second. This is necessary for other sensors to calculate their value.
I would like to manage the frequency of publication of this sensor in Home Assistant .
To do this, I had defined this sensor as internal: True
and via a trigger add component.update:

In the log, I see that the sensor publishes its status every second despite internal being set to True.
Do you have an idea for solving this problem?

Can you share your esphome config please?

here are the extracts from the yaml file (if you prefer the whole file, I can include it)
here are some of the sensors :

- platform: adc
    pin: GPIO4
    id: adc_sensor_id_4
    accuracy_decimals: 5
    attenuation: 12db # see :     since esphome 2024.5.0 change 11db to 12db 
                      # on the ESP32-S2 page :Attenuation(db) :6 , suggested range (mV ) :  0 ~ 1300  , Attenuation(db) :11 , suggested range (mV ) :  0 ~ 2500  
    update_interval: 1s
    internal: true

  - platform: ct_clamp
    sensor: adc_sensor_id_4
    name: "Sensor Live Current Burner"
    id: "sensor_live_current_burner"
    update_interval: 1s
    accuracy_decimals: 3
    device_class: current
    unit_of_measurement: "A"
    icon: "mdi:current-ac"
    internal: true  # This setting prevents it from publishing updates to Home Assistant directly. Instead, it just updates the global variable.
    sample_duration: 200ms
      - calibrate_linear:
          method: exact
            - 0 -> 0
            - 0.009 -> 0.0   #  zero load state :Raw AC Value: 0.019A
            - 0.040 -> 0.14
  #     Override with a fixed value for testing
  #    - lambda: return 0.2;  # Set to whatever fixed value you need to test the program

then the script :

  - id: check_threshold
    then:  # can't use a substution so need to be hardcoded , alternative create a global variable see above
      - lambda: |- 
          if (id(burner_on).state) {
            id(seconds_above_threshold_burner) += 1;
          } ;
          if (id(boiler_on).state) {
            id(seconds_above_threshold_boiler) += 1;   
          if (id(house_on).state) {
            id(seconds_above_threshold_house) += 1;   
          if (id(workshop_on).state) {
            id(seconds_above_threshold_workshop) += 1;   

  - id: publish_and_reset
      - component.update: sensor_live_current_burner
      - component.update: sensor_live_current_boiler
      - component.update: sensor_live_current_house
      - component.update: sensor_live_current_workshop
      - component.update: ct1Watts
      - component.update: ct2Watts
      - component.update: ct3Watts
      - component.update: ct4Watts  
      - component.update: seconds_per_minute_burner
      - component.update: seconds_per_minute_boiler
      - component.update: seconds_per_minute_house
      - component.update: seconds_per_minute_workshop
      - component.update: calculated_fuel_consumption
      - lambda: |-
          ESP_LOGD("custom", "Publishing Seconds: %d", id(seconds_above_threshold_burner) , id(fioul_l_per_hour) , id(fioul_used_since_refilling) );
          float new_value = id(fioul_used_since_refilling).state + id(calculated_fuel_consumption).state;

#          id(seconds_per_minute_burner).publish_state(id(seconds_above_threshold_burner));
#          id(fioul_used_since_refilling) += id(calculated_fuel_consumption).state; 
      - globals.set:
          id: seconds_above_threshold_burner
          value: '0'
      - globals.set:    
          id: seconds_above_threshold_boiler
          value: '0'
      - globals.set:    
          id: seconds_above_threshold_house
          value: '0'
      - globals.set:    
          id: seconds_above_threshold_workshop
          value: '0'
      - delay: 1000ms  # Ensure it delays slightly to avoid any race condition with last-second updates    

and the interval

  - interval: 1s
      - script.execute: check_threshold

  - interval: "${publish_sec}s"
      - script.execute: publish_and_reset

  - interval: 1h
      - script.execute: reset_hourly

  - interval: 24h
      - script.execute: reset_daily

^^ can You share definition of too.

IMHO with internal: true state will not be published to HA.
As well component.update trigger component reading, not publishing to HA.

substitutions:  # if the value is static and won't change during runtime. Substitution variables are set at compile-time and are consistent across the device's firmware. 
  device_name: "chaudieres21"
  device_friendly_name: "Chaudiere S2"
#  device_platform: ESP8266
#  device_board: d1_mini
  device_area: Buanderie
  publish_sec: '60'   # interval for publishing the sensors data in Home Assistant in sec 
globals:  #  if the value may need to change dynamically during runtime. Global variables are appropriate for values that might need to be updated based on conditions 
          #      or events while the device is operating.

  - id: publish_seconds  #  to use the substitution value inside a lambda, it needs to be set as a global variable's initial value
    type: int
    restore_value: no
    initial_value: '${publish_sec}'

That’s normal, the log shows you ‘everything’ and isn’t indicative of what it’s actually sending to HA during normal operation.

Hi Masterzz ,
thanks for your feedback
What is the meaning of IMHO ?

Hi brooksben11 ,
is there a way via the log ( or via an other way) to see only what is publish in HA ?

in the documentation : Actions, Triggers, Conditions — ESPHome
it seems that you can manually call the update() method of a component not the reading of it

In My Humble Opinion

Developer Tools / Events in HA, listen to state_changed.