Last active
April 15, 2023 04:05
-
-
Save zeroping/1679b9d32e38f6e982bc7e445548ff7b to your computer and use it in GitHub Desktop.
Esphome config for ESP32-based Linkind dimmer switches
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
# Basic Config | |
#--- | |
#substitutions: | |
# # https://esphome.io/guides/configuration-types.html#substitutions | |
# device_name: esp-br3 # hostname & entity_id | |
# transition_length: 0s # transition when turning on/off | |
## Uses a JST24A triac and a second MCU for dimming | |
esphome: | |
# https://esphome.io/components/esphome | |
name: ${device_name} | |
on_boot: | |
priority: 400 | |
then: | |
- lambda: !lambda |- | |
ESP_LOGI("i2cdimmer", "send dimmer init" ); | |
const uint8_t tosend [] = {0x2A, 0x07, 0x56, 0x01, 0x11, 0xFF, 0x66}; | |
ErrorCode ret = myi2cbus->write(0x50, tosend, 7); | |
ESP_LOGI("i2cdimmer", "result: %d", (int)ret ); | |
esp32: | |
board: esp32dev | |
framework: | |
type: esp-idf | |
sdkconfig_options: | |
CONFIG_FREERTOS_UNICORE: y | |
wifi: | |
# should get set by wifi.yaml | |
#captive_portal: | |
# doesn't work under esp-idf | |
#web_server: | |
#port: 80 | |
# https://esphome.io/components/web_server.html | |
# doesn't work under esp-idf | |
logger: | |
# https://esphome.io/components/logger | |
api: | |
#password: !secret esphome_api_password | |
# https://esphome.io/components/api | |
reboot_timeout: 0s #disable auto-reboot if homeassistant is not connecting | |
ota: | |
#password: !secret esphome_ota_password | |
# https://esphome.io/components/ota | |
i2c: | |
sda: GPIO4 | |
scl: GPIO22 | |
sda_pullup_enabled: true | |
scl_pullup_enabled: true | |
frequency: 100kHz | |
scan: false | |
id: myi2cbus | |
#light: | |
#- platform: status_led | |
#name: "Switch state" | |
#pin: GPIO2 | |
light: | |
- platform: monochromatic | |
# https://esphome.io/components/light/monochromatic.html | |
name: ${device_name} dimmer | |
output: dimi2c | |
default_transition_length: ${transition_length} | |
#gamma_correct: 0 # if we want to disable | |
id: dimmer | |
on_turn_on: | |
- output.turn_on: | |
id: green_led | |
on_turn_off: | |
- output.turn_off: | |
id: green_led | |
- platform: binary | |
id: greenlight | |
name: ${device_name} green led | |
output: green_led | |
- platform: status_led | |
#id: redlight | |
name: ${device_name} red led | |
pin: GPIO26 | |
output: | |
- platform: template | |
id: dimi2c | |
type: float | |
min_power: 0.1 | |
zero_means_zero: true | |
write_action: | |
lambda: !lambda |- | |
uint8_t dim_val = 255 * state; | |
uint16_t chk = 65403-dim_val; | |
const uint8_t tosend [] = {0x2A, 0x09, 0x50 ,0x01, dim_val, 0x00, 0x00, (uint8_t)(chk>>8), (uint8_t)(chk)}; | |
ErrorCode ret = myi2cbus->write(0x50, tosend, 9); | |
ESP_LOGI("i2cdimmer", "result: %d", (int)ret ); | |
- platform: gpio | |
# https://esphome.io/components/output/gpio.html | |
pin: GPIO14 | |
inverted: false | |
id: green_led | |
binary_sensor: | |
- platform: gpio | |
# https://esphome.io/components/binary_sensor/gpio.html | |
pin: | |
number: GPIO32 | |
inverted: true | |
mode: INPUT_PULLUP | |
name: ${device_name} Top Button | |
internal: false | |
on_click: | |
- min_length: 50ms | |
max_length: 350ms | |
then: | |
- light.turn_on: | |
id: dimmer | |
brightness: 70% | |
on_multi_click: | |
- timing: | |
- ON for at least 350ms | |
then: | |
- light.turn_on: | |
id: dimmer | |
brightness: 100% | |
- platform: gpio | |
# https://esphome.io/components/binary_sensor/gpio.html | |
pin: | |
number: GPIO33 | |
inverted: true | |
mode: INPUT_PULLUP | |
name: ${device_name} Bottom Button | |
internal: False | |
on_click: | |
- min_length: 50ms | |
max_length: 350ms | |
then: | |
- light.turn_off: dimmer | |
on_multi_click: | |
- timing: | |
- ON for at least 400ms | |
then: | |
- light.turn_on: | |
id: dimmer | |
brightness: 35% | |
#- output.turn_on: led2 | |
New to ESPHome (hace used Tasmota on this switch)..... How add/activate BLE sensors?
@balvant813 when I tried a few months ago, this version of the ESP32 didn't support any of the new BLE code. No idea if it can work now, but I haven't tried it since.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@zeroping & @jschwalbe
I was using this config and wanted to add BLE as well - flashed over serial and everything looked good.
When I went to OTA I got the error
Error receiving acknowledge binary size: timed out
.I did some digging, and found out that it's timing out during the upload.
SO - to fix it, comment out BLE and add the SDKConfig value
CONFIG_ESP_TASK_WDT_TIMEOUT_S: "10"
.Push this OTA to increase the timeout, then after that is successful, uncomment the BLE stuff and it will OTA without error.
I just did this a few minutes ago, and so far everything is working and looks good (I did reassemble the device and put it on mains so power wasn't an issue).
Cheers!
DeadEnd