From dd835b29c7a5a6dfe67e0fed9190589868ff54ee Mon Sep 17 00:00:00 2001 From: Jakob Lechner Date: Wed, 20 Aug 2025 11:10:21 +0200 Subject: [PATCH] Add esphome example --- esphome/dimmer.yaml | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 esphome/dimmer.yaml diff --git a/esphome/dimmer.yaml b/esphome/dimmer.yaml new file mode 100644 index 0000000..c9521b4 --- /dev/null +++ b/esphome/dimmer.yaml @@ -0,0 +1,62 @@ +esphome: + name: dimmer + +esp32: + board: esp32doit-devkit-v1 + +logger: + +api: + encryption: + key: !secret apikey_dimmer + +ota: + - platform: esphome + password: !secret otapass_dimmer + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + enable_on_boot: True + +light: + - platform: cwww + name: "LED light" + id: led_light + cold_white: output_cold + warm_white: output_warm + cold_white_color_temperature: 6500 K + warm_white_color_temperature: 2700 K + constant_brightness: true + gamma_correct: 0 + default_transition_length: 0s + +canbus: + - platform: esp32_can + tx_pin: GPIO5 + rx_pin: GPIO4 + can_id: 4 + bit_rate: 500kbps + +output: + - platform: template + id: output_cold + type: float + write_action: + - canbus.send: + can_id: 0x180 + data: !lambda |- + float value = state; + uint8_t *bytes = (uint8_t*)&value; + return {0x00, bytes[0], bytes[1], bytes[2], bytes[3]}; + + - platform: template + id: output_warm + type: float + write_action: + - canbus.send: + can_id: 0x180 + data: !lambda |- + float value = state; + uint8_t *bytes = (uint8_t*)&value; + return {0x01, bytes[0], bytes[1], bytes[2], bytes[3]};