blueprint:
  name: "HASPone p[7].b[all] displays an alarm control panel"
  description: |

    ## Blueprint Version: `1.05.00`

    # Description

    Page 7 controls a selected alarm panel for code entry and arm/disarm.

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

    ## HASPone Page and Button Reference

    <details>

    This automation is designed to work with the controls found on page 7:

    | Page 7 |
    |--------|
    | ![Page 7](https://raw.githubusercontent.com/HASwitchPlate/HASPone/main/images/NextionUI_p7_12buttons.png) |

    </details>

  source_url: "https://github.com/HASwitchPlate/Blueprints/blob/main/hasp_Display_Alarm_Control_page7.yaml"
  domain: automation
  input:
    haspdevice:
      name: "HASPone Device"
      description: "Select the HASPone device"
      selector:
        device:
          integration: mqtt
          manufacturer: "HASwitchPlate"
          model: "HASPone v1.0.0"
    alarmpanel:
      name: "Alarm panel to control"
      description: "Select an alarm panel to control"
      selector:
        entity:
          domain: alarm_control_panel
    b13armservice:
      name: "Lower-left arm service"
      description: "Select the alarm arm service to call when system is armed with the lower-left button"
      default: "alarm_arm_home"
      selector:
        select:
          options:
            - "alarm_arm_home"
            - "alarm_arm_away"
            - "alarm_arm_night"
            - "alarm_arm_vacation"
            - "alarm_arm_custom_bypass"
    b15armservice:
      name: "Lower-right arm service"
      description: "Select the alarm arm service to call when system is armed with the lower-right button"
      default: "alarm_arm_away"
      selector:
        select:
          options:
            - "alarm_arm_home"
            - "alarm_arm_away"
            - "alarm_arm_night"
            - "alarm_arm_vacation"
            - "alarm_arm_custom_bypass"
    codelength:
      name: "Alarm code length"
      description: "Select the alarm code length for your alarm (usually 4 digits)."
      default: 4
      selector:
        number:
          min: 2
          max: 10
          mode: slider
          unit_of_measurement: digits
    discoveryprefix:
      name: "Home Assistant MQTT discovery prefix"
      description: 'In nearly all cases this should be "homeassistant"'
      default: "homeassistant"
      selector:
        text:

mode: queued
max_exceeded: silent

variables:
  haspdevice: !input haspdevice
  haspname: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^sensor\..+_sensor(?:_\d+|)$") -%}
        {{- entity|regex_replace(find="^sensor\.", replace="", ignorecase=true)|regex_replace(find="_sensor(?:_\d+|)$", replace="", ignorecase=true) -}}
      {%- endif -%}
    {%- endfor -%}
  alarmpanel: !input alarmpanel
  codelength: !input codelength
  b13armservice: !input b13armservice
  b15armservice: !input b15armservice
  discoveryprefix: !input discoveryprefix
  commandtopic: '{{ "hasp/" ~ haspname ~ "/command/" }}'
  jsontopic: '{{ "hasp/" ~ haspname ~ "/state/json" }}'
  jsoncommandtopic: '{{ "hasp/" ~ haspname ~ "/command/json" }}'
  haspsensor: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^sensor\..+_sensor(?:_\d+|)$") -%}
        {{ entity }}
      {%- endif -%}
    {%- endfor -%}
  haspClientId: '{{state_attr(haspsensor, "haspClientID")}}'
  haspManufacturer: '{{state_attr(haspsensor, "haspManufacturer")}}'
  haspModel: '{{state_attr(haspsensor, "haspModel")}}'
  sw_version: '{{state_attr(haspsensor, "espVersion")}}'
  selectedfgtopic: '{{ "hasp/" ~ haspname ~ "/light/selectedforegroundcolor/rgb" }}'
  selectedbgtopic: '{{ "hasp/" ~ haspname ~ "/light/selectedbackgroundcolor/rgb" }}'
  unselectedfgtopic: '{{ "hasp/" ~ haspname ~ "/light/unselectedforegroundcolor/rgb" }}'
  unselectedbgtopic: '{{ "hasp/" ~ haspname ~ "/light/unselectedbackgroundcolor/rgb" }}'
  selectedfg: >-
    {%- set color = namespace() -%}
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_selected_foreground_color(?:_\d+|)$") -%}
        {%- set color.source=entity -%}
      {%- endif -%}
    {%- endfor -%}
    {%- set brightness = state_attr(color.source, "brightness")|int(default=255) / 255 -%}
    {%- set red=(state_attr(color.source, "rgb_color")[0] * brightness)|int(default=0) -%}
    {%- set green=(state_attr(color.source, "rgb_color")[1] * brightness)|int(default=0) -%}
    {%- set blue=(state_attr(color.source, "rgb_color")[2] * brightness)|int(default=0) -%}
    {{ (red|bitwise_and(248)*256) + (green|bitwise_and(252)*8) + (blue|bitwise_and(248)/8)|int }}
  selectedbg: >-
    {%- set color = namespace() -%}
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_selected_background_color(?:_\d+|)$") -%}
        {%- set color.source=entity -%}
      {%- endif -%}
    {%- endfor -%}
    {%- set brightness = state_attr(color.source, "brightness")|int(default=255) / 255 -%}
    {%- set red=(state_attr(color.source, "rgb_color")[0] * brightness)|int(default=0) -%}
    {%- set green=(state_attr(color.source, "rgb_color")[1] * brightness)|int(default=0) -%}
    {%- set blue=(state_attr(color.source, "rgb_color")[2] * brightness)|int(default=0) -%}
    {{ (red|bitwise_and(248)*256) + (green|bitwise_and(252)*8) + (blue|bitwise_and(248)/8)|int }}
  unselectedfg: >-
    {%- set color = namespace() -%}
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_unselected_foreground_color(?:_\d+|)$") -%}
        {%- set color.source=entity -%}
      {%- endif -%}
    {%- endfor -%}
    {%- set brightness = state_attr(color.source, "brightness")|int(default=255) / 255 -%}
    {%- set red=(state_attr(color.source, "rgb_color")[0] * brightness)|int(default=0) -%}
    {%- set green=(state_attr(color.source, "rgb_color")[1] * brightness)|int(default=0) -%}
    {%- set blue=(state_attr(color.source, "rgb_color")[2] * brightness)|int(default=0) -%}
    {{ (red|bitwise_and(248)*256) + (green|bitwise_and(252)*8) + (blue|bitwise_and(248)/8)|int }}
  unselectedbg: >-
    {%- set color = namespace() -%}
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^light\..*_unselected_background_color(?:_\d+|)$") -%}
        {%- set color.source=entity -%}
      {%- endif -%}
    {%- endfor -%}
    {%- set brightness = state_attr(color.source, "brightness")|int(default=255) / 255 -%}
    {%- set red=(state_attr(color.source, "rgb_color")[0] * brightness)|int(default=0) -%}
    {%- set green=(state_attr(color.source, "rgb_color")[1] * brightness)|int(default=0) -%}
    {%- set blue=(state_attr(color.source, "rgb_color")[2] * brightness)|int(default=0) -%}
    {{ (red|bitwise_and(248)*256) + (green|bitwise_and(252)*8) + (blue|bitwise_and(248)/8)|int }}

  b13text: >-
    {%- if states(alarmpanel) == "disarmed" -%}
      {%- if b13armservice == "alarm_arm_home" -%}
        arm\\rhome
      {%- elif b13armservice == "alarm_arm_away" -%}
        arm\\raway
      {%- elif b13armservice == "alarm_arm_night" -%}
        arm\\rnight
      {%- elif b13armservice == "alarm_arm_vacation" -%}
        arm\\rvaca
      {%- elif b13armservice == "alarm_arm_custom_bypass" -%}
        arm\\rbypass
      {%- endif -%}
    {%- elif states(alarmpanel) == "arming" -%}
      arming
    {%- elif states(alarmpanel) == "armed_home" -%}
      armed\\rhome
    {%- elif states(alarmpanel) == "armed_away" -%}
      armed\\raway
    {%- elif states(alarmpanel) == "armed_night" -%}
      armed\\rnight
    {%- elif states(alarmpanel) == "armed_vacation" -%}
      armed\\rvaca
    {%- elif states(alarmpanel) == "armed_custom_bypass" -%}
      armedbypass
    {%- endif -%}
  b15text: >-
    {%- if states(alarmpanel) == "disarmed" -%}
      {%- if b15armservice == "alarm_arm_home" -%}
        arm\\rhome
      {%- elif b15armservice == "alarm_arm_away" -%}
        arm\\raway
      {%- elif b15armservice == "alarm_arm_night" -%}
        arm\\rnight
      {%- elif b15armservice == "alarm_arm_vacation" -%}
        arm\\rvaca
      {%- elif b15armservice == "alarm_arm_custom_bypass" -%}
        arm\\rbypass
      {%- endif -%}
    {%- else -%}
      disarm
    {%- endif -%}

trigger_variables:
  haspdevice: !input haspdevice
  haspname: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^sensor\..+_sensor(?:_\d+|)$") -%}
        {{- entity|regex_replace(find="^sensor\.", replace="", ignorecase=true)|regex_replace(find="_sensor(?:_\d+|)$", replace="", ignorecase=true) -}}
      {%- endif -%}
    {%- endfor -%}
  haspsensor: >-
    {%- for entity in device_entities(haspdevice) -%}
      {%- if entity|regex_search("^sensor\..+_sensor(?:_\d+|)$") -%}
        {{ entity }}
      {%- endif -%}
    {%- endfor -%}
  jsontopic: '{{ "hasp/" ~ haspname ~ "/state/json" }}'
  selectedfgtopic: '{{ "hasp/" ~ haspname ~ "/light/selectedforegroundcolor/rgb" }}'
  selectedbgtopic: '{{ "hasp/" ~ haspname ~ "/light/selectedbackgroundcolor/rgb" }}'
  unselectedfgtopic: '{{ "hasp/" ~ haspname ~ "/light/unselectedforegroundcolor/rgb" }}'
  unselectedbgtopic: '{{ "hasp/" ~ haspname ~ "/light/unselectedbackgroundcolor/rgb" }}'

trigger:
  - platform: state
    entity_id: !input alarmpanel
  - platform: homeassistant
    event: start
  - platform: template
    value_template: "{{ is_state(haspsensor, 'ON') }}"
  - platform: mqtt
    topic: "{{jsontopic}}"
  - platform: mqtt
    topic: "{{selectedfgtopic}}"
  - platform: mqtt
    topic: "{{selectedbgtopic}}"
  - platform: mqtt
    topic: "{{unselectedfgtopic}}"
  - platform: mqtt
    topic: "{{unselectedbgtopic}}"

condition:
  - condition: template
    value_template: "{{ is_state(haspsensor, 'ON') }}"

action:
  - choose:
      #########################################################################
      # RUN ACTIONS or Home Assistant Startup or HASPone Connect
      - conditions:
          - condition: template
            value_template: >-
              {{-
                (trigger is not defined)
              or
                (trigger.platform is none)
              or
                ((trigger.platform == 'homeassistant') and (trigger.event == 'start'))
              or
                ((trigger.platform == 'template') and (trigger.entity_id == haspsensor) and (trigger.to_state.state == 'ON'))
              -}}
        sequence:
          # Apply themes and set numbered button labels
          - service: mqtt.publish
            data:
              topic: "{{jsoncommandtopic}}"
              payload: >-
                [{%- for i in range(4,15) if not i == 13 -%}
                "p[7].b[{{i}}].pco={{selectedfg}}",
                "p[7].b[{{i}}].bco={{selectedbg}}",
                "p[7].b[{{i}}].pco2={{unselectedfg}}",
                "p[7].b[{{i}}].bco2={{unselectedbg}}",
                "p[7].b[{{i}}].font=3",{%- endfor -%}
                {%- for i in range(4,13) -%}
                "p[7].b[{{i}}].txt=\"{{i-3}}\"",{%- endfor -%}
                "p[7].b[14].txt=\"0\""]
          - service: mqtt.publish
            data:
              topic: "{{jsoncommandtopic}}"
              payload: >-
                ["p[7].b[13].font=6",
                "p[7].b[15].font=6",
                {%- if states(alarmpanel) == "disarmed" -%}
                "p[7].b[13].pco={{selectedfg}}",
                "p[7].b[13].bco={{selectedbg}}",
                "p[7].b[13].pco2={{unselectedfg}}",
                "p[7].b[13].bco2={{unselectedbg}}",
                "p[7].b[15].pco={{selectedfg}}",
                "p[7].b[15].bco={{selectedbg}}",
                "p[7].b[15].pco2={{unselectedfg}}",
                "p[7].b[15].bco2={{unselectedbg}}",
                {%- else -%}
                "p[7].b[13].pco={{unselectedfg}}",
                "p[7].b[13].bco={{unselectedbg}}",
                "p[7].b[13].pco2={{selectedfg}}",
                "p[7].b[13].bco2={{selectedbg}}",
                "p[7].b[15].pco={{unselectedfg}}",
                "p[7].b[15].bco={{unselectedbg}}",
                "p[7].b[15].pco2={{selectedfg}}",
                "p[7].b[15].bco2={{selectedbg}}",
                {%- endif -%}
                "p[7].b[13].txt=\"{{b13text}}\"",
                "p[7].b[15].txt=\"{{b15text}}\""]
          - repeat:
              count: "{{codelength}}"
              sequence:
                # create number objects for each digit in codelength
                - service: mqtt.publish
                  data:
                    topic: "{{discoveryprefix}}/number/{{haspname}}/alarmcode_{{repeat.index}}/config"
                    payload: >-
                      {"name":"{{haspname}} alarmcode {{repeat.index}}",
                      "command_topic":"hasp/{{haspname}}/alarmcode/{{repeat.index}}",
                      "availability":{"topic":"hasp/{{haspname}}/alwayson","payload_available":"ON"},
                      "retain":true,
                      "optimistic":true,
                      "min":-1,
                      "max":9,
                      "icon":"mdi:bell-plus-outline",
                      "unique_id":"{{haspClientId}}-alarmcode_{{repeat.index}}",
                      "device":{
                      "identifiers":["{{haspClientId}}"],
                      "name":"{{haspname}}",
                      "manufacturer":"{{haspManufacturer}}",
                      "model":"{{haspModel}}",
                      "sw_version":{{sw_version}}
                      }}
          - delay: "00:00:01"
          - repeat:
              count: "{{codelength}}"
              sequence:
                # set initial bogus value for each digit in codelength
                - service: number.set_value
                  data:
                    entity_id: "number.{{haspname}}_alarmcode_{{repeat.index}}"
                    value: -1

      #########################################################################
      # Update alarm state if the selected alarm panel entity changes state
      - conditions:
          - condition: template
            value_template: '{{ (trigger.platform == "state") and (trigger.entity_id == alarmpanel) }}'
        sequence:
          - service: mqtt.publish
            data:
              topic: "{{jsoncommandtopic}}"
              payload: >-
                [{%- if states(alarmpanel) == "disarmed" -%}
                "p[7].b[13].pco={{selectedfg}}",
                "p[7].b[13].bco={{selectedbg}}",
                "p[7].b[13].pco2={{unselectedfg}}",
                "p[7].b[13].bco2={{unselectedbg}}",
                "p[7].b[15].pco={{selectedfg}}",
                "p[7].b[15].bco={{selectedbg}}",
                "p[7].b[15].pco2={{unselectedfg}}",
                "p[7].b[15].bco2={{unselectedbg}}",
                {%- else -%}
                "p[7].b[13].pco={{unselectedfg}}",
                "p[7].b[13].bco={{unselectedbg}}",
                "p[7].b[13].pco2={{selectedfg}}",
                "p[7].b[13].bco2={{selectedbg}}",
                "p[7].b[15].pco={{unselectedfg}}",
                "p[7].b[15].bco={{unselectedbg}}",
                "p[7].b[15].pco2={{selectedfg}}",
                "p[7].b[15].bco2={{selectedbg}}",
                {%- endif -%}
                "p[7].b[13].txt=\"{{b13text}}\"",
                "p[7].b[15].txt=\"{{b15text}}\""]

      #########################################################################
      # Handle MQTT message triggers
      - conditions:
          - condition: template
            value_template: '{{ trigger.platform == "mqtt" }}'
        sequence:
          - choose:
              #########################################################################
              # Catch incoming JSON button presses
              - conditions:
                  - condition: template
                    value_template: '{{ (trigger.topic == jsontopic) and (trigger.payload_json is defined) and (trigger.payload_json.event_type is defined) and (trigger.payload_json.event_type == "button_short_press") }}'
                sequence:
                  - choose:
                      #########################################################################
                      # Catch a number button
                      - conditions:
                          - condition: template
                            value_template: >-
                              {% set page = trigger.payload_json.event.split("].b[")[0] | replace("p[","") | int %}
                              {% set button = trigger.payload_json.event.split("].b[")[1] | replace("]","") | int %}
                              {% if page == 7 and (button >= 4 and button <= 12) or button == 14%}{{true}}{% endif %}
                        sequence:
                          - repeat:
                              count: "{{(codelength|int) - 1}}"
                              sequence:
                                # roll existing number entries forward into the next number
                                - service: number.set_value
                                  data:
                                    entity_id: "number.{{haspname}}_alarmcode_{{(codelength|int) - repeat.index + 1}}"
                                    value: '{{states("number." ~ haspname ~ "_alarmcode_" ~ ((codelength|int) - repeat.index))|int}}'
                          - service: number.set_value
                            data:
                              entity_id: "number.{{haspname}}_alarmcode_1"
                              value: >-
                                {%- set button = trigger.payload_json.event.split("].b[")[1] | replace("]","") | int - 3 -%}
                                {%- if button == 11 %}{% set button = 0 -%}{%- endif -%}
                                {{button|int}}

                      #########################################################################
                      # b13 arm was pressed
                      - conditions:
                          - condition: template
                            value_template: '{{ (trigger.payload_json.event is defined) and (trigger.payload_json.event == "p[7].b[13]") and (trigger.payload_json.value == "ON") and (states(alarmpanel) == "disarmed")}}'
                        sequence:
                          - service: "{{'alarm_control_panel.' ~ b13armservice}}"
                            data:
                              entity_id: !input alarmpanel
                              code: >-
                                {%- set code = namespace() -%}
                                {%- set code.value = states("number." ~ haspname ~ "_alarmcode_" ~ codelength)|int -%}
                                {%- for i in range(1,codelength|int) -%}
                                {%- set code.value =  code.value|int * 10 + (states("number." ~ haspname ~ "_alarmcode_" ~ (codelength|int - i))|int) -%}
                                {%- endfor -%}
                                {{code.value|int}}
                          - repeat:
                              count: "{{codelength}}"
                              sequence:
                                # clear out code entry after arm attempt
                                - service: number.set_value
                                  data:
                                    entity_id: "number.{{haspname}}_alarmcode_{{repeat.index}}"
                                    value: -1
                      #########################################################################
                      # b15 arm was pressed
                      - conditions:
                          - condition: template
                            value_template: '{{ (trigger.payload_json.event is defined) and (trigger.payload_json.event == "p[7].b[15]") and (trigger.payload_json.value == "ON") and (states(alarmpanel) == "disarmed")}}'
                        sequence:
                          - service: "{{'alarm_control_panel.' ~ b15armservice}}"
                            data:
                              entity_id: !input alarmpanel
                              code: >-
                                {%- set code = namespace() -%}
                                {%- set code.value = states("number." ~ haspname ~ "_alarmcode_" ~ codelength)|int -%}
                                {%- for i in range(1,codelength|int) -%}
                                {%- set code.value =  code.value|int * 10 + (states("number." ~ haspname ~ "_alarmcode_" ~ (codelength|int - i))|int) -%}
                                {%- endfor -%}
                                {{code.value|int}}
                          - repeat:
                              count: "{{codelength}}"
                              sequence:
                                # clear out code entry after arm attempt
                                - service: number.set_value
                                  data:
                                    entity_id: "number.{{haspname}}_alarmcode_{{repeat.index}}"
                                    value: -1

                      #########################################################################
                      # Disarm was pressed
                      - conditions:
                          - condition: template
                            value_template: '{{ (trigger.payload_json.event is defined) and (trigger.payload_json.event == "p[7].b[15]") and (trigger.payload_json.value == "ON")}}'
                        sequence:
                          - service: alarm_control_panel.alarm_disarm
                            data:
                              entity_id: !input alarmpanel
                              code: >-
                                {%- set code = namespace() -%}
                                {%- set code.value = states("number." ~ haspname ~ "_alarmcode_" ~ codelength)|int -%}
                                {%- for i in range(1,codelength|int) -%}
                                {%- set code.value =  code.value|int * 10 + (states("number." ~ haspname ~ "_alarmcode_" ~ (codelength|int - i))|int) -%}
                                {%- endfor -%}
                                {{code.value|int}}
                          - repeat:
                              count: "{{codelength}}"
                              sequence:
                                # clear out code entry after disarm attempt
                                - service: number.set_value
                                  data:
                                    entity_id: "number.{{haspname}}_alarmcode_{{repeat.index}}"
                                    value: -1

              #########################################################################
              # Theme: Apply selected foreground color when it changes.
              - conditions:
                  - condition: template
                    value_template: "{{ trigger.topic == selectedfgtopic }}"
                sequence:
                  - service: mqtt.publish
                    data:
                      topic: "{{jsoncommandtopic}}"
                      payload: >-
                        [{%- for i in range(4,15) if not i == 13 -%}
                        "p[7].b[{{i}}].pco={{selectedfg}}",{%- endfor -%}
                        {%- if states(alarmpanel) == "disarmed" -%}
                        "p[7].b[13].pco={{selectedfg}}",
                        "p[7].b[15].pco={{selectedfg}}"
                        {%- else -%}
                        "p[7].b[13].pco2={{selectedfg}}",
                        "p[7].b[15].pco2={{selectedfg}}"
                        {%- endif -%}]

              #########################################################################
              # Theme: Apply selected background color on change
              - conditions:
                  - condition: template
                    value_template: "{{ trigger.topic == selectedbgtopic }}"
                sequence:
                  - service: mqtt.publish
                    data:
                      topic: "{{jsoncommandtopic}}"
                      payload: >-
                        [{%- for i in range(4,15) if not i == 13 -%}
                        "p[7].b[{{i}}].bco={{selectedbg}}",{%- endfor -%}
                        {%- if states(alarmpanel) == "disarmed" -%}
                        "p[7].b[13].bco={{selectedbg}}",
                        "p[7].b[15].bco={{selectedbg}}"
                        {%- else -%}
                        "p[7].b[13].bco2={{selectedbg}}",
                        "p[7].b[15].bco2={{selectedbg}}"
                        {%- endif -%}]

              #########################################################################
              # Theme: Apply unselected foreground color on change
              - conditions:
                  - condition: template
                    value_template: "{{ trigger.topic == unselectedfgtopic }}"
                sequence:
                  - service: mqtt.publish
                    data:
                      topic: "{{jsoncommandtopic}}"
                      payload: >-
                        [{%- for i in range(4,15) if not i == 13 -%}
                        "p[7].b[{{i}}].pco2={{unselectedfg}}",{%- endfor -%}
                        {%- if states(alarmpanel) == "disarmed" -%}
                        "p[7].b[13].pco2={{unselectedfg}}",
                        "p[7].b[15].pco2={{unselectedfg}}"
                        {%- else -%}
                        "p[7].b[13].pco={{unselectedfg}}",
                        "p[7].b[15].pco={{unselectedfg}}"
                        {%- endif -%}]

              #########################################################################
              # Theme: Apply unselected background color on change
              - conditions:
                  - condition: template
                    value_template: "{{ trigger.topic == unselectedbgtopic }}"
                sequence:
                  - service: mqtt.publish
                    data:
                      topic: "{{jsoncommandtopic}}"
                      payload: >-
                        [{%- for i in range(4,15) if not i == 13 -%}
                        "p[7].b[{{i}}].bco2={{unselectedbg}}",{%- endfor -%}
                        {%- if states(alarmpanel) == "disarmed" -%}
                        "p[7].b[13].bco2={{unselectedbg}}",
                        "p[7].b[15].bco2={{unselectedbg}}"
                        {%- else -%}
                        "p[7].b[13].bco={{unselectedbg}}",
                        "p[7].b[15].bco={{unselectedbg}}"
                        {%- endif -%}]
