You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.6 KiB

  1. # --------------------------------------------------------------------------
  2. # A few practical configuration substitutions.
  3. # --------------------------------------------------------------------------
  4. substitutions:
  5. name: bedside_lamp
  6. friendly_name: Bedside Lamp
  7. transition_length: 800ms
  8. # --------------------------------------------------------------------------
  9. # Use your own preferences for these components.
  10. # --------------------------------------------------------------------------
  11. wifi:
  12. ssid: "Your-SSID"
  13. password: "Your-Password"
  14. use_address: 192.168.10.12
  15. # Enable fallback hotspot (for captive portal) in case wifi connection fails
  16. ap:
  17. ssid: "ESPHome $friendly_name"
  18. password: "bedside2021"
  19. captive_portal:
  20. api:
  21. ota:
  22. logger:
  23. # --------------------------------------------------------------------------
  24. # Configureation specific for the Yeelight Bedside Lamp 2.
  25. # --------------------------------------------------------------------------
  26. # Special platform + package are used for enabling unicore and disabling the
  27. # efuse mac crc check. These two changes are required for the ESP32-WROOM-32D
  28. # chip that is used in the device.
  29. esphome:
  30. name: $name
  31. platform: ESP32
  32. board: esp32doit-devkit-v1
  33. platformio_options:
  34. platform: espressif32@3.2.0
  35. platform_packages: |-4
  36. framework-arduinoespressif32 @ https://github.com/pauln/arduino-esp32.git#solo-no-mac-crc/1.0.6
  37. # This component controls the light of the device.
  38. light:
  39. - platform: yeelight_bs2
  40. name: ${friendly_name} RGBW Light
  41. default_transition_length: ${transition_length}
  42. # You can use any effects that you like. These are just examples.
  43. effects:
  44. - random:
  45. name: "Slow Random"
  46. transition_length: 30s
  47. update_interval: 30s
  48. - random:
  49. name: "Fast Random"
  50. transition_length: 3s
  51. update_interval: 3s
  52. # This output component controls the front panel light + level.
  53. # Value 0.0 turns off the front panel light.
  54. # Other values (up to 1.0) turn on the light + slider light level.
  55. output:
  56. - platform: yeelight_bs2
  57. id: ${name}_front_panel_light
  58. # Binary sensors can be created for handling front panel touch / release
  59. # events. To specify what part of the front panel to look at, the "part"
  60. # parameter can be set to: "any" (i.e. the default), "power button",
  61. # "color button" or "slider".
  62. binary_sensor:
  63. # When pressing the power button, turn on the light.
  64. - platform: yeelight_bs2
  65. id: ${name}_power_button
  66. part: power button
  67. on_press:
  68. then:
  69. - light.toggle: ${name}
  70. # When holding the color button, turn on night light mode.
  71. - platform: yeelight_bs2
  72. id: ${name}_color_button
  73. part: color button
  74. on_multi_click:
  75. - timing:
  76. - ON for at least 0.8s
  77. then:
  78. - light.turn_on:
  79. id: ${name}
  80. brightness: 0.01
  81. red: 0
  82. green: 1
  83. blue: 0
  84. # This sensor component publishes touch events for the front panel slider.
  85. # The published value represents the level at which the slider was touched.
  86. # By default, values range from 0.01 to 1.00 (in 20 steps). This range can
  87. # be modified using the "range_from" and "range_to" parameters.
  88. sensor:
  89. # When the slider is touched, update the brightness.
  90. # Brightness 0.01 initiates the light night mode, which has already
  91. # been handle above. Therefore, brightness starts from 0.02 here,
  92. # so night mode is not triggered from the slider.
  93. - platform: yeelight_bs2
  94. id: ${name}_slider_level
  95. range_from: 0.02
  96. on_value:
  97. then:
  98. - light.turn_on:
  99. id: ${name}
  100. brightness: !lambda return x;