Created
May 28, 2025 10:10
-
-
Save peyanski/c583073713920cbaf27f6b1b4eac2e09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A resistor is needed on R19 pad | |
# Uncomment the two lines below if you want to have a web server with sensor readings | |
#web_server: | |
# port: 80 | |
uart: | |
tx_pin: 5 | |
rx_pin: 4 | |
baud_rate: 9600 | |
sensor: | |
- platform: "jsn_sr04t" | |
id: Distance | |
name: "Distance" | |
update_interval: 1s | |
# this is a template function to return percentage where 25cm = 100% , 6m = 0% | |
- platform: template | |
name: "% Full" | |
lambda: |- | |
if ((id(Distance).state) <= 0.250) { | |
return 100; | |
} | |
else if ((id(Distance).state) >= 6.000) { | |
return 0; | |
} else { | |
return (100 - ((id(Distance).state) - 0.250) / 5.75 * 100); | |
} | |
update_interval: 1s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment