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]};