diff --git a/Home_Assistant/blueprints/hasp_Display_Calendar_with_Icon.yaml b/Home_Assistant/blueprints/hasp_Display_Calendar_with_Icon.yaml
index dbf2035..6703a46 100644
--- a/Home_Assistant/blueprints/hasp_Display_Calendar_with_Icon.yaml
+++ b/Home_Assistant/blueprints/hasp_Display_Calendar_with_Icon.yaml
@@ -22,6 +22,28 @@ blueprint:
+ ## Nextion color codes
+
+
+
+ The Nextion environment utilizes RGB 565 encoding. [Use this handy convertor](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to select your colors and convert to the RGB 565 format.
+
+ Here are some example colors:
+
+ | Color | Code |
+ |--------|-------|
+ | White | 65535 |
+ | Black | 0 |
+ | Grey | 25388 |
+ | Red | 63488 |
+ | Green | 2016 |
+ | Blue | 31 |
+ | Yellow | 65504 |
+ | Orange | 64512 |
+ | Brown | 48192 |
+
+
+
domain: automation
input:
haspdevice:
@@ -52,6 +74,51 @@ blueprint:
max: 7
mode: slider
unit_of_measurement: button
+ selected_fgcolor:
+ name: "Selected foreground color"
+ description: 'Selected foreground color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme selected foreground color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ selected_bgcolor:
+ name: "Selected background color"
+ description: 'Selected background color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme selected background color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ unselected_fgcolor:
+ name: "Unselected foreground color"
+ description: 'Unselected foreground color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme unselected foreground color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ unselected_bgcolor:
+ name: "Unselected background color"
+ description: 'Unselected background color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme unselected background color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ icon_fgcolor:
+ name: "Icon foreground color"
+ description: 'Icon foreground color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme selected foreground color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
mode: parallel
max_exceeded: silent
@@ -66,14 +133,15 @@ variables:
{%- endfor -%}
hasppage: !input hasppage
haspbutton: !input haspbutton
+ selected_fgcolor: !input selected_fgcolor
+ selected_bgcolor: !input selected_bgcolor
+ unselected_fgcolor: !input unselected_fgcolor
+ unselected_bgcolor: !input unselected_bgcolor
+ icon_fgcolor: !input icon_fgcolor
haspobject: '{{ "p[" ~ hasppage ~ "].b[" ~ haspbutton ~ "]" }}'
commandtopic: '{{ "hasp/" ~ haspname ~ "/command/" ~ haspobject }}'
jsontopic: '{{ "hasp/" ~ haspname ~ "/state/json" }}'
jsoncommandtopic: '{{ "hasp/" ~ haspname ~ "/command/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" }}'
activepage: >-
{%- set activepage = namespace() -%}
{%- for entity in device_entities(haspdevice) -%}
@@ -82,54 +150,90 @@ variables:
{%- endif -%}
{%- endfor -%}
{{ states(activepage.entity) | int(default=-1) }}
+ 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 }}
+ {%- if (selected_fgcolor|int) >= 0 -%}
+ {{ selected_fgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
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 }}
+ {%- if (selected_bgcolor|int) >= 0 -%}
+ {{ selected_bgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
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 }}
+ {%- if (unselected_fgcolor|int) >= 0 -%}
+ {{ unselected_fgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
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 }}
+ {%- if (unselected_bgcolor|int) >= 0 -%}
+ {{ unselected_bgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
+ iconcolor: >-
+ {%- if (icon_fgcolor|int) >= 0 -%}
+ {{ icon_fgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
text: '{{(now().strftime("%b "))~now().day}}'
font: 8
ypos: "{{(haspbutton|int - 4) * 67 + 2}}" # calculate the top pixel position based on the selected button
@@ -212,7 +316,7 @@ action:
"{{haspobject}}.bco2={{unselectedbg}}",
"{{haspobject}}.txt=\"{{text}} \""
{%- if activepage|int == hasppage|int -%}
- ,"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""
+ ,"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""
{%- endif -%}]
#########################################################################
# Update the calendar text every day at midnight. If the selected page is currently active, also place the icon.
@@ -226,7 +330,7 @@ action:
payload: >-
["{{haspobject}}.txt=\"{{text}} \""
{%- if activepage|int == hasppage|int -%}
- ,"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""
+ ,"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""
{%- endif -%}]
#########################################################################
# Catch MQTT events
@@ -251,7 +355,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
- conditions: # Page changed to our page, so place the icon on the screen.
- condition: template
value_template: '{{ (trigger.topic == jsontopic ) and (trigger.payload_json.event == "page" ) and (trigger.payload_json.value == hasppage|int) }}'
@@ -259,7 +363,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply selected foreground color when it changes.
# Any change to the button will remove the overlaid icon.
@@ -277,7 +381,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{trigger.payload}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply selected background color on change
- conditions:
@@ -294,7 +398,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply unselected foreground color on change
- conditions:
@@ -311,7 +415,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply unselected background color on change
- conditions:
@@ -328,4 +432,4 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
diff --git a/Home_Assistant/blueprints/hasp_Display_Clock_with_Icon.yaml b/Home_Assistant/blueprints/hasp_Display_Clock_with_Icon.yaml
index 20de71b..4fb87b2 100644
--- a/Home_Assistant/blueprints/hasp_Display_Clock_with_Icon.yaml
+++ b/Home_Assistant/blueprints/hasp_Display_Clock_with_Icon.yaml
@@ -22,6 +22,28 @@ blueprint:
+ ## Nextion color codes
+
+
+
+ The Nextion environment utilizes RGB 565 encoding. [Use this handy convertor](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to select your colors and convert to the RGB 565 format.
+
+ Here are some example colors:
+
+ | Color | Code |
+ |--------|-------|
+ | White | 65535 |
+ | Black | 0 |
+ | Grey | 25388 |
+ | Red | 63488 |
+ | Green | 2016 |
+ | Blue | 31 |
+ | Yellow | 65504 |
+ | Orange | 64512 |
+ | Brown | 48192 |
+
+
+
domain: automation
input:
haspdevice:
@@ -57,6 +79,51 @@ blueprint:
default: false
selector:
boolean:
+ selected_fgcolor:
+ name: "Selected foreground color"
+ description: 'Selected foreground color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme selected foreground color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ selected_bgcolor:
+ name: "Selected background color"
+ description: 'Selected background color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme selected background color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ unselected_fgcolor:
+ name: "Unselected foreground color"
+ description: 'Unselected foreground color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme unselected foreground color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ unselected_bgcolor:
+ name: "Unselected background color"
+ description: 'Unselected background color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme unselected background color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
+ icon_fgcolor:
+ name: "Icon foreground color"
+ description: 'Icon foreground color in Nextion RGB565 format (see "Nextion color codes" above for reference). -1 = Current theme selected foreground color.'
+ default: -1
+ selector:
+ number:
+ min: -1
+ max: 65535
+ mode: slider
mode: parallel
max_exceeded: silent
@@ -72,6 +139,11 @@ variables:
hasppage: !input hasppage
haspbutton: !input haspbutton
hour24: !input hour24
+ selected_fgcolor: !input selected_fgcolor
+ selected_bgcolor: !input selected_bgcolor
+ unselected_fgcolor: !input unselected_fgcolor
+ unselected_bgcolor: !input unselected_bgcolor
+ icon_fgcolor: !input icon_fgcolor
haspobject: '{{ "p[" ~ hasppage ~ "].b[" ~ haspbutton ~ "]" }}'
commandtopic: '{{ "hasp/" ~ haspname ~ "/command/" ~ haspobject }}'
jsontopic: '{{ "hasp/" ~ haspname ~ "/state/json" }}'
@@ -89,53 +161,85 @@ variables:
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 }}
+ {%- if (selected_fgcolor|int) >= 0 -%}
+ {{ selected_fgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
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 }}
+ {%- if (selected_bgcolor|int) >= 0 -%}
+ {{ selected_bgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
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 }}
+ {%- if (unselected_fgcolor|int) >= 0 -%}
+ {{ unselected_fgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
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 }}
+ {%- if (unselected_bgcolor|int) >= 0 -%}
+ {{ unselected_bgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
+ iconcolor: >-
+ {%- if (icon_fgcolor|int) >= 0 -%}
+ {{ icon_fgcolor }}
+ {%- else -%}
+ {%- 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 }}
+ {%- endif -%}
text: '{%- if hour24 == true -%}{%- set hourformat="%-H" -%}{%- else %}{%- set hourformat="%I" -%}{%- endif -%}{{(now().strftime(hourformat)|int)~now().strftime(":%M")}}'
font: 10
ypos: "{{(haspbutton|int - 4) * 67 + 2}}" # calculate the top pixel position based on the selected button
@@ -218,7 +322,7 @@ action:
"{{haspobject}}.bco2={{unselectedbg}}",
"{{haspobject}}.txt=\"{{text}} \""
{%- if activepage|int == hasppage|int -%}
- ,"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""
+ ,"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""
{%- endif -%}]
#########################################################################
# Every minute, update the clock text. If the selected page is currently active, also place the icon.
@@ -229,7 +333,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["{{haspobject}}.txt=\"{{text}} \""{%- if activepage|int == hasppage|int -%},"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""{%- endif -%}]'
+ payload: '["{{haspobject}}.txt=\"{{text}} \""{%- if activepage|int == hasppage|int -%},"delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""{%- endif -%}]'
#########################################################################
# Catch MQTT events
@@ -254,7 +358,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
- conditions: # Page changed to our page, so place the icon on the screen.
- condition: template
value_template: '{{ (trigger.topic == jsontopic ) and (trigger.payload_json.event == "page" ) and (trigger.payload_json.value == hasppage|int) }}'
@@ -262,7 +366,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply selected foreground color when it changes.
# Any change to the button will remove the overlaid icon.
@@ -280,7 +384,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{trigger.payload}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply selected background color on change
- conditions:
@@ -297,7 +401,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply unselected foreground color on change
- conditions:
@@ -314,7 +418,7 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
#########################################################################
# Theme: Apply unselected background color on change
- conditions:
@@ -331,4 +435,4 @@ action:
- service: mqtt.publish
data:
topic: "{{jsoncommandtopic}}"
- payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{selectedfg}},0,1,1,3,\"{{icon}}\""]'
+ payload: '["delay=1","xstr {{xpos}},{{ypos}},{{iconwidth}},{{iconheight}},{{iconfont}},{{iconcolor}},0,1,1,3,\"{{icon}}\""]'
diff --git a/Home_Assistant/blueprints/hasp_Display_Weather_Condition_with_Icon.yaml b/Home_Assistant/blueprints/hasp_Display_Weather_Condition_with_Icon.yaml
index aa90a09..5098550 100644
--- a/Home_Assistant/blueprints/hasp_Display_Weather_Condition_with_Icon.yaml
+++ b/Home_Assistant/blueprints/hasp_Display_Weather_Condition_with_Icon.yaml
@@ -43,6 +43,7 @@ blueprint:
| Brown | 48192 |
+
domain: automation
input:
haspdevice:
diff --git a/images/hasp_Theme_Dark_on_Light.png b/images/hasp_Theme_Dark_on_Light.png
index d13ddcd..7e7d448 100644
Binary files a/images/hasp_Theme_Dark_on_Light.png and b/images/hasp_Theme_Dark_on_Light.png differ
diff --git a/images/hasp_Theme_Light_on_BlueDark.png b/images/hasp_Theme_Light_on_BlueDark.png
new file mode 100644
index 0000000..0812ccd
Binary files /dev/null and b/images/hasp_Theme_Light_on_BlueDark.png differ
diff --git a/images/hasp_Theme_Light_on_Dark.png b/images/hasp_Theme_Light_on_Dark.png
index bdb5654..f465f12 100644
Binary files a/images/hasp_Theme_Light_on_Dark.png and b/images/hasp_Theme_Light_on_Dark.png differ