SM2135 LED driver
==================

.. seo::
    :description: Instructions for setting up SM2135 LED drivers in ESPHome.
    :keywords: SM2135, Calex Smart RGB Reflector

.. _sm2135-component:

Component/Hub
-------------

The SM2135 component represents a SM2135 LED diver chain
(`SM2135 description <https://github.com/arendst/Sonoff-Tasmota/files/3656603/SM2135E_zh-CN_en-US_translated.pdf>`__,
`SM2135 description <https://github.com/arendst/Sonoff-Tasmota/files/3656603/SM2135E_zh-CN_en-US_translated.pdf>`__) in
ESPHome. Communication is done with two GPIO pins (MOSI and SCLK).
It is used in some smart light bulbs:

- Calex Smart RGB Reflector LED lamp (GU10)
- LSC Smart GU10

To use the channels of this components, you first need to setup the
global ``sm2135`` hub and give it an id, and then define the
:ref:`individual output channels <sm2135-output>`.

.. code-block:: yaml

    # Example configuration entry
    sm2135:
      data_pin: GPIO12
      clock_pin: GPIO14

    # Individual outputs
    output:
      - platform: sm2135
        id: output_red
        channel: 0
        max_power: 0.8
      - platform: sm2135
        id: output_green
        channel: 1
        max_power: 0.8
      - platform: sm2135
        id: output_blue
        channel: 2
        max_power: 0.8
      - platform: sm2135
        id: output_white
        channel: 3
        max_power: 0.8
      - platform: sm2135
        id: output_warmwhite
        channel: 4
        max_power: 0.8

Configuration variables:
************************

-  **data_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin used for MOSI.
-  **clock_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin which SCLK is
   connected to.
-  **id** (*Optional*, :ref:`config-id`): The id to use for
   this ``sm2135`` component. Use this if you have multiple SM2135 chains
   connected at the same time.

.. _sm2135-output:

Output
------

The SM2135 output component exposes a SM2135 channel of a global
:ref:`sm2135-component` as a float output.

.. code-block:: yaml

    # Example configuration entry
    sm2135:
      data_pin: GPIO12
      clock_pin: GPIO14

    # Individual outputs
    output:
      - platform: sm2135
        id: output_red
        channel: 0
        max_power: 0.8
      - platform: sm2135
        id: output_green
        channel: 1
        max_power: 0.8
      - platform: sm2135
        id: output_blue
        channel: 2
        max_power: 0.8
      - platform: sm2135
        id: output_white
        channel: 3
        max_power: 0.8
      - platform: sm2135
        id: output_warmwhite
        channel: 4
        max_power: 0.8

Configuration variables:
************************

- **id** (**Required**, :ref:`config-id`): The id to use for this output component.
- **channel** (**Required**, int): Chose the channel of the SM2135 chain of
  this output component.
- **sm2135_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the
  :ref:`sm2135-component`.
  Use this if you have multiple SM2135 chains you want to use at the same time.
- All other options from :ref:`Output <config-output>`.

.. note::

    The white LEDs are much brighter than the color LEDs. To get uniform brightness
    for both color and white you will need to limit the white led power.

.. note::

    This driver does not support enabling of both the color and the white channels
    at the same time. Therefore, the :ref:`rgbw_color_interlock` should be set to true
    when using this driver.

See Also
--------

- :doc:`/components/output/index`
- :doc:`/components/output/esp8266_pwm`
- :doc:`/components/output/sm16716`
- :doc:`/components/light/rgb`
- :doc:`/components/light/rgbw`
- :doc:`/components/light/rgbww`
- :doc:`/components/power_supply`
- :apiref:`output/sm2135_output_component.h`
- :ghedit:`Edit`
