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.

120 lines
5.0 KiB

  1. < [Installation guide](installation.md) | [Index](../README.md) | [Flashing guide](flashing.md) >
  2. # Configuration guide
  3. The `xiaomi_bslamp2` platform provides various components that expose the core functionalities of the lamp.
  4. In the following table, you can find what components are used for exposing what parts of the lamp.
  5. | Part | Component(s) |
  6. | -------------------------- |--------------------------------------------------------|
  7. | ESP32 pinouts | [platform xiaomi_bslamp2](#platform-xiaomi_bslamp2) |
  8. | RGBWW LEDs | [light](#light) |
  9. | Front Panel Power button | [binary_sensor](#binary_sensor) |
  10. | Front Panel Color button | [binary_sensor](#binary_sensor) |
  11. | Front Panel Slider | [binary_sensor](#binary_sensor) (touch/release) |
  12. | | [sensor](#sensor) (touched slider level) |
  13. | Front Panel Illumination | [output](#output) (on/off + indicator level) |
  14. | Light mode propagation | [text_sensor](#text_sensor) |
  15. ## Platform: xiaomi_bslamp2
  16. At the core of the hardware support is the `xiaomi_bslamp2` platform, which provides two
  17. hub-style hardware abstraction layer (HAL) components that are used by the other components:
  18. one for driving the GPIO's for the RGBWW leds and one for the I2C communication between
  19. the ESP32 and the front panel.
  20. I do mention it here for completeness sake, but generally you will not have to add the
  21. following configuration option to your yaml file. It is loaded automatically by the
  22. components that need it, and the GPIO + I2C configurations are fully prepared to work
  23. for the Bedside Lamp 2 wiring out of the box.
  24. Therefore, you will not find this piece of configuration in the [example.yaml](example.yaml).
  25. Having said that, here are the configuration options:
  26. ```yaml
  27. xiaomi_bslamp2:
  28. # Options for the RGBWW LEDs HAL.
  29. red: "GPIO13"
  30. green: "GPIO14"
  31. blue: "GPIO5"
  32. white: "GPIO12"
  33. master_1: "GPIO33"
  34. master_2: "GPIO4"
  35. # Options for the Front Panel HAL.
  36. sda: "GPIO21"
  37. scl: "GPIO19"
  38. address: 0x2C
  39. trigger_pin: "GPIO16"
  40. ```
  41. The only reason that I can think of for adding this platform configuration to your yaml
  42. file, would be if you blew one or more or the ESP32 pins, and need to rewire functions
  43. to different pins.
  44. ## Component: light
  45. The light component creates an RGBWW light. This means that it can do colored light and
  46. cold/warm white light based on a color temperature.
  47. ```yaml
  48. light:
  49. - platform: xiaomi_bslamp2
  50. name: My Bedside Lamp
  51. id: my_bedside_lamp
  52. default_transition_length: 0.5s
  53. effects:
  54. - random:
  55. name: Randomize
  56. transition_length: 3s
  57. update_interval: 3s
  58. on_brightness:
  59. - then:
  60. - logger.log: The brightness changed!
  61. presets:
  62. my_color_presets:
  63. red: { red: 100%, green: 0%, blue: 0% }
  64. green: { red: 0%, green: 100%, blue: 0% }
  65. blue: { red: 0%, green: 0%, blue: 100% }
  66. yellow: { red: 100%, green: 100%, blue: 0% }
  67. purple: { red: 100%, green: 0%, blue: 100% }
  68. randomize: { effect: Randomize }
  69. my_white_presets:
  70. cold: { color_temperature: 153 mireds }
  71. chilly: { color_temperature: 275 mireds }
  72. luke: { color_temperature: 400 mireds }
  73. warm: { color_temperature: 588 mireds
  74. ```
  75. ### Configuration variables:
  76. * **name** (**Required**, string): The name of the light.
  77. * **id** (*Optional*, ID): Manually specify the ID used for code generation. By providing an id,
  78. you can reference the light from automation rules (e.g. to turn on the light when the power
  79. button is tapped)
  80. * **default_transition_length** (*Optional*, Time): The default transition length to use when
  81. no transition length is set in a light call. Defaults to 1s.
  82. * **effects** (*Optional*, list): A list of [light effects](https://esphome.io/components/light/index.html#light-effects)
  83. to use for this light.
  84. * **presets** (*Optional*, dict): Used to define presets, that can be used from automations.
  85. See [below](#light-presets) for detailed information.
  86. * **on_brightness** (*Optional*, Action): An automation to perform when the brightness of the light is modified.
  87. * All other options from [the base Light implementation](https://esphome.io/components/light/index.html#config-light),
  88. except for options that handle color correction options like `gamma_correct` and `color_correct`.
  89. These options are superceded by the fact that the light component has a fully customized
  90. light model, that closely follows the light model of the original lamp's firmware.
  91. ### Light presets
  92. TODO
  93. ## Component: binary_sensor
  94. ## Component: sensor
  95. ## Component: output
  96. ## Component: text_output
  97. < [Installation guide](installation.md) | [Index](../README.md) | [Flashing guide](flashing.md) >