Media player - Buttons
- Added code to buttons on media_player page. - Clean-up: - Moved wake-up select from Blueprint to ESPHome component - Removed `switch.xxxxx_confirmation_message`
This commit is contained in:
@@ -204,22 +204,6 @@ api:
|
||||
then:
|
||||
- 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 to show a notification-message on the screen #####
|
||||
- service: notification_show
|
||||
variables:
|
||||
@@ -392,7 +376,7 @@ api:
|
||||
id(disp1).send_command_printf("home.dimtimer.en=1");
|
||||
id(disp1).send_command_printf("home.sleeptimer.en=1");
|
||||
}
|
||||
else if (id(current_page).state == "screensaver") id(disp1).send_command_printf("page %i", id(wakeup_page_id));
|
||||
else if (id(current_page).state == "screensaver") id(disp1).send_command_printf("page %s", id(wakeup_page_name).state);
|
||||
id(disp1).send_command_printf("dim=brightness");
|
||||
if (reset_timer) id(page_timer)->execute(int(id(page_timeout).state));
|
||||
|
||||
@@ -413,6 +397,7 @@ api:
|
||||
id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
|
||||
if (strcmp(ent_icon.c_str(), "0") != 0) id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
|
||||
id(disp1).set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str());
|
||||
//id(display_wrapped_text).execute(entlabel.c_str(), ent_label.c_str(), id(display_mode) == 2 ? 16 : 20);
|
||||
id(disp1).set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str());
|
||||
if (strcmp(ent_value_xcen.c_str(), "0") != 0) id(disp1).send_command_printf("%s", entxcen.c_str());
|
||||
|
||||
@@ -432,7 +417,6 @@ api:
|
||||
embedded_climate: bool
|
||||
embedded_indoor_temperature: bool
|
||||
temperature_unit_is_fahrenheit: bool
|
||||
wakeup_page: int
|
||||
mui_please_confirm: string
|
||||
then:
|
||||
- lambda: |-
|
||||
@@ -481,10 +465,6 @@ api:
|
||||
id(temp_unit_fahrenheit) = temperature_unit_is_fahrenheit;
|
||||
id(display_embedded_temp)->execute();
|
||||
|
||||
// Wakeup page
|
||||
ESP_LOGV("service.global_settings", "Wakeup page - Start");
|
||||
id(wakeup_page_id) = wakeup_page;
|
||||
|
||||
// Confirm page
|
||||
ESP_LOGV("service.global_settings", "Confirm page - Start");
|
||||
id(display_wrapped_text).execute("confirm.title", mui_please_confirm.c_str(), 15);
|
||||
@@ -530,7 +510,7 @@ api:
|
||||
- lambda: ESP_LOGV("service.global_settings", "Play boot sound");
|
||||
- rtttl.play:
|
||||
rtttl: 'two short:d=4,o=5,b=100:16e6,16e6'
|
||||
- lambda: id(disp1).send_command_printf("page %i", id(wakeup_page_id));
|
||||
- lambda: id(disp1).send_command_printf("page %s", id(wakeup_page_name).state);
|
||||
|
||||
- lambda: ESP_LOGV("service.global_settings", "Finished");
|
||||
|
||||
@@ -721,6 +701,7 @@ api:
|
||||
// Logs - End
|
||||
ESP_LOGV("service.alarm_settings", "Finished");
|
||||
|
||||
#### Service to populate the media player page #####
|
||||
- service: media_player
|
||||
variables:
|
||||
entity: string
|
||||
@@ -770,7 +751,7 @@ api:
|
||||
id(disp1).set_component_text_printf("time_total", "%i", time_total);
|
||||
id(disp1).set_component_value("time_progress", time_progress);
|
||||
id(disp1).set_component_text_printf("vol_text", "%i%", volume);
|
||||
id(disp1).set_component_value("vol_slider", time_progress);
|
||||
id(disp1).set_component_value("vol_slider", volume);
|
||||
if (bt_mute > 0)
|
||||
{
|
||||
id(disp1).show_component("bt_mute");
|
||||
@@ -865,12 +846,6 @@ globals:
|
||||
restore_value: false
|
||||
#initial_value: '63488'
|
||||
|
||||
##### Wakeup page ID #####
|
||||
- id: wakeup_page_id
|
||||
type: int
|
||||
restore_value: true
|
||||
initial_value: '0'
|
||||
|
||||
##### Versions #####
|
||||
- id: version_blueprint
|
||||
type: std::string
|
||||
@@ -1191,7 +1166,18 @@ text_sensor:
|
||||
else if (page=="screensaver")
|
||||
{
|
||||
ESP_LOGV("text_sensor.nspanelevent", "Construct screensaver page");
|
||||
id(disp1).set_component_value("orign", id(wakeup_page_id));
|
||||
int wakeup_page_id = 0;
|
||||
if (id(wakeup_page_name).state == "buttonpage01") wakeup_page_id = 12;
|
||||
else if (id(wakeup_page_name).state == "buttonpage02") wakeup_page_id = 13;
|
||||
else if (id(wakeup_page_name).state == "buttonpage03") wakeup_page_id = 14;
|
||||
else if (id(wakeup_page_name).state == "buttonpage04") wakeup_page_id = 15;
|
||||
else if (id(wakeup_page_name).state == "entitypage01") wakeup_page_id = 18;
|
||||
else if (id(wakeup_page_name).state == "entitypage02") wakeup_page_id = 19;
|
||||
else if (id(wakeup_page_name).state == "entitypage03") wakeup_page_id = 20;
|
||||
else if (id(wakeup_page_name).state == "entitypage04") wakeup_page_id = 21;
|
||||
else if (id(wakeup_page_name).state == "qrcode") wakeup_page_id = 17;
|
||||
else if (id(wakeup_page_name).state == "alarm") wakeup_page_id = 23;
|
||||
id(disp1).set_component_value("orign", wakeup_page_id);
|
||||
}
|
||||
else if (page=="climate")
|
||||
{
|
||||
@@ -1241,11 +1227,8 @@ text_sensor:
|
||||
else if (page=="settings") id(disp1).set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline
|
||||
else if (page=="notification")
|
||||
{
|
||||
if (not id(confirmation_message).state)
|
||||
{
|
||||
id(disp1).set_component_text_printf("notification.notifi_label", "%s", id(notification_label).state.c_str());
|
||||
id(display_wrapped_text).execute("notification.notifi_text01", id(notification_text).state.c_str(), id(display_mode) == 2 ? 23 : 32);
|
||||
}
|
||||
id(disp1).set_component_text_printf("notification.notifi_label", "%s", id(notification_label).state.c_str());
|
||||
id(display_wrapped_text).execute("notification.notifi_text01", id(notification_text).state.c_str(), id(display_mode) == 2 ? 23 : 32);
|
||||
}
|
||||
else if (page=="media_player")
|
||||
{
|
||||
@@ -1295,8 +1278,9 @@ text_sensor:
|
||||
int embedded = doc["embedded"];
|
||||
ESP_LOGV("text_sensor.localevent", "embedded: %i", embedded);
|
||||
std::string service = "";
|
||||
auto ha_event = new esphome::api::CustomAPIDevice();
|
||||
|
||||
// send event to Home Assistant
|
||||
auto ha_event = new esphome::api::CustomAPIDevice();
|
||||
if (event=="pagechanged")
|
||||
{
|
||||
ESP_LOGD("text_sensor.localevent", "New page: %s", page.c_str());
|
||||
@@ -1326,8 +1310,8 @@ text_sensor:
|
||||
});
|
||||
}
|
||||
|
||||
if (page == "climate") id(service_call_climate)->execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1));
|
||||
else if (page == "alarm")
|
||||
// page based actions
|
||||
if (page == "alarm")
|
||||
{
|
||||
std::string code_format = doc["code_format"];
|
||||
std::string code_arm_req = doc["code_arm_req"];
|
||||
@@ -1344,29 +1328,6 @@ text_sensor:
|
||||
}
|
||||
else id(service_call_alarm_control_panel)->execute(entity.c_str(), key.c_str(), code_format.c_str(), "");
|
||||
}
|
||||
else if (page == "keyb_num")
|
||||
{
|
||||
std::string base_domain = doc["base_domain"];
|
||||
if (base_domain == "alarm")
|
||||
{
|
||||
std::string code_format = doc["code_format"];
|
||||
std::string pin = doc["pin"];
|
||||
id(service_call_alarm_control_panel)->execute(entity.c_str(), key.c_str(), code_format.c_str(), pin.c_str());
|
||||
}
|
||||
else if (base_domain == "" or base_domain.empty()) base_domain = "home";
|
||||
id(disp1).send_command_printf("page %s", base_domain.c_str());
|
||||
}
|
||||
else if (page == "light") id(ha_call_service)->execute("light.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
||||
else if (page == "cover")
|
||||
{
|
||||
if (key == "position") id(ha_call_service)->execute("cover.set_cover_position", key.c_str(), value.c_str(), entity.c_str());
|
||||
else id(ha_call_service)->execute((std::string("cover.") + key.c_str()), "", "", entity.c_str());
|
||||
}
|
||||
else if (page == "fan")
|
||||
{
|
||||
if (key == "stop" or value == "0") id(ha_call_service)->execute("fan.turn_off", "", "", entity.c_str());
|
||||
else id(ha_call_service)->execute("fan.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
||||
}
|
||||
else if (page=="boot")
|
||||
{
|
||||
// Detect display mode - Need review
|
||||
@@ -1398,11 +1359,35 @@ text_sensor:
|
||||
});
|
||||
if (stof(value) >= 5)
|
||||
{
|
||||
ESP_LOGV("text_sensor.localevent", "Jump to wakeup page: %i", id(wakeup_page_id));
|
||||
id(disp1).send_command_printf("page %i", id(wakeup_page_id));
|
||||
ESP_LOGV("text_sensor.localevent", "Jump to wakeup page: %s", id(wakeup_page_name).state);
|
||||
id(disp1).send_command_printf("page %s", id(wakeup_page_name).state);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (page == "climate") id(service_call_climate)->execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1));
|
||||
else if (page == "cover")
|
||||
{
|
||||
if (key == "position") id(ha_call_service)->execute("cover.set_cover_position", key.c_str(), value.c_str(), entity.c_str());
|
||||
else id(ha_call_service)->execute((std::string("cover.") + key.c_str()), "", "", entity.c_str());
|
||||
}
|
||||
else if (page == "fan")
|
||||
{
|
||||
if (key == "stop" or value == "0") id(ha_call_service)->execute("fan.turn_off", "", "", entity.c_str());
|
||||
else id(ha_call_service)->execute("fan.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
||||
}
|
||||
else if (page == "keyb_num")
|
||||
{
|
||||
std::string base_domain = doc["base_domain"];
|
||||
if (base_domain == "alarm")
|
||||
{
|
||||
std::string code_format = doc["code_format"];
|
||||
std::string pin = doc["pin"];
|
||||
id(service_call_alarm_control_panel)->execute(entity.c_str(), key.c_str(), code_format.c_str(), pin.c_str());
|
||||
}
|
||||
else if (base_domain == "" or base_domain.empty()) base_domain = "home";
|
||||
id(disp1).send_command_printf("page %s", base_domain.c_str());
|
||||
}
|
||||
else if (page == "light") id(ha_call_service)->execute("light.turn_on", key.c_str(), value.c_str(), entity.c_str());
|
||||
|
||||
ESP_LOGV("text_sensor.localevent", "Finished");
|
||||
|
||||
@@ -1446,14 +1431,6 @@ switch:
|
||||
optimistic: true
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
|
||||
##### Confirmation Message #####
|
||||
- name: ${device_name} Confirmation Message
|
||||
platform: template
|
||||
id: confirmation_message
|
||||
entity_category: config
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
optimistic: true
|
||||
|
||||
##### PHYSICAL SWITCH 1 #####
|
||||
- name: ${device_name} Relay 1
|
||||
platform: gpio
|
||||
@@ -1622,6 +1599,33 @@ number:
|
||||
restore_value: true
|
||||
optimistic: true
|
||||
|
||||
select:
|
||||
- id: wakeup_page_name
|
||||
name: ${device_name} Wake-up page
|
||||
platform: template
|
||||
options:
|
||||
- home
|
||||
- buttonpage01
|
||||
- buttonpage02
|
||||
- buttonpage03
|
||||
- buttonpage04
|
||||
- entitypage01
|
||||
- entitypage02
|
||||
- entitypage03
|
||||
- entitypage04
|
||||
- qrcode
|
||||
- alarm
|
||||
initial_option: 'home'
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
internal: false
|
||||
entity_category: config
|
||||
icon: mdi:page-next-outline
|
||||
set_action:
|
||||
- logger.log:
|
||||
format: "Wake-up page set: %s"
|
||||
args: ["x.c_str()"]
|
||||
|
||||
##### START - DISPLAY START CONFIGURATION #####
|
||||
display:
|
||||
- id: disp1
|
||||
|
||||
Reference in New Issue
Block a user