MQTT Tasmota PCA9685 light configuration

Hi,
I’m new here. I like Home Assistent and I’m doing more and more with it. I’m a fan of Tasmota. The only thing is, I want to controll 16 lights at once and also be able to controll them seperatly. Since I’m building them myself I thought I use the PCA9685 which can cotrol 16 PWM outputs. Nice. Then I use a ESP12F to control the PCA9685. This also workts. Only a little different then the normal PWM outputs of the ESP’s.

I searched the web and even this forum. Can’t find anything to control the lights from HA.
In MQTT I can controll it:

cmnd/tasmota_AB9BFB/driver15 status
tele/tasmota_AB9BFB/SENSOR {“Time”:“2021-05-25T15:25:47”,“PCA9685”:{“PWM_FREQ”:1500,“PWM0”:0,“PWM1”:0,“PWM2”:0,“PWM3”:0,“PWM4”:0,“PWM5”:0,“PWM6”:0,“PWM7”:0,“PWM8”:0,“PWM9”:0,“PWM10”:0,“PWM11”:0,“PWM12”:0,“PWM13”:0,“PWM14”:0,“PWM15”:0,“END”:1}}

cmnd/tasmota_AB9BFB/driver15 pwm,0,1000
stat/tasmota_AB9BFB/RESULT {“PCA9685”:{“PIN”:0,“PWM”:1000}}

cmnd/tasmota_AB9BFB/driver15 pwm,pin,OFF
stat/tasmota_AB9BFB/RESULT {“PCA9685”:{“PIN”:0,“PWM”:0}}

cmnd/tasmota_AB9BFB/driver15 pwm,pin,ON
stat/tasmota_AB9BFB/RESULT {“PCA9685”:{“PIN”:0,“PWM”:4096}}

Is there anyone who can help me on an example to create a section in configuration.yaml to control this as light:
In addition, it would be nice if I can manage to remember somewhere the value of the channel when turned off.

Thanks in advance.
Marc

1 Like

Exactly what I am looking for too. Let me know if you find anything. Will do the same :wink:

I’ve solved it 90%, you can turn it on and off and dim it, but the status display in HA is only simulated! I can’t get HA to correctly evaluate Tasmota’s answer :frowning:

mqtt:
  light:
    - name: "Wohnzimmer Licht"
      unique_id: "wohnzimmer_licht"
      state_topic: "stat/Dimmer-Modul-1-Wlan/RESULT"
      brightness_command_topic: "cmnd/Dimmer-Modul-1-Wlan/driver15"
      brightness_command_template: "pwm 2 {{ value }}"
      command_topic: "cmnd/Dimmer-Modul-1-Wlan/driver15"
      on_command_type: brightness
      optimistic: true
      brightness_scale: "4095"
      payload_on: "PWM 2 4095"
      payload_off: "PWM 2 0"

The option “optimistic: true” means that the ha no longer waits for a response from the device, but simulates the status!

I tried the following:

state_value_template: >
        {% if value_json.PCA9685.PIN == 2 and value_json.PCA9685.PWM == 0 %}
          OFF
        {% else %}
          ON
        {% endif %}


      brightness_value_template: >
        {% if value_json.PCA9685.PIN == 2 %}
          {{ value_json.PCA9685.PWM }}
        {% else %}
          0
        {% endif %}