blueprint: name: Ataraxia Lighting – Hue Defaults (v1.15) description: > Apply Philips Hue defaults via Zigbee2MQTT without a reference device. What it does per device: • Configures state reporting (endpoint 11) for On/Off, Level, and Color Temperature • Publishes Zigbee2MQTT device options (transition, color_sync, state_action, optimistic, qos=0) • Applies light defaults via `/set`, sending ONE key per publish: - power_on_behavior - color_temp_startup - color_options.execute_if_off (ALWAYS pushed: true) - level_config.execute_if_off (ALWAYS pushed: true) • Wait a short delay between MQTT publishes (default 0.5s) to avoid flooding MQTT base topic is configurable (default: "zigbee2mqtt"). Parameters • MQTT Base Topic (text, default: zigbee2mqtt) • state_action (bool, default: false) • color_sync (bool, default: true) • transition (number, default: 0.4) • optimistic (bool, default: true) • Power-on behavior (select, default: previous) • Delay between MQTT publishes (number, default: 0.5s) • Configure Switch State Reporting (bool, default: true) • Target devices (list) Changelog • v1.15: Remove unsupported blueprint keys (icon/tags/input_order). Keep always-push of execute_if_off flags. • v1.14: Added configurable MQTT base topic; docs tables (no logic change) • v1.13: Docs polish • v1.12: Send light defaults one key per publish • v1.11: Removed reference device Notes / limitations • Requires Zigbee2MQTT. • Assumes Hue lights use endpoint 11 for reporting config. domain: script source_url: https://raw.githubusercontent.com/mnestrud/ha_random/refs/heads/main/Ataraxia%20Lighting%20-%20Hue%20Defaults.yaml homeassistant: min_version: 2024.8.0 input: base_topic: name: MQTT Base Topic description: The root MQTT topic used by Zigbee2MQTT. Typically "zigbee2mqtt". default: zigbee2mqtt selector: text: {} # DEVICE OPTIONS (Z2M per-device) state_action: name: state_action (device option) description: When true, Z2M also publishes action events. Default = false. default: false selector: boolean: {} color_sync: name: color_sync (device option) description: Keep xy and color_temp modes in sync. Default = true. default: true selector: boolean: {} transition: name: Default transition time (seconds, device option) description: Device-level default transition time for on/off, brightness, and color changes. default: 0.4 selector: number: min: 0 max: 5 step: 0.1 mode: slider optimistic: name: optimistic (device option) description: Assume success and update state immediately. Default = true. default: true selector: boolean: {} # LIGHT DEFAULTS power_on_behavior: name: Power-on behavior (light default) description: previous=restore last state; "on"=always on; "off"=stay off after power restore. default: previous selector: select: mode: dropdown options: - previous - "on" - "off" # TIMING / REPORTING publish_delay: name: Delay between MQTT publishes description: Pause after each publish (seconds). Default 0.5. default: 0.5 selector: number: min: 0 max: 5 step: 0.1 mode: slider configure_reporting: name: Configure Switch State Reporting (endpoint 11) description: > If ON (default): configures reporting for: • genOnOff.onOff (min 0, max 10800, change 0) • genLevelCtrl.currentLevel (min 0, max 10800, change 1) • lightingColorCtrl.colorTemperature (min 0, max 10800, change 1) default: true selector: boolean: {} # DEVICES target_devices: name: Hue bulbs (Zigbee2MQTT) description: Select one or more Hue lights paired through Zigbee2MQTT to apply defaults. default: [] selector: device: multiple: true filter: - integration: mqtt mode: parallel max: 50 # -------------------- # Internal variables # -------------------- variables: base_topic: !input base_topic # Inputs → variables in_state_action: !input state_action in_color_sync: !input color_sync in_transition: !input transition in_optimistic: !input optimistic in_power_on_behavior: !input power_on_behavior in_publish_delay: !input publish_delay in_configure_reporting: !input configure_reporting # Constant defaults for Hue color_temp_startup_default: 370 color_options_execute_if_off_default: true level_config_execute_if_off_default: true # Devices (slice for safety) _devices: !input target_devices devices_200: "{{ (_devices | default([], true))[:200] }}" # Desired values (no reference path) desired_device_options: >- {{ { 'transition': in_transition, 'color_sync': in_color_sync, 'state_action': in_state_action, 'optimistic': in_optimistic, 'qos': 0 } }} # Common request topics based on base_topic req_devopts_topic: "{{ base_topic }}/bridge/request/device/options" req_cfgrep_topic: "{{ base_topic }}/bridge/request/device/configure_reporting" # ------------- # Main sequence # ------------- sequence: - repeat: for_each: "{{ devices_200 }}" sequence: - variables: dev_id: "{{ repeat.item }}" name: >- {{ device_attr(dev_id, 'name') or device_attr(dev_id, 'name_by_user') or dev_id }} set_topic: "{{ base_topic }}/{{ name }}/set" # 0) Strict reporting (endpoint 11) - choose: - conditions: "{{ in_configure_reporting }}" sequence: # OnOff.onOff - action: mqtt.publish data: topic: "{{ req_cfgrep_topic }}" payload: >- {{ { 'id': name, 'endpoint': 11, 'cluster': 'genOnOff', 'attribute': 'onOff', 'minimum_report_interval': 0, 'maximum_report_interval': 10800, 'reportable_change': 0 } | tojson }} - delay: "{{ in_publish_delay }}" # LevelCtrl.currentLevel - action: mqtt.publish data: topic: "{{ req_cfgrep_topic }}" payload: >- {{ { 'id': name, 'endpoint': 11, 'cluster': 'genLevelCtrl', 'attribute': 'currentLevel', 'minimum_report_interval': 0, 'maximum_report_interval': 10800, 'reportable_change': 1 } | tojson }} - delay: "{{ in_publish_delay }}" # LightingColorCtrl.colorTemperature - action: mqtt.publish data: topic: "{{ req_cfgrep_topic }}" payload: >- {{ { 'id': name, 'endpoint': 11, 'cluster': 'lightingColorCtrl', 'attribute': 'colorTemperature', 'minimum_report_interval': 0, 'maximum_report_interval': 10800, 'reportable_change': 1 } | tojson }} - delay: "{{ in_publish_delay }}" # 1) Device options (Z2M device-level) – single publish - action: mqtt.publish data: topic: "{{ req_devopts_topic }}" payload: >- {{ { 'id': name, 'options': desired_device_options } | tojson }} - delay: "{{ in_publish_delay }}" # 2) Light defaults (/set) – ONE KEY PER PUBLISH (and ALWAYS push execute_if_off flags) # power_on_behavior - action: mqtt.publish data: topic: "{{ set_topic }}" payload: >- {{ { 'power_on_behavior': in_power_on_behavior } | tojson }} - delay: "{{ in_publish_delay }}" # color_temp_startup - action: mqtt.publish data: topic: "{{ set_topic }}" payload: >- {{ { 'color_temp_startup': color_temp_startup_default } | tojson }} - delay: "{{ in_publish_delay }}" # color_options.execute_if_off (ALWAYS) - action: mqtt.publish data: topic: "{{ set_topic }}" payload: >- {{ { 'color_options': { 'execute_if_off': color_options_execute_if_off_default } } | tojson }} - delay: "{{ in_publish_delay }}" # level_config.execute_if_off (ALWAYS) - action: mqtt.publish data: topic: "{{ set_topic }}" payload: >- {{ { 'level_config': { 'execute_if_off': level_config_execute_if_off_default } } | tojson }} - delay: "{{ in_publish_delay }}"