Abstandssensor/Abstandssensor.yaml

129 lines
2.8 KiB
YAML
Raw Normal View History

2022-05-16 15:26:02 +02:00
esphome:
name: parksensor
platform: ESP8266
board: d1_mini
captive_portal:
wifi:
ssid: "YOUR-WIFI-SSID"
password: "YOUR-WIFI-KEY"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Abstandssensor Fallback Hotspot"
password: "FALLBACK-WIFI-KEY"
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.10.136
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.10.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
dns1: 192.168.10.1
globals:
- id: active
type: bool
restore_value: no
initial_value: "false"
mqtt:
broker: your.mqtt.broker.org
topic_prefix: "esphome"
on_json_message:
topic: hm/status/Garage_Licht/STATE
# topic: hm/status/1OG_Flur_Licht/STATE
then:
- lambda: !lambda |-
bool state = false;
if (x.containsKey("val"))
state = x["val"];
id(active) = state;
# Enable logging
logger:
level: INFO
# Enable Home Assistant API
# api:
web_server:
port: 80
ota:
password: "YOUR-OTA-PASSWORD"
uart:
rx_pin: GPIO12
tx_pin: GPIO13
baud_rate: 9600
id: uart_mhz19
sensor:
- platform: ultrasonic
id: us_sensor
trigger_pin: D0
echo_pin: D1
update_interval: 0.5s
name: "Ultrasonic Sensor"
on_value:
then:
- if:
condition:
lambda: 'return !id(active);'
then:
- light.turn_off:
id: led_ring
- if:
condition:
lambda: 'return (id(active) && (id(us_sensor).state >= id(poti).state*1.5));'
then:
- light.turn_on:
id: led_ring
red: 0%
green: 100%
blue: 0%
- if:
condition:
lambda: 'return ( id(active) && ((id(us_sensor).state) < (id(poti).state*1.5) && (id(us_sensor).state >= id(poti).state)) );'
then:
- light.turn_on:
id: led_ring
red: 100%
green: 100%
blue: 0%
- if:
condition:
lambda: 'return ( id(active) && (id(us_sensor).state < id(poti).state));'
then:
- light.turn_on:
id: led_ring
red: 100%
green: 0%
blue: 0%
- platform: adc
id: poti
pin: A0
name: "Potentiomenter"
update_interval: 1s
filters:
- lambda: return x;
unit_of_measurement: "m"
light:
- platform: neopixelbus
id: led_ring
type: GRB
variant: WS2812
pin: GPIO3
num_leds: 8
default_transition_length: 0.1s
name: "NeoPixel Light"