blueprint:
  name: "HASPone Theme Light on Dark"
  description: |

    ## Blueprint Version: `1.05.00`

    ## Description

    Press RUN ACTIONS to apply the theme Light on Dark to the selected HASPone device

    ![Preview](https://raw.githubusercontent.com/HASwitchPlate/HASPone/main/images/hasp_Theme_Light_on_Dark.png)

  domain: automation
  input:
    haspdevice:
      name: "HASPone Device"
      description: "Select the HASPone device"
      selector:
        device:
          integration: mqtt
          manufacturer: "HASwitchPlate"
          model: "HASPone v1.0.0"

mode: single
max_exceeded: silent

variables:
  haspdevice: !input haspdevice
  selectedfg_entity: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_selected_foreground_color(?:_\d+|)$") -%}
        {{ entity }}
      {%- endif -%}
    {%- endfor -%}
  selectedbg_entity: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_selected_background_color(?:_\d+|)$") -%}
        {{ entity }}
      {%- endif -%}
    {%- endfor -%}
  unselectedfg_entity: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_unselected_foreground_color(?:_\d+|)$") -%}
        {{ entity }}
      {%- endif -%}
    {%- endfor -%}
  unselectedbg_entity: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_unselected_background_color(?:_\d+|)$") -%}
        {{ entity }}
      {%- endif -%}
    {%- endfor -%}
  selected_foreground_brightness: "255"
  selected_foreground_color: "[255, 255, 255]"
  selected_background_brightness: "1"
  selected_background_color: "[255, 255, 255]"
  unselected_foreground_brightness: "224"
  unselected_foreground_color: "[255, 255, 255]"
  unselected_background_brightness: "64"
  unselected_background_color: "[255, 255, 255]"

trigger: []

action:
  - service: light.turn_on
    data:
      entity_id: "{{selectedfg_entity}}"
      rgb_color: "{{selected_foreground_color}}"
  - service: light.turn_on
    data:
      entity_id: "{{selectedfg_entity}}"
      brightness: "{{selected_foreground_brightness}}"
  - service: light.turn_on
    data:
      entity_id: "{{selectedbg_entity}}"
      rgb_color: "{{selected_background_color}}"
  - service: light.turn_on
    data:
      entity_id: "{{selectedbg_entity}}"
      brightness: "{{selected_background_brightness}}"
  - service: light.turn_on
    data:
      entity_id: "{{unselectedfg_entity}}"
      rgb_color: "{{unselected_foreground_color}}"
  - service: light.turn_on
    data:
      entity_id: "{{unselectedfg_entity}}"
      brightness: "{{unselected_foreground_brightness}}"
  - service: light.turn_on
    data:
      entity_id: "{{unselectedbg_entity}}"
      rgb_color: "{{unselected_background_color}}"
  - service: light.turn_on
    data:
      entity_id: "{{unselectedbg_entity}}"
      brightness: "{{unselected_background_brightness}}"
