Hey Guys,
I’m using a HC-SR04 to measure some distance.
Sometimes the differences between the measurements are low, 1, 2 or 3 millimeters.
Is there any way directly in ESPHome to ignore that low changes and only send the new measurement if the difference is above, lets say, 3 mm?
This is my config file:
esphome:
name: esphome-web-0c14f8
esp8266:
board: esp01_1m
# Enable logging
logger:
level: VERBOSE
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-0C14F8"
password: "f0SZDyGJNFc3"
captive_portal:
text_sensor:
- platform: wifi_info
ip_address:
name: ESP IP Address
ssid:
name: ESP Connected SSID
- platform: template
name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start
sensor:
- platform: uptime
name: Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
- platform: ultrasonic
trigger_pin: GPIO14
echo_pin: GPIO12
name: "Zoutniveau waterontharder"
update_interval: 2s
timeout: 2.0m
filters:
# Replace the 0.42 by the height of your container. From the sensor to the bottom.
# I multiplied by 100 in order to get CM since the sensor works in meters
- lambda: return (0.51-x)*100;
unit_of_measurement: "cm"
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: 60s