dimmable led
This commit is contained in:
parent
35d2705b90
commit
c4cec09dd7
172
esp32c3-dimmable-LED.yaml
Normal file
172
esp32c3-dimmable-LED.yaml
Normal file
@ -0,0 +1,172 @@
|
||||
# LED GPIO = 1
|
||||
# Button GPIO = 9 - same as boot
|
||||
|
||||
substitutions:
|
||||
hostname: "moka1-led"
|
||||
device_name: $hostname
|
||||
wifi_update_interval: 15s
|
||||
ch1_pwm_pin: "GPIO01"
|
||||
debounce: "50ms"
|
||||
Button1: GPIO09
|
||||
|
||||
esphome:
|
||||
name: $hostname
|
||||
friendly_name: $hostname
|
||||
|
||||
esp32:
|
||||
board: esp32-c3-devkitm-1
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
api:
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
fast_connect: true
|
||||
power_save_mode: none
|
||||
|
||||
ap:
|
||||
ssid: $hostname
|
||||
password: "12345678"
|
||||
|
||||
captive_portal:
|
||||
|
||||
logger:
|
||||
level: INFO
|
||||
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
time:
|
||||
platform: homeassistant
|
||||
id: homeassistant_time
|
||||
|
||||
# default sensors
|
||||
text_sensor:
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
name: "${hostname} IP"
|
||||
icon: mdi:ip-network
|
||||
|
||||
ssid:
|
||||
name: "${hostname} SSID"
|
||||
|
||||
bssid:
|
||||
name: "${hostname} BSSID"
|
||||
|
||||
mac_address:
|
||||
name: "${hostname} MAC"
|
||||
icon: mdi:ip-network
|
||||
|
||||
- platform: template
|
||||
name: "${hostname} Uptime Human"
|
||||
id: uptime_human
|
||||
icon: mdi:timer-sand
|
||||
|
||||
- platform: version
|
||||
name: ${hostname} ESPHome Version
|
||||
icon: mdi:numeric
|
||||
|
||||
sensor:
|
||||
- platform: wifi_signal
|
||||
name: "${hostname} RSSI"
|
||||
update_interval: $wifi_update_interval
|
||||
icon: mdi:signal
|
||||
|
||||
- platform: uptime
|
||||
name: "${hostname} Uptime"
|
||||
id: uptime_sensor
|
||||
icon: mdi:timer-sand
|
||||
update_interval: $wifi_update_interval
|
||||
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();
|
||||
|
||||
# default controls
|
||||
switch:
|
||||
- platform: restart
|
||||
id: restart_switch
|
||||
name: "${hostname} Restart"
|
||||
icon: mdi:restart
|
||||
|
||||
button:
|
||||
- platform: restart
|
||||
id: restart_button
|
||||
name: "${hostname} Restart"
|
||||
icon: mdi:restart
|
||||
|
||||
# device specific
|
||||
output:
|
||||
- platform: ledc
|
||||
pin: $ch1_pwm_pin
|
||||
id: ch1_pwm
|
||||
frequency: "25000Hz"
|
||||
min_power: 0.0
|
||||
max_power: 1.0
|
||||
|
||||
light:
|
||||
- platform: monochromatic
|
||||
name: "$hostname light"
|
||||
id: led1
|
||||
output: ch1_pwm
|
||||
default_transition_length: "1.0s"
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
binary_sensor:
|
||||
- platform: status
|
||||
name: "${hostname} Status"
|
||||
icon: mdi:connection
|
||||
# Button on mini switch
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: $Button1
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
name: "${hostname} Button"
|
||||
disabled_by_default: false
|
||||
internal: true
|
||||
on_multi_click:
|
||||
# 3 clicks: 50%
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at most 0.5s
|
||||
- ON for at most 0.5s
|
||||
- OFF for at most 0.5s
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: led1
|
||||
brightness: 50%
|
||||
# short click: toggle
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- light.toggle: led1
|
||||
# long click: 100%
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: led1
|
||||
brightness: 100%
|
||||
|
Loading…
Reference in New Issue
Block a user