mirror of
https://github.com/esphome/esphome.git
synced 2026-05-23 11:16:52 +08:00
ee7b38504b
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@home-assistant.io>
337 lines
8.6 KiB
YAML
337 lines
8.6 KiB
YAML
esphome:
|
|
on_boot:
|
|
- lambda: 'ESP_LOGD("display","is_connected(): %s", YESNO(id(main_lcd).is_connected()));'
|
|
|
|
- display.nextion.set_brightness: 80%
|
|
|
|
# Binary sensor publish action tests
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: True
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: True
|
|
publish_state: True
|
|
send_to_nextion: True
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: True
|
|
publish_state: False
|
|
send_to_nextion: True
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: True
|
|
publish_state: True
|
|
send_to_nextion: False
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: True
|
|
publish_state: False
|
|
send_to_nextion: False
|
|
|
|
# Templated
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: !lambda 'return true;'
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
- binary_sensor.nextion.publish:
|
|
id: r0_sensor
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
# Sensor publish action tests
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: 42.0
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: 42.0
|
|
publish_state: True
|
|
send_to_nextion: True
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: 42.0
|
|
publish_state: False
|
|
send_to_nextion: True
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: 42.0
|
|
publish_state: True
|
|
send_to_nextion: False
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: 42.0
|
|
publish_state: False
|
|
send_to_nextion: False
|
|
|
|
# Templated
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: !lambda 'return 42.0;'
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: !lambda 'return 42.0;'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: !lambda 'return 42.0;'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: !lambda 'return 42.0;'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
- sensor.nextion.publish:
|
|
id: testnumber
|
|
state: !lambda 'return 42.0;'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
# Switch publish action tests
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: True
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: True
|
|
publish_state: true
|
|
send_to_nextion: true
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: True
|
|
publish_state: false
|
|
send_to_nextion: true
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: True
|
|
publish_state: true
|
|
send_to_nextion: false
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: True
|
|
publish_state: false
|
|
send_to_nextion: false
|
|
|
|
# Templated
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: !lambda 'return true;'
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
- switch.nextion.publish:
|
|
id: r0
|
|
state: !lambda 'return true;'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
# Test sensor publish action tests
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: 'Test'
|
|
publish_state: true
|
|
send_to_nextion: true
|
|
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: 'Test'
|
|
publish_state: false
|
|
send_to_nextion: true
|
|
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: 'Test'
|
|
publish_state: true
|
|
send_to_nextion: false
|
|
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: 'Test'
|
|
publish_state: false
|
|
send_to_nextion: false
|
|
|
|
# Templated
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: !lambda 'return "Test";'
|
|
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: !lambda 'return "Test";'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: !lambda 'return "Test";'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return true;'
|
|
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: !lambda 'return "Test";'
|
|
publish_state: !lambda 'return true;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
- text_sensor.nextion.publish:
|
|
id: text0
|
|
state: !lambda 'return "Test";'
|
|
publish_state: !lambda 'return false;'
|
|
send_to_nextion: !lambda 'return false;'
|
|
|
|
wifi:
|
|
ssid: MySSID
|
|
password: password1
|
|
|
|
binary_sensor:
|
|
- platform: nextion
|
|
page_id: 0
|
|
component_id: 2
|
|
name: Nextion Touch Component
|
|
- platform: nextion
|
|
id: r0_sensor
|
|
name: R0 Sensor
|
|
component_name: page0.r0
|
|
|
|
sensor:
|
|
- platform: nextion
|
|
id: testnumber
|
|
name: testnumber
|
|
variable_name: testnumber
|
|
- platform: nextion
|
|
id: testwave
|
|
name: testwave
|
|
component_id: 2
|
|
wave_channel_id: 1
|
|
|
|
switch:
|
|
- platform: nextion
|
|
id: r0
|
|
name: R0 Switch
|
|
component_name: page0.r0
|
|
|
|
text_sensor:
|
|
- platform: nextion
|
|
name: text0
|
|
id: text0
|
|
update_interval: 4s
|
|
component_name: text0
|
|
|
|
display:
|
|
- platform: nextion
|
|
id: main_lcd
|
|
auto_wake_on_touch: true
|
|
brightness: 80%
|
|
command_spacing: 5ms
|
|
dump_device_info: true
|
|
exit_reparse_on_start: true
|
|
lambda: |-
|
|
ESP_LOGD("display","Display is being tested!");
|
|
max_commands_per_loop: 20
|
|
max_queue_age: 5000ms # Remove queue items after 5s
|
|
max_queue_size: 50
|
|
on_buffer_overflow:
|
|
then:
|
|
logger.log: "Nextion reported a buffer overflow!"
|
|
on_custom_text_sensor:
|
|
then:
|
|
- lambda: |-
|
|
// key: StringRef, value: StringRef
|
|
if (key == "csv") {
|
|
// parse value here, or forward to your own component
|
|
ESP_LOGD("nextion.csv", "Got CSV: %s", value.c_str());
|
|
}
|
|
on_custom_sensor:
|
|
then:
|
|
- lambda: |-
|
|
// key: StringRef, value: int32_t
|
|
if (key == "temperature_raw") {
|
|
ESP_LOGD("nextion.custom", "%s=%d", key.c_str(), value);
|
|
}
|
|
on_custom_binary_sensor:
|
|
then:
|
|
- lambda: |-
|
|
if (key == "btn1") {
|
|
ESP_LOGD("nextion.btn", "btn1=%s", ONOFF(value));
|
|
}
|
|
on_custom_switch:
|
|
then:
|
|
- lambda: |-
|
|
ESP_LOGD("nextion.sw", "%s=%s", key.c_str(), ONOFF(value));
|
|
on_page:
|
|
then:
|
|
lambda: 'ESP_LOGD("display","Display shows new page %u", x);'
|
|
on_setup:
|
|
then:
|
|
lambda: 'ESP_LOGD("display","Display setup completed");'
|
|
on_sleep:
|
|
then:
|
|
lambda: 'ESP_LOGD("display","Display went to sleep");'
|
|
on_touch:
|
|
then:
|
|
lambda: |-
|
|
ESP_LOGD("display",
|
|
"Display was touched at page %u, component %u, touch event: %s",
|
|
page_id, component_id, touch_event ? "press" : "release");
|
|
on_wake:
|
|
then:
|
|
lambda: 'ESP_LOGD("display","Display woke up");'
|
|
start_up_page: 1
|
|
startup_override_ms: 10000ms # Wait 10s for display ready
|
|
touch_sleep_timeout: 3
|
|
update_interval: 5s
|
|
wake_up_page: 2
|