Problem controlling homemade plant watering pump

Recently I made a plant watering pump with a microcontroller for my indoor plants which uses MQTT to communicate with HA. It has a soil moisture sensor a water pump, the pump has 2 commands, one is to set the volumn of the next watering, the other one is to start pump the indicated volumn and stop itself once done.

Because the operation is very similar to a dimable light, watering volume is like brightness and pump on/off is like the light switch, so I’m using the light configuration for it:

light:
  - platform: mqtt
    unique_id: M5Water01_Pump
    name: "M5Water01 Pump"
    state_topic: "HLSmartHome/M5Water01/state"
    state_value_template: "{{ value_json.pump_state }}"
    brightness_value_template: "{{ value_json.pump_ml }}"
    command_topic: "HLSmartHome/M5Water01/command/pump"
    brightness_command_topic: "HLSmartHome/M5Water01/command/setml"
    brightness_scale: 1000
    #on_command_type: "brightness"
    payload_on: "on"
    payload_off: "off"
    optimistic: false
    qos: 0

Sample state payload from the pump:

{
  "pump_state": "off",
  "pump_ml": "298",
  "moisture": "41"
}

Also just a simple entity card on lovelace:
lovelace

Now the problem is,

  1. the pump icon on lovelace card doesn’t update with the pump on/off status. Also doesn’t update with the volume state returned from the pump.

  2. It auto triggers the on command for the pump if I set the volume, I don’t want that, I want to make setting the volume and starting the pump 2 separate actions. So I can first set the volume and then start the pump myself. If I uncomment the on_command_type line, it will only send set volume command if I change the volume, but also send the same command if click on the pump on/off, so the pump never turns on.

  3. If the above is unsolvable with the light integration/stock lovelace card, which ones should I use and how do I configure it?

Thanks!

Any idea? All help is appreciated :grinning: