the code:
substitutions:
device_name: "fan_pwm_01"
friendly_name: "Fan Pwm 01"
esphome:
name: "${device_name}"
friendly_name: "${friendly_name}"
esp8266:
board: esp8285
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxx"
ota:
password: "xxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
sensor:
- platform: pulse_counter
id: sensor_pulse_counter
pin:
number: GPIO13
inverted: true
mode:
input: true
pullup: true
name: "Fan Speed"
unit_of_measurement: 'RPM'
filters:
- multiply: 0.5
- lambda: |-
if (x <= 5000) return x;
else return {};
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
update_interval: 2s
The code can correctly calculate the RPM, and can be correctly displayed in the home assistant.
but why the entity ID is incorrect? It should be “sensor.sensor_pulse_counter” as I wrote in the code.