diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md
index 928930d..c774d9b 100644
--- a/docs/ReleaseNotes.md
+++ b/docs/ReleaseNotes.md
@@ -37,7 +37,8 @@ Since in this update lots of input to the blueprint changed, we highly recommend
8. Removed switches "Relay 1 Local Fallback" and "Relay 2 Local Fallback", together with the relay fallback inputs. Now when you assign your panel's relay to it's respective button the control will be fully local and therefore will have the same behavior as the "fallback" in previous versions.
9. The "Hardware button long press hold delay" input was removed and the delay (800ms) is now hard coded in ESPHome.
10. The service `esphome.xxxxx_wake_up_display` was deprecated. Please use `esphome.xxxxx_wake_up` instead which uses the parameter `reset_timer: bool` to indicate if the timeout timer (to move back to Home page) should be reset.
-11. To be deprecated soon:
+11. The services `esphome.xxxxx_send_command_font_color` and `esphome.xxxxx_send_command_background_color` where deprecated. Please use `esphome.xxxxx_set_component_color` instead, and you can use RGB arrays for `foreground` and `background` colors, a 1-element array with the Nextion color code or an empty array if you don't want to change that specific parameter.
+12. To be deprecated soon:
- Old color selection (based in a text input where you typed a number).
The icons colors selected before the implementation of the color picker (when it was about typing a number) will be deprecated soon, so if you haven't done this yet, please select the color using the new color selector. Open the Blueprint and if the colors are shown, you are good, otherwise, please select a color.
- The panel selection based on a text box (where you manually typed the panel name).
The new device selection was introduce a few releases ago and is more reliable. The previous selections are still valid, but requires extra processing every time the automation is triggered, so it will be removed.
If you can see your device name on the blueprint settings screen, you are good, otherwise, pick your panel from the new drop down list.
- Sensor "NSPanel Event".
This sensor contains a json-like text and is used for ESPHome to send information to the blueprint. This is slowly being replaced by Home Assistant events and will then be removed.
The sensor "Current page" is back with the information about the page currently visible in your panel, so please update your automation if you are using the event sensor.
diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml
index 762f428..03fc712 100644
--- a/nspanel_blueprint.yaml
+++ b/nspanel_blueprint.yaml
@@ -3507,27 +3507,27 @@ variables:
##### Nextion dict ####
nextion:
color:
- blue: '1055' # rgb(0, 128, 248)
- grey_dark: '10597' # rgb(40, 44, 40)
- grey_light: '33808' # rgb(128, 128, 128)
- grey_super_light: '52857' # rgb(200, 204, 200)
- grey_white: '59164' # rgb(225, 225, 225)
- red: '63488' # rgb(248, 0, 0)
- white: '65535' # rgb(255, 255, 255)
- yellow: '65472' # rgb(248, 248, 0)
+ blue: [1055] #'1055' # rgb(0, 128, 248)
+ grey_dark: [10597] #'10597' # rgb(40, 44, 40)
+ grey_light: [33808] #'33808' # rgb(128, 128, 128)
+ grey_super_light: [52857] #'52857' # rgb(200, 204, 200)
+ grey_white: [59164] #'59164' # rgb(225, 225, 225)
+ red: [63488] #'63488' # rgb(248, 0, 0)
+ white: [65535] #'65535' # rgb(255, 255, 255)
+ yellow: [65472] #'65472' # rgb(248, 248, 0)
#### Colors from HA Style:
- green: '19818' # rgb(76, 175, 80)
- orange: '64704' # rgb(255, 152, 0)
- cyan: '1530' # rgb(0, 188, 212)
- deep-orange: '64164' # rgb(255, 87, 34)
- amber: '65024' # rgb(255, 193, 7)
- "off": '35921' #8a8a8a
- disabled: '48631' # rgb(189, 189, 189)
- unavailable: '6339'
+ green: [19818] #'19818' # rgb(76, 175, 80)
+ orange: [64704] #'64704' # rgb(255, 152, 0)
+ cyan: [1530] #'1530' # rgb(0, 188, 212)
+ deep-orange: [64164] #'64164' # rgb(255, 87, 34)
+ amber: [65024] #'65024' # rgb(255, 193, 7)
+ "off": [35921] #'35921' #8a8a8a
+ disabled: [48631] #'48631' # rgb(189, 189, 189)
+ unavailable: [6339] #'6339'
command:
alarm_settings: 'esphome.{{ nspanel_name }}_alarm_settings'
#background_color: 'esphome.{{ nspanel_name }}_send_command_background_color'
- font_color: 'esphome.{{ nspanel_name }}_send_command_font_color'
+ #font_color: 'esphome.{{ nspanel_name }}_send_command_font_color'
global_settings: 'esphome.{{ nspanel_name }}_global_settings'
hide: 'esphome.{{ nspanel_name }}_send_command_hide'
notification_clear: 'esphome.{{ nspanel_name }}_notification_clear'
@@ -3539,6 +3539,7 @@ variables:
qrcode: 'esphome.{{ nspanel_name }}_qrcode'
set_button: 'esphome.{{ nspanel_name }}_set_button'
set_climate: 'esphome.{{ nspanel_name }}_set_climate'
+ set_component_color: 'esphome.{{ nspanel_name }}_set_component_color'
set_entity: 'esphome.{{ nspanel_name }}_set_entity'
show: 'esphome.{{ nspanel_name }}_send_command_show'
show_all: 'esphome.{{ nspanel_name }}_send_command_show_all'
@@ -6624,15 +6625,11 @@ action:
outdoor_temp_color_rgb: !input 'home_outdoor_temp_label_color'
### LABEL Outdoor Temp Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: home.outdoor_temp
- message: >
- {{
- outdoor_temp_color_rgb
- if is_number(outdoor_temp_color_rgb)
- else ((outdoor_temp_color_rgb[0] //(2**3)) *(2**11))+((outdoor_temp_color_rgb[1] //(2**2)) *(2**5))+(outdoor_temp_color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ outdoor_temp_color_rgb ] if is_number(outdoor_temp_color_rgb) else outdoor_temp_color_rgb }}'
+ background: []
continue_on_error: true
### LABEL Outdoor Temp Font ###
- *delay-default
@@ -6677,15 +6674,11 @@ action:
then:
### ICON Indoor Temp Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: home.indoortempicon
- message: >
- {{
- indoor_temp.icon.color_rgb
- if is_number(indoor_temp.icon.color_rgb)
- else ((indoor_temp.icon.color_rgb[0] //(2**3)) *(2**11))+((indoor_temp.icon.color_rgb[1] //(2**2)) *(2**5))+(indoor_temp.icon.color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ indoor_temp.icon.color_rgb ] if is_number(indoor_temp.icon.color_rgb) else indoor_temp.icon.color_rgb }}'
+ background: []
continue_on_error: true
### ICON Indoor Temp Font ###
- *delay-default
@@ -6706,15 +6699,11 @@ action:
continue_on_error: true
### LABEL Indoor Temp Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: home.current_temp
- message: >
- {{
- indoor_temp.label.color_rgb
- if is_number(indoor_temp.label.color_rgb)
- else ((indoor_temp.label.color_rgb[0] //(2**3)) *(2**11))+((indoor_temp.label.color_rgb[1] //(2**2)) *(2**5))+(indoor_temp.label.color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ indoor_temp.label.color_rgb ] if is_number(indoor_temp.label.color_rgb) else indoor_temp.label.color_rgb }}'
+ background: []
continue_on_error: true
### LABEL Indoor Temp Font ###
- *delay-default
@@ -6735,15 +6724,11 @@ action:
then:
### LABEL Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: home.left_bt_text
- message: >
- {{
- hardware.buttons.left.color_rgb
- if is_number(hardware.buttons.left.color_rgb)
- else ((hardware.buttons.left.color_rgb[0] //(2**3)) *(2**11))+((hardware.buttons.left.color_rgb[1] //(2**2)) *(2**5))+(hardware.buttons.left.color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ hardware.buttons.left.color_rgb ] if is_number(hardware.buttons.left.color_rgb) else hardware.buttons.left.color_rgb }}'
+ background: []
continue_on_error: true
### LABEL Font ###
- *delay-default
@@ -6768,15 +6753,11 @@ action:
then:
### LABEL Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: home.right_bt_text
- message: >
- {{
- hardware.buttons.right.color_rgb
- if is_number(hardware.buttons.right.color_rgb)
- else ((hardware.buttons.right.color_rgb[0] //(2**3)) *(2**11))+((hardware.buttons.right.color_rgb[1] //(2**2)) *(2**5))+(hardware.buttons.right.color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ hardware.buttons.right.color_rgb ] if is_number(hardware.buttons.right.color_rgb) else hardware.buttons.right.color_rgb }}'
+ background: []
continue_on_error: true
### LABEL Font ###
- *delay-default
@@ -6897,18 +6878,11 @@ action:
then:
### ICON Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: '{{ repeat.item.page }}.{{ repeat.item.component }}'
- message: >
- {{
- repeat.item.icon_color_rgb
- if is_number(repeat.item.icon_color_rgb)
- else
- ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+
- ((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+
- (repeat.item.icon_color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ repeat.item.icon_color_rgb ] if is_number(repeat.item.icon_color_rgb) else repeat.item.icon_color_rgb }}'
+ background: []
continue_on_error: true
### ICON Font ###
- *delay-default
@@ -6952,18 +6926,11 @@ action:
then:
### ICON Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: '{{ repeat.item.page }}.{{ repeat.item.component }}_icon'
- message: >
- {{
- repeat.item.icon_color_rgb
- if is_number(repeat.item.icon_color_rgb)
- else
- ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+
- ((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+
- (repeat.item.icon_color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ repeat.item.icon_color_rgb ] if is_number(repeat.item.icon_color_rgb) else repeat.item.icon_color_rgb }}'
+ background: []
continue_on_error: true
### ICON Font ###
- *delay-default
@@ -6988,18 +6955,11 @@ action:
- condition: '{{ repeat_item_state_available }}'
### LABEL Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: '{{ repeat.item.page }}.{{ repeat.item.component }}{{ "_state" if repeat.item.page == page.home }}'
- message: >
- {{
- repeat.item.label_color_rgb
- if is_number(repeat.item.label_color_rgb)
- else
- ((repeat.item.label_color_rgb[0] //(2**3)) *(2**11))+
- ((repeat.item.label_color_rgb[1] //(2**2)) *(2**5))+
- (repeat.item.label_color_rgb[2] //(2**3))
- }}
+ foreground: '{{ [ repeat.item.label_color_rgb ] if is_number(repeat.item.label_color_rgb) else repeat.item.label_color_rgb }}'
+ background: []
continue_on_error: true
### LABEL Font ###
- *delay-default
@@ -7036,14 +6996,7 @@ action:
}}
set_button04_icon_font: >
{{
- (
- bt_notific.color_rgb[notification_unread_state]
- if is_number(bt_notific.color_rgb[notification_unread_state])
- else
- ((bt_notific.color_rgb[notification_unread_state][0] //(2**3)) *(2**11))+
- ((bt_notific.color_rgb[notification_unread_state][1] //(2**2)) *(2**5))+
- (bt_notific.color_rgb[notification_unread_state][2] //(2**3))
- )
+ ( [ bt_notific.color_rgb[notification_unread_state] ] if is_number(bt_notific.color_rgb[notification_unread_state]) else bt_notific.color_rgb[notification_unread_state] )
if notification_unread_state in ["on", "off"] and notification_text_state | length > 0
else nextion.color.grey_light
}}
@@ -7057,10 +7010,11 @@ action:
##### SET ICON Font Color - Notify #####
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: home.bt_notific
- message: '{{ set_button04_icon_font }}'
+ foreground: '{{ set_button04_icon_font }}'
+ background: []
continue_on_error: true
##### Show/Hide notification button #####
@@ -7658,10 +7612,11 @@ action:
continue_on_error: true
### ICON Battery Font Color ###
- *delay-default
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: cover.battery_icon
- message: '{{ nextion.color.grey_super_light }}'
+ foreground: '{{ nextion.color.grey_super_light }}'
+ background: []
continue_on_error: true
### ICON Battery Font ###
- *delay-default
@@ -7867,15 +7822,16 @@ action:
- condition: '{{ repeat.item.mode in hvac_modes }}'
- *delay-default
### ICON Font Color ###
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: 'climate.{{ repeat.item.component }}_icon'
- message: >
+ foreground: >
{{
nextion.color[repeat.item.color]
if states(climate_entity) == repeat.item.mode
else nextion.color.disabled
}}
+ background: []
continue_on_error: true
### ICON Font ###
- *delay-default
@@ -7924,15 +7880,16 @@ action:
- condition: '{{ entity_domain != "unknown" }}'
- *delay-default
### ICON Font Color ###
- - service: '{{ nextion.command.font_color }}'
+ - service: '{{ nextion.command.set_component_color }}'
data:
component: 'climate.{{ repeat.item.component }}_icon'
- message: >
+ foreground: >
{{
- ((repeat.item.icon_color_rgb[0] //(2**3)) *(2**11))+((repeat.item.icon_color_rgb[1] //(2**2)) *(2**5))+(repeat.item.icon_color_rgb[2] //(2**3))
+ repeat.item.icon_color_rgb
if states(repeat.item.entity) in ["on", "true", true, "open", "opening"]
else nextion.color.disabled
}}
+ background: []
continue_on_error: true
### ICON Font ###
- *delay-default
diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml
index a253953..3ece2e8 100644
--- a/nspanel_esphome.yaml
+++ b/nspanel_esphome.yaml
@@ -196,20 +196,29 @@ api:
- lambda: id(disp1).show_component("255");
##### Service to send a command "font color" directly to the display #####
- - service: send_command_font_color
+ - service: set_component_color
variables:
component: string
- message: int
+ foreground: int[]
+ background: int[]
then:
- - lambda: 'id(disp1).set_component_font_color(component.c_str(), message);'
+ - lambda: id(set_component_color).execute(component, foreground, background);
+
+ ##### Service to send a command "font color" directly to the display #####
+ #- service: send_command_font_color
+ # variables:
+ # component: string
+ # message: int
+ # then:
+ # - lambda: 'id(disp1).set_component_font_color(component.c_str(), message);'
##### Service to send a command "background color" directly to the display #####
- - service: send_command_background_color
- variables:
- component: string
- message: int
- then:
- - lambda: 'id(disp1).set_component_background_color(component.c_str(), message);'
+ #- service: send_command_background_color
+ # variables:
+ # component: string
+ # message: int
+ # then:
+ # - lambda: 'id(disp1).set_component_background_color(component.c_str(), message);'
##### Service to show a notification-message on the screen #####
- service: notification_show
@@ -1869,6 +1878,31 @@ script:
}
ESP_LOGV("script.update_climate_icon", "Finished");
+ - id: set_component_color
+ mode: queued
+ parameters:
+ component: string
+ foreground: int[]
+ background: int[]
+ then:
+ - lambda: |-
+ ESP_LOGV("script.set_component_color", "Starting");
+ ESP_LOGV("script.set_component_color", "Component: %s", component.c_str());
+ int fg565 = -1;
+ int bg565 = -1;
+
+ // Foreground
+ if (foreground.size() == 3) fg565 = ((foreground[0] & 0b11111000) << 8) | ((foreground[1] & 0b11111100) << 3) | (foreground[2] >> 3);
+ else if (foreground.size() == 1) fg565 = foreground[0];
+ if (fg565 >= 0) id(disp1).set_component_font_color(component.c_str(), fg565);
+
+ // Background
+ if (background.size() == 3) bg565 = ((background[0] & 0b11111000) << 8) | ((background[1] & 0b11111100) << 3) | (background[2] >> 3);
+ else if (background.size() == 1) bg565 = background[0];
+ if (bg565 >= 0) id(disp1).set_component_background_color(component.c_str(), bg565);
+
+ ESP_LOGV("script.set_component_color", "Finished");
+
##### ADD-ONS ############################################################
##### Add-on - Climate #####
- id: addon_climate_service_call