substitutions:
devicename: taiden_esp32c3_c0ab60
esphome:
name: ${devicename}
platform: ESP32
board: esp32-c3-devkitm-1
platformio_options:
platform: https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
platform_packages:
- framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.0
board_build.variant: esp32c3
board_build.f_cpu: 160000000L
board_build.f_flash: 40000000L
upload_protocol: esptool
board_build.flash_mode: dio
wifi: {ssid: "cc",password: "xxxxxxxxxxx",fast_connect: true}
api: {password: "xxxxxxxxxxx",reboot_timeout: 0s}
ota: {password: "xxxxxxxxxxx"}
web_server: {port: 80}
logger:
output:
- platform: ledc
pin: GPIO5
id: pwm
inverted: False
light:
- platform: monochromatic
name: ${devicename}_light1
output: pwm
default_transition_length: 0s
id: light_1
binary_sensor:
- platform: gpio
internal: true
id: button_1
pin: {number: "GPIO20", inverted: true, mode: "INPUT_PULLUP"}
on_press: {light.toggle: light_1}
sensor:
- platform: rotary_encoder
id: my_rotary_encoder
pin_a: GPIO19
pin_b: GPIO18
on_clockwise:
then:
- if:
condition:
lambda: 'return id(light_1).current_values.get_brightness() > 0.85;'
then:
- light.turn_on:
id: light_1
brightness: 85%
else:
- light.dim_relative:
id: light_1
relative_brightness: 5% #增加5%
transition_length: 0.1s
- delay: 0.1s
on_anticlockwise:
then:
- if:
condition:
lambda: 'return id(light_1).current_values.get_brightness() < 0.35;'
then:
- light.turn_off:
id: light_1
else:
- light.dim_relative:
id: light_1
relative_brightness: -5% #减少5%
transition_length: 0.1s
- delay: 0.1s
|