Change color button hold

Hi to all, i hope that someone can help me :slight_smile:
I start to migrate xiami mijia button (wxkg01lm) from orginal gateway to usb zigbee dongle.
I want to know if there are some easy script for do what i did with xiaomi app…
practically, at the event “hold button”, I would like a lamp to change color according to some pre-established steps (e.g. first time hold: white second time: red third time: blue etc).
Can you help me to write that automation?

- alias: change color
  trigger:
    platform: state
    entity_id: sensor.xxxx
    to: 'hold'
  action:
    xxxx

thanks to all