Fix display as a light
@@ -332,8 +332,6 @@ button:
|
|||||||
|
|
||||||
|
|
||||||
### Set display as a light
|
### Set display as a light
|
||||||
> Requires v4.1 or higher
|
|
||||||
|
|
||||||
You can set your display as a light in Home Assistant, so you can control the brightness and turn on/off just like any other light, and even use this in your automation to control when your panel is on with the same automation you use for your lights:
|
You can set your display as a light in Home Assistant, so you can control the brightness and turn on/off just like any other light, and even use this in your automation to control when your panel is on with the same automation you use for your lights:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -348,14 +346,14 @@ light:
|
|||||||
on_turn_on:
|
on_turn_on:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGV("light.display_light", "Turn-on");
|
ESP_LOGD("light.display_light", "Turn-on");
|
||||||
if (id(current_page).state == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str());
|
if (current_page->state == "screensaver") disp1->goto_page(wakeup_page_name->state.c_str());
|
||||||
id(timer_reset_all).execute(id(wakeup_page_name).state.c_str());
|
timer_reset_all->execute(wakeup_page_name->state.c_str());
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGV("light.display_light", "Turn-off");
|
ESP_LOGD("light.display_light", "Turn-off");
|
||||||
id(disp1).goto_page("screensaver");
|
disp1->goto_page("screensaver");
|
||||||
|
|
||||||
output:
|
output:
|
||||||
# Output required by `display_light` to send the commands to Nextion
|
# Output required by `display_light` to send the commands to Nextion
|
||||||
@@ -365,22 +363,22 @@ output:
|
|||||||
write_action:
|
write_action:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGV("output.display_output", "state: %f", state);
|
ESP_LOGV("output.display_output", "state: %f", state);
|
||||||
uint current_brightness = int(round(id(display_light).current_values.is_on() ? (id(display_light).current_values.get_brightness() * 100.0f) : 0.0));
|
uint8_t current_brightness = int(round(display_light->current_values.is_on() ? (display_light->current_values.get_brightness() * 100.0f) : 0.0));
|
||||||
ESP_LOGV("output.display_output", "current_brightness: %i%%", current_brightness);
|
ESP_LOGV("output.display_output", "current_brightness: %i%%", current_brightness);
|
||||||
id(set_brightness).execute(current_brightness);
|
set_brightness->execute(current_brightness);
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# Updates the existing `page_changed` script to update the `display_light` status when a page changes
|
# Updates the existing `page_changed` script to update the `display_light` status when a page changes
|
||||||
- id: !extend page_changed
|
- id: !extend page_changed
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGV("script.page_changed(custom)", "page: %s", page.c_str());
|
ESP_LOGD("script.page_changed(custom)", "page: %s", page.c_str());
|
||||||
ESP_LOGV("script.page_changed(custom)", "is_on(): %i", id(display_light).current_values.is_on() ? 1 : 0);
|
ESP_LOGV("script.page_changed(custom)", "is_on(): %s", display_light->current_values.is_on() ? "True" : "False");
|
||||||
if (page == "screensaver" and id(display_light).current_values.is_on()) {
|
if (page == "screensaver" and display_light->current_values.is_on()) {
|
||||||
auto call = id(display_light).turn_off();
|
auto call = display_light->turn_off();
|
||||||
call.perform();
|
call.perform();
|
||||||
} else if (page != "screensaver" and (not id(display_light).current_values.is_on())) {
|
} else if (page != "screensaver" and (not display_light->current_values.is_on())) {
|
||||||
auto call = id(display_light).turn_on();
|
auto call = display_light->turn_on();
|
||||||
call.perform();
|
call.perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,15 +386,20 @@ script:
|
|||||||
- id: !extend set_brightness
|
- id: !extend set_brightness
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGD("script.set_brightness(custom)", "brightness: %i", brightness);
|
ESP_LOGD("script.set_brightness(custom)", "brightness: %i%%", brightness);
|
||||||
if (id(current_page).state != "screensaver" and brightness > 0) {
|
uint8_t current_brightness = int(round(display_light->current_values.is_on() ? (display_light->current_values.get_brightness() * 100.0f) : 0.0));
|
||||||
auto call = id(display_light).turn_on();
|
ESP_LOGV("script.set_brightness(custom)", "current_brightness: %i%%", current_brightness);
|
||||||
|
if (brightness != current_brightness) {
|
||||||
|
if (current_page->state != "screensaver" and brightness > 0) {
|
||||||
|
auto call = display_light->turn_on();
|
||||||
call.set_brightness(static_cast<float>(id(display_last_brightness)) / 100.0f);
|
call.set_brightness(static_cast<float>(id(display_last_brightness)) / 100.0f);
|
||||||
call.perform();
|
call.perform();
|
||||||
} else {
|
} else if (display_light->current_values.is_on()) {
|
||||||
auto call = id(display_light).turn_off();
|
auto call = display_light->turn_off();
|
||||||
|
call.set_brightness(0);
|
||||||
call.perform();
|
call.perform();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -465,8 +468,6 @@ time:
|
|||||||
|
|
||||||
|
|
||||||
### Framework `esp-idf`
|
### Framework `esp-idf`
|
||||||
> Requires v4.1 or higher
|
|
||||||
|
|
||||||
> When switching from `arduino` to `esp-idf`, make sure to update the device with a serial cable as the partition table is different between the two frameworks as [OTA Update Component](https://esphome.io/components/ota) updates will not change the partition table.
|
> When switching from `arduino` to `esp-idf`, make sure to update the device with a serial cable as the partition table is different between the two frameworks as [OTA Update Component](https://esphome.io/components/ota) updates will not change the partition table.
|
||||||
|
|
||||||
The `arduino` protocol still more popular and therefore more components are available, but as `esp-idf` is maintained by EspressIF and is kept updated, more boards are supported and the memory management is better, making it ideal if you wanna customize your panel to support memory consumption functionalities, like `bluetooth_proxy` or [Improv](https://www.improv-wifi.com/).
|
The `arduino` protocol still more popular and therefore more components are available, but as `esp-idf` is maintained by EspressIF and is kept updated, more boards are supported and the memory management is better, making it ideal if you wanna customize your panel to support memory consumption functionalities, like `bluetooth_proxy` or [Improv](https://www.improv-wifi.com/).
|
||||||
@@ -484,8 +485,6 @@ esp32:
|
|||||||
|
|
||||||
|
|
||||||
### Bluetooth proxy
|
### Bluetooth proxy
|
||||||
> Requires v4.1 or higher
|
|
||||||
|
|
||||||
> The [ESP32 Platform](#framework-esp-idf) component should be configured to use the `esp-idf` framework, as the `arduino` framework uses significantly more memory and performs poorly with the Bluetooth proxy enabled.
|
> The [ESP32 Platform](#framework-esp-idf) component should be configured to use the `esp-idf` framework, as the `arduino` framework uses significantly more memory and performs poorly with the Bluetooth proxy enabled.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user