Blink, how? (Part 2)

Yes, I asked a few months ago and got a lot of assistance, and the solution from another forum user.
I can blink an LED full-time now.

However, my question.
I have a Dallas DS8b20 sensor and I want to blink an LED if the temperature goes above a set point. Here is my YAML code:

# Simple thermometer. A DS18b20 sensor and an SSD1306 128x64 OLED display
#
substitutions:
  device_name: thermometer
  
esphome:
  name: ${device_name}
  
esp8266:
  board: d1_mini

logger:
  level: VERBOSE

api:

ota:
  safe_mode: True

packages:
  wifi: !include common/wifi.yaml
  
output:
    platform: slow_pwm
    pin: D5
    id: my_slow_pwm
    period: 500ms
    inverted: false
    min_power: 0.01
    max_power: 1.00
    
sensor:
  - platform: dallas
    address: 0xd00217924557a228
    name: ${device_name} Temperature
    id: temperature
    resolution: 9
    on_value_range:
      - above: 27.0
        then:
          - output.turn_on: my_slow_pwm
      - below: 26.0
        then:
          - output.turn_off: my_slow_pwm
    
dallas:
  - pin: D4
    update_interval: 5.0s
    
i2c:
  sda: D2
  scl: D1
  frequency: 800kHz

font:
  - file: 'arial.ttf'
    id: font1
    size: 12  
  - file: 'arialbd.ttf'
    id: font2
    size: 16   

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.print(0, 0, id(font1), "Temperature");  
      if (id(temperature).has_state()) {
        it.printf(0, 15, id(font2), TextAlign::TOP_LEFT, "%.1f°C", id(temperature).state);
      }
      

Here’s the problem I need help with.
The LED on D5 (GPIO14) blinks randomly then the sensor temperature is outside of the on_value_range, and when in range it is on solid. No blink.

Any tips would be appreciated. (I picked the setpoint temperatures because I could raise the sensor temperature by pinching it between my fingers. In real use it will be monitoring my freezer temperature and alarming if the temperature goes above 0°C.)

Please read the documentation for on_value_range (again) Sensor Component — ESPHome

This trigger will only trigger when the new value is inside the range and the previous value was outside the range.

  • above (Optional) The minimum for the trigger.
  • below (Optional) The maximum for the trigger.

So it will trigger if the value is BETWEEN the above AND below boundary.

Thanks, it’s clear now. I added an interval trigger that tests sensor.in_range: and now the LED comes on above the trigger temperature and off when below. Here’s the (almost) working YAML file. (Almost because slow_pwm is not working as expected. The LED does not blink. It’s either on or off.)

I have used slow_pwm this way before, so I am going back to the docs to see why it isn’t blinking now. (Unless you see something obvious…)

# Simple thermometer. A DS18b20 sensor and an SSD1306 128x64 OLED display
#
substitutions:
  device_name: thermometer
  
esphome:
  name: ${device_name}
  
esp8266:
  board: d1_mini

logger:
  level: VERBOSE

api:

ota:
  safe_mode: True

packages:
  wifi: !include common/wifi.yaml
  
output:
    platform: slow_pwm
    pin: D5
    id: my_slow_pwm
    period: 200ms
    inverted: false

sensor:
  - platform: dallas
    address: 0xd00217924557a228
    name: ${device_name} Temperature
    id: temperature
    resolution: 9
    
interval:
  - interval: 500ms
    then:
      if:
        condition:
          sensor.in_range:
            id: temperature
            above: 23.0
        then:
          output.turn_on: my_slow_pwm
        else:
          output.turn_off: my_slow_pwm

dallas:
  - pin: D4
    update_interval: 5.0s
    
i2c:
  sda: D2
  scl: D1
  frequency: 800kHz

font:
  - file: 'arial.ttf'
    id: font1
    size: 12  
  - file: 'arialbd.ttf'
    id: font2
    size: 16   

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.print(0, 0, id(font1), "Temperature");  
      if (id(temperature).has_state()) {
        it.printf(0, 15, id(font2), TextAlign::TOP_LEFT, "%.1f°C", id(temperature).state);
      }