ESPHome - keep sensor internal to ESP node to avoid unncessary network traffic

Hi,

I created a small remote control for a light using a potentiometer to set the brightness.
Works like a charm.

However the potentiometer is attached to the adc pin (A0) and in order to have a smooth brightness, I set the update_interval to 200ms.
this means that every 200ms, the node sends the value to Home Assistant, even if it hasn’t changed (as it provides its measure, but ignoring the delta filter).

Can we set some sensors (here the adc) to remain internal to the node and not displayed as sensor in Home Assistant. This would avoid the node sending its data every 200ms…
As I have a LED attached to the board (using PWM), it flickers due to the usage of the Wifi.

In addition, such update interval and sending of measures would drastically reduce uptime in case the node is battery powered (Wifi consumes a lot).

# Example configuration entry
output:
  - platform: esp8266_pwm
    pin: D3
    frequency: 200 Hz
    id: pwm_output    
sensor:
  - platform: adc
    pin: A0
    #name: "TV Light Brightness"
    id: "set_brightness"
    filters:
     - calibrate_linear:
         - 0.0 -> 255
         - 1.0 -> 0
     - lambda: |-
         return (int)x;
     - delta: 3
    update_interval: 200ms
    on_value:
     then:
      if:
        condition:
         light.is_on: toggle_led
        then:
          - logger.log:
             format: "Stored value set to: %i"
             args: ['id(last_measure_set)']
          - homeassistant.service:
             service: light.turn_on
             data:
              entity_id: light.tv_light
              brightness: !lambda "return (int)x;"   
light:
  - platform: monochromatic
    name: "Small LED test"
    id: toggle_led
    output: pwm_output

Yep, just add internal: true.

Only specifying an id and no name will do that too.

I’ve attempted both suggestions, but my LED is still flickering, meaning some Wifi may still being used every 200ms…

Any idea how I can ensure Wifi is not used, or how I can reduce the flickering?
According to the ESP8266 Software PWM, flickering is expected when Wifi is in use…

It could also be flickering because of the low frequency. Try upping it to 10000 Hz

Just set it to 10k, but I believe i caps at 1kHz according to ESP8266 PWM specs…
But led still flickers…
If it flickers with LED, I’m a bit scared on the impact of such flickering on a servo…

ESPHome uses a different PWM method. ESPHome ESP8266 software PWM software is good for a max of 15-20kHz.

Honestly if it’s that critical I’d switch to an ESP32 board with a hardware PWM module.

I don’t mean to revive such an old thread, but I’m hoping someone can answer this. I used some of the config yaml from OPs post and it has overall been working great. The only interesting part is that when I turn the potentiometer where it registers a value of 0 by ESPHome, the light turns off completely, as in it gets toggled off in HA.

The only way to turn it back on is to toggle it back on via the HA interface. If I turn the potentiometer back up, it doesn’t turn the light on.

I tried making some changes to the code, but can’t quite figure out why this is. Any ideas?

This condition is probably preventing it turning on:

      if:
        condition:
         light.is_on: toggle_led

Bingo! That solved it. Thanks, Tom!