New climate page - basic support (#835)

* New climate page - basic support

Basic support to the new climate page.
Still pending values and buttons.

* Support to new climate services

* New climate page - basic
This commit is contained in:
Edward Firmo
2023-05-24 18:38:41 +02:00
committed by GitHub
parent e5a702e541
commit 14283c0776
2 changed files with 129 additions and 109 deletions

View File

@@ -311,33 +311,64 @@ api:
id(disp1).send_command_printf("page qrcode");
id(disp1).set_component_text_printf("qrcode.qrcode_value", "%s", qrdata.c_str());
#### Service to send thermostat cycle state ####
- service: send_thermostat_cycle_state
#### Service to send thermostat cycle state - deprecated on v3.3.1 ####
#- service: send_thermostat_cycle_state
# variables:
# value: float
# then:
# - wait_until:
# binary_sensor.is_on: nextion_init
# - lambda: |-
# //ESP_LOGD("nextion", "thermostat sendig value %f", value);
# int v = int(2 * std::min(std::max(value - 13.5, 0.0), 5.0));
# int left = v + (v ? 19 : 16); // 16 is empty left.
# v = int(2 * std::min(std::max(value - 18.0, 0.0), 4.0));
# int mid = v + (v ? 29 : 17); // 17 is empty mid.
# v = int(2 * std::min(std::max(value - 21.5, 0.0), 5.5));
# int right = v + (v ? 37 : 18); // 18 is empty right.
# // sends the 3 images to the display
# //ESP_LOGD("nextion", "thermostat left %i", left);
# //ESP_LOGD("nextion", "thermostat mid %i", mid);
# //ESP_LOGD("nextion", "thermostat right %i", right);
# id(disp1).send_command_printf("climate_left.pic=%i", left);
# id(disp1).send_command_printf("climate_middle.pic=%i", mid);
# id(disp1).send_command_printf("climate_right.pic=%i", right);
# // send target-temp
# id(disp1).set_component_text_printf("target_temp", "%.1f", value);
# id(display_target_temp).publish_state(value);
#### Service to set climate target_temp ####
- service: set_climate_target_temp
variables:
value: float
target_temp: float
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: |-
//ESP_LOGD("nextion", "thermostat sendig value %f", value);
int v = int(2 * std::min(std::max(value - 13.5, 0.0), 5.0));
int left = v + (v ? 19 : 16); // 16 is empty left.
v = int(2 * std::min(std::max(value - 18.0, 0.0), 4.0));
int mid = v + (v ? 29 : 17); // 17 is empty mid.
v = int(2 * std::min(std::max(value - 21.5, 0.0), 5.5));
int right = v + (v ? 37 : 18); // 18 is empty right.
// sends the 3 images to the display
//ESP_LOGD("nextion", "thermostat left %i", left);
//ESP_LOGD("nextion", "thermostat mid %i", mid);
//ESP_LOGD("nextion", "thermostat right %i", right);
id(disp1).send_command_printf("climate_left.pic=%i", left);
id(disp1).send_command_printf("climate_middle.pic=%i", mid);
id(disp1).send_command_printf("climate_right.pic=%i", right);
// send target-temp
id(disp1).set_component_text_printf("target_temp", "%.1f°", value);
id(display_target_temp).publish_state(value);
- &set_climate_target_temp
lambda: |-
id(disp1).set_component_value("climate.climateslider", target_temp);
id(disp1).set_component_text_printf("climate.target_temp", "%.1f", target_temp);
id(display_target_temp).publish_state(target_temp);
#### Service to set the buttons ####
#### Service to set climate state ####
- service: set_climate
variables:
state: string
hvac_modes: string
current_temp: float
target_temp: float
min_temp: int
max_temp: int
then:
- wait_until:
binary_sensor.is_on: nextion_init
- *set_climate_target_temp
- lambda: |-
id(disp1).send_command_printf("climate.climateslider.minval=%i", min_temp);
id(disp1).send_command_printf("climate.climateslider.maxval=%i", max_temp);
id(disp1).set_component_text_printf("climate.current_temp", "%.1f°", current_temp);
#### Service to set the buttons ####
- service: set_button
variables:
btn_id: string
@@ -895,7 +926,7 @@ display:
- logger.log: "Nextion start - Jump to page 8"
- lambda: id(disp1).send_command_printf("page 8");
- logger.log: "Nextion start - Publish ESPHome version"
- lambda: id(disp1).set_component_text_printf("boot.esph_version", "%s", "3.3"); ### esphome-version ###
- lambda: id(disp1).set_component_text_printf("boot.esph_version", "%s", "3.3.1"); ### esphome-version ###
- logger.log: "Nextion start - Wait for Home Assistant API"
- wait_until:
api.connected