blueprint: source_url: https://github.com/bonesderdritte/ha-ikea-kajplats-zigbee-pairing-blueprint/blob/main/blueprints/script/ikea_kajplats_zigbee_pairing_mode_power_cycle.yaml name: IKEA KAJPLATS Smart Bulb Zigbee Pairing Mode Power Cycle description: > Power-cycle helper for IKEA smart bulbs using a smart plug/relay. Counting rule (matches typical manual reset instructions): • "Cycles" means: how many times the bulb is powered ON (OFF→ON). The script ends with the bulb ON. Example: cycles=6 => 6 ON-events total Common usage (device-dependent): • 6 = Factory reset / start new Zigbee pairing • 12 = Switch from Matter mode to Zigbee mode (legacy Zigbee) I only tested this with one KAJPLATS bulb, your settings may vary. This will also work with other smart bulbs if you adjust the input values accordingly domain: script input: target_switch: name: Target Switch description: Smart plug or relay controlling the bulb power. selector: entity: domain: switch cycles: name: Number of ON events (OFF→ON) description: "Typical: 6 = new pairing, 12 = Matter→Zigbee mode switch" default: 12 selector: number: min: 1 max: 20 step: 1 mode: slider initial_off_delay: name: Initial OFF Stabilization (seconds) default: 2 selector: number: min: 0 max: 10 step: 0.1 unit_of_measurement: seconds mode: box off_time: name: OFF Duration (seconds) default: 1.5 selector: number: min: 0.2 max: 5 step: 0.1 unit_of_measurement: seconds mode: box on_time: name: ON Duration (seconds) default: 1.5 selector: number: min: 0.2 max: 5 step: 0.1 unit_of_measurement: seconds mode: box sequence: # Clean start: force OFF - service: switch.turn_off target: entity_id: !input target_switch - delay: seconds: !input initial_off_delay # Copy input into variables for templating - variables: cycles_value: !input cycles # We will do (cycles-1) full ON->OFF toggles, then a final ON. repeat_count: "{{ max((cycles_value | int) - 1, 0) }}" # Do (cycles-1) times: ON then OFF - repeat: count: "{{ repeat_count }}" sequence: - service: switch.turn_on target: entity_id: !input target_switch - delay: seconds: !input on_time - service: switch.turn_off target: entity_id: !input target_switch - delay: seconds: !input off_time # Final ON = the Nth ON-event. Leaves power ON. - service: switch.turn_on target: entity_id: !input target_switch mode: single