Is flash effect similar to stock Philipps Hue possible in ZHA or Zigbee2mqtt?

Hello,
I recently migrated my 3 HUE bulbs from the Hue Bridge to a Sonoff Zigbee 3.0 model P USB Dongle.
Now, I used to call this service on a lightbulb connected to the Hue Hub:

service: light.turn_on
data:
  flash: short
target:
  entity_id: light.iris

Which caused my light (which still has the same entity ID now) to turn off shortly, then turn on with full brightness, then turn back to normal brightness.

Now when I now call the exact same service on the same light but over Z2M (also tested with ZHA, same result), it instead goes to full brightness white and then back to normal.

Is there a way to change this, because I really liked the HUE-style flash effect and still want to have it in Z2M or ZHA?

Best regards
Aaron

Replying to myself to solve this, I made a script that works with any light entity, regardless of capabilities or integration method, and can be called as a service with a parameter entityId being the entity Id of the light to blink. Here’s the YAML code:

alias: Licht blinken
sequence:
  - variables:
      prevState: |
        {{states({{entityId}})}}
      entityId: |
        {{entityId}}
  - choose:
      - conditions:
          - condition: template
            value_template: "{{prevState==\"on\"}}"
        sequence:
          - service: light.turn_off
            data:
              transition: 0
            target:
              entity_id: |
                {{entityId}}
          - delay:
              hours: 0
              minutes: 0
              seconds: 0
              milliseconds: 500
          - service: light.turn_on
            data:
              transition: 0
            target:
              entity_id: |
                {{entityId}}
    default:
      - service: light.turn_on
        data:
          transition: 0
        target:
          entity_id: |
            {{entityId}}
      - delay:
          hours: 0
          minutes: 0
          seconds: 0
          milliseconds: 500
      - service: light.turn_off
        data:
          transition: 0
        target:
          entity_id: |
            {{entityId}}
mode: parallel

1 Like

Hi, just came back to thank you for this script. I was having trouble finding a simple way to blink my lights, and this solved it for me.

I added another variable ‘blinkCount’ to make it easy to customise the number of blinks.

alias: Flash Light
sequence:
  - variables:
      entityId: "{{ entityId }}"
      prevState: "{{ states(entityId) }}"
      blinkCount: "{{ blinkCount | default(1) }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ prevState == 'on' }}"
        sequence:
          - repeat:
              count: "{{ blinkCount }}"
              sequence:
                - data:
                    transition: 0
                  target:
                    entity_id: "{{ entityId }}"
                  action: light.turn_off
                - delay:
                    milliseconds: 500
                - data:
                    transition: 0
                  target:
                    entity_id: "{{ entityId }}"
                  action: light.turn_on
                - delay:
                    milliseconds: 500
    default:
      - repeat:
          count: "{{ blinkCount }}"
          sequence:
            - data:
                transition: 0
              target:
                entity_id: "{{ entityId }}"
              action: light.turn_on
            - delay:
                milliseconds: 500
            - data:
                transition: 0
              target:
                entity_id: "{{ entityId }}"
              action: light.turn_off
            - delay:
                milliseconds: 500
mode: parallel
description: "Flashes light {entityId} with {blinkCount} for repetitions"
  - action: script.flash_light
    data:
      entityId:
      blinkCount: