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.

116 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. id: ${name}
  41. name: ${friendly_name} RGBW Light
  42. default_transition_length: ${transition_length}
  43. # You can use any effects that you like. These are just examples.
  44. effects:
  45. - random:
  46. name: "Slow Random"
  47. transition_length: 30s
  48. update_interval: 30s
  49. - random:
  50. name: "Fast Random"
  51. transition_length: 3s
  52. update_interval: 3s
  53. # This output component controls the front panel light + level.
  54. # Value 0.0 turns off the front panel light.
  55. # Other values (up to 1.0) turn on the light + slider light level.
  56. output:
  57. - platform: yeelight_bs2
  58. id: ${name}_front_panel_light
  59. # Binary sensors can be created for handling front panel touch / release
  60. # events. To specify what part of the front panel to look at, the "part"
  61. # parameter can be set to: "any" (i.e. the default), "power button",
  62. # "color button" or "slider".
  63. binary_sensor:
  64. # When pressing the power button, turn on the light.
  65. - platform: yeelight_bs2
  66. id: ${name}_power_button
  67. part: power button
  68. on_press:
  69. then:
  70. - light.toggle: ${name}
  71. # When holding the color button, turn on night light mode.
  72. - platform: yeelight_bs2
  73. id: ${name}_color_button
  74. part: color button
  75. on_multi_click:
  76. - timing:
  77. - ON for at least 0.8s
  78. then:
  79. - light.turn_on:
  80. id: ${name}
  81. brightness: 0.01
  82. red: 0
  83. green: 1
  84. blue: 0
  85. # This sensor component publishes touch events for the front panel slider.
  86. # The published value represents the level at which the slider was touched.
  87. # By default, values range from 0.01 to 1.00 (in 20 steps). This range can
  88. # be modified using the "range_from" and "range_to" parameters.
  89. sensor:
  90. # When the slider is touched, update the brightness.
  91. # Brightness 0.01 initiates the light night mode, which has already
  92. # been handle above. Therefore, brightness starts from 0.02 here,
  93. # so night mode is not triggered from the slider.
  94. - platform: yeelight_bs2
  95. id: ${name}_slider_level
  96. range_from: 0.02
  97. on_value:
  98. then:
  99. - light.turn_on:
  100. id: ${name}
  101. brightness: !lambda return x;