-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotary encoder light brightness - simple.yaml
executable file
·54 lines (48 loc) · 1.46 KB
/
rotary encoder light brightness - simple.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#******************************************************************************
# ESPHome based "dimmer" - simple
# Use a rotary encoder connected to ESP32 as a dimmer for a light in Home Assistant (HA)
#
# Function:
# 1. Turn the encoder, sets HA light brightness in steps of 1% from 0-100%,
#
# Code by Patrick Felstead
#******************************************************************************
esphome:
name: rotary_encoder_set_brightness_simple
platform: ESP32
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.0.25
gateway: 192.168.0.1
subnet: 255.255.255.0
# Enable logging
logger:
level: DEBUG
api:
ota:
sensor:
#******************************************************************************
# Rotary encoder
# ESPHome docs: https://esphome.io/components/sensor/rotary_encoder.html
#******************************************************************************
- platform: rotary_encoder
name: "Rotary Encoder"
id: knob
pin_a: GPIO2
pin_b: GPIO4
resolution: 2
min_value: 0
max_value: 100
filters:
- debounce: 50ms # debounce the encoder wafers
- throttle: 100ms # limit updates if the user twists the encoder too fast :D
on_value:
then:
- homeassistant.service:
service: light.turn_on
data:
entity_id: light.lounge_table_lamp
brightness_pct: !lambda 'return x;'