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.

145 lines
4.7 KiB

  1. # --------------------------------------------------------------------------
  2. # A few practical configuration substitutions.
  3. # --------------------------------------------------------------------------
  4. substitutions:
  5. name: bedside_lamp
  6. friendly_name: Bedside Lamp
  7. transition_length: 700ms
  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. # Configuration 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. light:
  38. # This component controls the LED lights of the device.
  39. - platform: yeelight_bs2
  40. id: ${name}
  41. name: ${friendly_name} RGBW Light
  42. default_transition_length: ${transition_length}
  43. # When the brightness is changed, then update the level indication
  44. # on the front panel accordingly. In night light mode, turn off
  45. # the front panel illumination.
  46. on_brightness:
  47. then:
  48. - output.set_level:
  49. id: ${name}_front_panel_light
  50. level: !lambda if (x < 0.012f) return 0; else return x;
  51. # You can use any effects that you like. These are just examples.
  52. effects:
  53. - random:
  54. name: "Slow Random"
  55. transition_length: 30s
  56. update_interval: 30s
  57. - random:
  58. name: "Fast Random"
  59. transition_length: 3s
  60. update_interval: 3s
  61. # A fun thing you could do with the front panel output component
  62. # (as defined below): wrap it in a light component, so you can
  63. # treat the front panel illumination as a monochromatic light
  64. # from within Home Assitant.
  65. - platform: monochromatic
  66. name: $friendly_name Front Panel Light
  67. output: ${name}_front_panel_light
  68. default_transition_length: 0s
  69. gamma_correct: 1
  70. # This output controls the front panel illumination + level indication.
  71. # Value 0.0 turns off the illumination.
  72. # Other values (up to 1.0) turn on the illumination and set the level
  73. # indication to the requested level.
  74. output:
  75. - platform: yeelight_bs2
  76. id: ${name}_front_panel_light
  77. # Binary sensors can be created for handling front panel touch / release
  78. # events. To specify what part of the front panel to look at, the "part"
  79. # parameter can be set to: "any" (i.e. the default), "power button",
  80. # "color button" or "slider".
  81. binary_sensor:
  82. # When pressing the power button, turn on the light.
  83. - platform: yeelight_bs2
  84. id: ${name}_power_button
  85. part: power button
  86. on_press:
  87. then:
  88. - light.toggle: ${name}
  89. # When touching the color button, set a random color.
  90. # When holding the color button, turn on night light mode.
  91. - platform: yeelight_bs2
  92. id: ${name}_color_button
  93. part: color button
  94. on_multi_click:
  95. - timing:
  96. - ON for at most 0.8s
  97. then:
  98. - light.turn_on:
  99. id: ${name}
  100. red: !lambda return random_float();
  101. green: !lambda return random_float();
  102. blue: !lambda return random_float();
  103. white: 0
  104. - timing:
  105. - ON for at least 0.8s
  106. then:
  107. - light.turn_on:
  108. id: ${name}
  109. red: 1
  110. green: 1
  111. blue: 1
  112. brightness: 0.01
  113. # This sensor component publishes touch events for the front panel slider.
  114. # The published value represents the level at which the slider was touched.
  115. # By default, values range from 0.01 to 1.00 (in 20 steps). This range can
  116. # be modified using the "range_from" and "range_to" parameters.
  117. sensor:
  118. # When the slider is touched, update the brightness.
  119. # Brightness 0.01 initiates the light night mode, which has already
  120. # been handled above. Therefore, brightness starts from 0.02 here,
  121. # so night mode is not triggered from the slider.
  122. - platform: yeelight_bs2
  123. id: ${name}_slider_level
  124. range_from: 0.02
  125. on_value:
  126. then:
  127. - light.turn_on:
  128. id: ${name}
  129. brightness: !lambda return x;