Aliexpress ripple lamp esp32 mod pwm motor control

Hi All.
I’ve recently bought a few of these neat ripple led lamps from aliexpress.
aliexpress ripple lamp

They are usually controlled by IR remote but of course, i want it smart.
I’ve successfully integrated an esp32 c3 flashed with tasmota and i have pwm control of the rgb leds thru ha.
Which is great, works as intended.
Now, the lamp has a small geared motor which rotates the diffuser lens above the leds to give the ripple effect. This is also controlled by pwm with a logic level smd mosfet like the leds.
I have set the motor pwm as pwm 6 in tasmota config as i know there is something about the first 4 or 5 pwms are for lights and pwm 6 is a general pwm output.
Using all hardware pwm pins on the esp32c3 as well.
I am able to issue pwm commands from tasmota console to adjust the speed of the motor, works fine.
But this is where I’m a bit stuck.
I need that pwm to appear as an entity on ha so i can have a slider to adjust motor speed.
I’m guessing i need to create a custom yaml config to send mqtt commands to the tasmota pwm 6.
As this is a fairly unique setup, i haven’t been successful finding any answers that work for me.
Would anyone be able to point me in the right direction?

Here is my current card config, obviously the entity for the “motor” slider is not correct, this is where i would want the motor pwm entity.

type: entities
entities:
  - type: section
    label: null
  - type: custom:slider-entity-row
    entity: light.ripple_lamp_lamp
    toggle: true
    full_row: false
    name: Lamp Dimmer
  - type: custom:slider-entity-row
    entity: light.ripple_lamp_lamp
    toggle: true
    full_row: false
    name: Motor
  - type: custom:rgb-light-card
    entity: light.ripple_lamp_lamp
    size: 30
    colors:
      - rgb_color:
          - 255
          - 0
          - 0
        transition: 1
      - rgb_color:
          - 255
          - 127
          - 0
        transition: 1
      - rgb_color:
          - 255
          - 255
          - 0
        transition: 1
      - rgb_color:
          - 0
          - 255
          - 0
        transition: 1
      - rgb_color:
          - 0
          - 0
          - 255
        transition: 1
      - rgb_color:
          - 75
          - 0
          - 130
        transition: 1
      - rgb_color:
          - 148
          - 0
          - 211
        transition: 1
  - type: custom:rgb-light-card
    entity: light.ripple_lamp_lamp
    size: 30
    colors:
      - rgb_color:
          - 255
          - 177
          - 110
        transition: 1
      - rgb_color:
          - 255
          - 206
          - 166
        transition: 1
      - rgb_color:
          - 255
          - 237
          - 222
        transition: 1
      - rgb_color:
          - 255
          - 255
          - 255
        transition: 1
state_color: true
title: Ripple Lamp
show_header_toggle: true
card_mod:
  style: |
    .card-header {
      font-size: 18px;
      padding: 2px 15px 2px 15px
    }

Ok I’ve been playing around some more and found a workaround for now.
Instead of a slider i am just creating scripts to publish the mqtt command for a preset pwm value (ie. slowest = 300, fastest = 1000)
And then add a button for each speed on the dashboard.
I’ll keep playing but i’m getting closer.

I’ve settled with individual speed buttons, each button triggers the script to send a mqtt comand with the pwm value desired.
Works great and that’ll do! :grin:
I’m sure there’s nicer way to do this and I might explore having one button cycle thru speeds, still learning it all.

Current card layout, compact, simple and works.
Screenshot 2024-06-27 175416

This is the code for sending the pwm value for the fastest speed. Change payload to suit between 0 - 1024.

alias: Ripple Lamp Fastest
sequence:
  - service: mqtt.publish
    metadata: {}
    data:
      qos: 0
      retain: false
      payload: "1023"
      topic: cmnd/Ripple_Lamp/pwm6
mode: single
icon: mdi:heat-wave