Add service set_component_color
Deprecates the following services: - `send_command_font_color` - `send_command_background_color`
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user