### The problem
I bricked my NSPanel with OTA. Was able to reflash on it usin…g headers. I added back my code gradually.
I then found the breaking point. However, after playing with it for some time, I realized it didn't fail because of the thing itself, just too many things.
I added 10 dummy binary sensor: fails. Commented out 9/10 of those: works. (limit1 ... limit10)
When it got bricked, I couldn't ping it anymore. fully dead.
However, when I am exceeding the limit by a small bit only, mDNS stops working, Logs doesnt work either. Button trigger doesnt trigger. However, OTA/ping still works.
`RAM: [= ] 13.1% (used 42860 bytes from 327680 bytes)
Flash: [====== ] 63.9% (used 1172816 bytes from 1835008 bytes)`
I dont know what kind of buffer I am exceeding...
To be fair, there's 60 "platform:" in my yaml. Not very small...
I'll do my best to give additional information you require.
[https://imgur.com/a/tiwAAPR](https://imgur.com/a/tiwAAPR)
PS: Thanks for working on ESPHome. I hope one day I can contribute to it!
### Which version of ESPHome has the issue?
2022.3.1
### What type of installation are you using?
Home Assistant Add-on
### Which version of Home Assistant has the issue?
2022.3.8
### What platform are you using?
ESP32
### Board
NSPanel
### Component causing the issue
Nextion or generic
### Example YAML snippet
```yaml
# Set some variables for convenience
substitutions:
node_name: nspanel2
device_name: NSPanel
# Note: this may not be needed if the pull request has been merged.
# Check https://github.com/esphome/esphome/pull/2956 for current status.
external_components:
- source: github://pr#2956
components: [nextion]
refresh: 1h
esphome:
name: $node_name
comment: $device_name
esp32:
board: esp32dev
wifi: !secret wifi_settings
# Enable logging
logger:
# Enable wireless updates
ota:
time:
- platform: sntp
id: sntp_time
on_time:
# Every 5 minutes
- minutes: /1
then:
- lambda: |-
auto time_text = id(sntp_time).now().strftime("%H:%M");
auto date_text = id(sntp_time).now().strftime("%d %B");
id(disp1).set_component_text("time", time_text.c_str());
id(disp1).set_component_text("date", date_text.c_str());
# Enable Home Assistant API
api:
services:
# Service to play a song
- service: play_rtttl
variables:
song_str: string
then:
- rtttl.play:
rtttl: !lambda 'return song_str;'
# https://corax89.github.io/esp8266Game/soundEditor.html
- service: rtttl_up
then:
- rtttl.play:
rtttl: "s:d=4,o=5,b=400:d,g"
- service: rtttl_down
then:
- rtttl.play:
rtttl: "s:d=4,o=5,b=400:g,d"
- service: rtttl_n
then:
- rtttl.play:
rtttl: "s:d=4,o=5,b=400:d,a,a,a,a,d"
- service: rtttl_u
variables:
song_str: string
then:
- rtttl.play:
rtttl: "s:d=4,o=5,b=400:a,d,d,d,d,a,p,a"
- service: goto_page
variables:
page_str: string
then:
- lambda: 'id(disp1)->goto_page(page_str.c_str());'
- service: upload_tft
then:
- lambda: 'id(disp1)->upload_tft();'
- service: set_int
variables:
name_str: string
value_int: int
then:
- lambda: 'id(disp1).set_component_value (name_str.c_str(), value_int);'
- service: set_text
variables:
name_str: string
value_str: string
then:
- lambda: 'id(disp1).set_component_text(name_str.c_str(), value_str.c_str());'
- service: set_pos
variables:
name_str: string
xx: int
yy: int
then:
- lambda: 'id(disp1).set_component_coordinates(name_str.c_str(), xx,yy);'
- service: poll
then:
- lambda: 'id(disp1).update();'
# A reboot button is always useful
button:
- platform: restart
name: Restart $device_name
text_sensor:
- name: hass_light
id: hass_light
platform: template
#Dist {{ sqrt(int("150")**2+int("0")**2)/150*100 }}
#right is blue-purpleish {{ ((atan2(150-150,200-150)/3.14159*180)+270)%360 }}
#left is greenish {{ ((atan2(150-150,50-150)/3.14159*180)+270)%360 }}
#down is red {{ ((atan2(200-150,150-150)/3.14159*180)+270)%360 }}
#up is cyan {{ ((atan2(50-150,150-150)/3.14159*180)+270)%360 }}
#upleft is greencyan {{ ((atan2(50-150,50-150)/3.14159*180)+270)%360 }}
#upright is cyanblue {{ ((atan2(50-150,200-150)/3.14159*180)+270)%360 }}
#downleft is yellow {{ ((atan2(200-150,50-150)/3.14159*180)+270)%360 }}
#downright is magenta {{ ((atan2(200-150,200-150)/3.14159*180)+270)%360 }}
#Then, plug these into light.turn_on hue-sat color, where hue is angle and sat is dist
# Define some inputs
binary_sensor:
- platform: gpio
name: $device_name Left Button
pin:
number: 14
inverted: true
#https://community.home-assistant.io/t/esphome-buttons/158390/10
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- logger.log: "Double Clicked"
- homeassistant.service:
service: light.turn_on
data:
color_temp: "367"
brightness_pct: "100"
entity_id: "light.bedroom_lights"
- timing:
- ON for 1s to 2s
- OFF for at least 0.5s
then:
- logger.log: "Single Long Clicked"
- homeassistant.service:
service: light.turn_on
data:
effect: "Party"
entity_id: "light.bedroom_lights"
- timing:
- ON for at least 2.2s
then:
- logger.log: "Click and Hold"
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- logger.log: "Single Short Clicked"
- homeassistant.service:
service: light.toggle
data:
entity_id: "light.bedroom_lights"
- platform: gpio
name: $device_name Right Button
pin:
number: 27
inverted: true
#https://community.home-assistant.io/t/esphome-buttons/158390/10
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- logger.log: "Double Clicked"
- timing:
- ON for 1s to 2s
- OFF for at least 0.5s
then:
- logger.log: "Single Long Clicked"
- timing:
- ON for at least 2.2s
then:
- logger.log: "Click and Hold"
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- logger.log: "Single Short Clicked"
#pArming
- platform: nextion
name: $device_name Cancel Arming Btn
page_id: 2
component_id: 3
on_press:
then:
- homeassistant.service:
service: script.alarm_lock_cancel_arming
#pScreensaver
# pMain
- platform: nextion
name: $device_name WTF Btn
page_id: 4
component_id: 4
on_press:
then:
- homeassistant.service:
service: script.alarm_lock_home
- platform: nextion
name: $device_name Sleep Btn
page_id: 4
component_id: 3
on_press :
then:
- homeassistant.service:
service: script.gasleep
# pMusic
- platform: nextion
name: $device_name PlayPause Btn
page_id: 5
component_id: 1
on_press :
then:
- homeassistant.service:
service: script.spotify_playpause
- platform: nextion
name: $device_name VolMinus
page_id: 5
component_id: 5
on_press :
then:
- homeassistant.service:
service: script.spotify_volminus
- platform: nextion
name: $device_name VolPlus
page_id: 5
component_id: 6
on_press :
then:
- homeassistant.service:
service: script.spotify_volplus
#pMusicMove
- platform: nextion
name: $device_name Move Music To Bed
page_id: 6
component_id: 1
on_press :
then:
- homeassistant.service:
service: script.move_spotify_bed
- platform: nextion
name: $device_name Move Music To TV
page_id: 6
component_id: 4
on_press :
then:
- homeassistant.service:
service: script.move_spotify_couch
- platform: nextion
name: $device_name Move Music To Kitchen
page_id: 6
component_id: 5
on_press :
then:
- homeassistant.service:
service: script.move_spotify_kitchen
- platform: nextion
name: $device_name Move Music To TVKitchen
page_id: 6
component_id: 3
on_press :
then:
- homeassistant.service:
service: script.move_spotify_tv_kitchen
- platform: nextion
name: $device_name Move Music To All
page_id: 6
component_id: 7
on_press :
then:
- homeassistant.service:
service: script.move_spotify_all
#pMusicSelect
- platform: nextion
name: $device_name Music Select Liked
page_id: 7
component_id: 1
on_press :
then:
- homeassistant.service:
service: script.spotifystart_liked
- platform: nextion
name: $device_name Music Select Sad
page_id: 7
component_id: 2
on_press :
then:
- homeassistant.service:
service: script.spotifystart_sad
- platform: nextion
name: $device_name Music Select HallOfFame
page_id: 7
component_id: 4
on_press :
then:
- homeassistant.service:
service: script.spotifystart_hof
- platform: nextion
name: $device_name Music Select SoulStitching
page_id: 7
component_id: 3
on_press :
then:
- homeassistant.service:
service: script.spotifystart_soulstitching
- platform: nextion
name: $device_name Music Select Morning
page_id: 7
component_id: 5
on_press :
then:
- homeassistant.service:
service: script.spotifystart_morning
#pLightSelect
- platform: nextion
name: $device_name Light Select Bedroom
page_id: 8
component_id: 1
on_press :
then:
- lambda: |-
id(hass_light).state = "light.bedroom_lights";
- platform: nextion
name: $device_name Light Select Kitchen
page_id: 8
component_id: 2
on_press :
then:
- lambda: |-
id(hass_light).state = "light.kitchen_lights";
- platform: nextion
name: $device_name Light Select Hallway
page_id: 8
component_id: 4
on_press :
then:
- lambda: |-
id(hass_light).state = "light.hallway_lights";
- platform: nextion
name: $device_name Light Select TV
page_id: 8
component_id: 3
on_press :
then:
- lambda: |-
id(hass_light).state = "light.tv_lights";
- platform: nextion
name: $device_name Light Select PC
page_id: 8
component_id: 5
on_press :
then:
- lambda: |-
id(hass_light).state = "light.pc_lights";
- platform: nextion
name: $device_name Light Select All
page_id: 8
component_id: 8
on_press :
then:
- lambda: |-
id(hass_light).state = "all";
#pLight
- platform: nextion
name: $device_name Light Off
page_id: 9
component_id: 2
on_press :
then:
- homeassistant.service:
service: light.turn_off
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Light 2700k
page_id: 9
component_id: 1
on_press :
then:
- homeassistant.service:
service: script.lightresetcolor
data_template:
entity_id2: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
#pLightColor
# - platform: nextion
# name: $device_name limit1
# page_id: 10
# component_id: 1
#
# - platform: nextion
# name: $device_name limit2
# page_id: 10
# component_id: 2
#
# - platform: nextion
# name: $device_name limit3
# page_id: 10
# component_id: 3
#
# - platform: nextion
# name: $device_name limit4
# page_id: 10
# component_id: 4
# - platform: nextion
# name: $device_name limit5
# page_id: 10
# component_id: 5
# - platform: nextion
# name: $device_name limit6
# page_id: 10
# component_id: 6
# - platform: nextion
# name: $device_name limit7
# page_id: 10
# component_id: 7
# - platform: nextion
# name: $device_name limit8
# page_id: 10
# component_id: 8
# - platform: nextion
# name: $device_name limit9
# page_id: 10
# component_id: 9
# - platform: nextion
# name: $device_name limit10
# page_id: 10
# component_id: 10
#pLightDim
- platform: nextion
name: $device_name Dim 100%
page_id: 11
component_id: 2
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
brightness_pct: "100"
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Dim 75%
page_id: 11
component_id: 3
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
brightness_pct: "75"
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Dim 40%
page_id: 11
component_id: 6
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
brightness_pct: "40"
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Dim 10%
page_id: 11
component_id: 8
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
brightness_pct: "10"
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
#pLightEffect
- platform: nextion
name: $device_name Effect Party
page_id: 12
component_id: 1
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
effect: Party
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Effect Wakeup
page_id: 12
component_id: 2
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
effect: Wake up
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Effect Candle
page_id: 12
component_id: 4
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
effect: Candlelight
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Effect Pastel
page_id: 12
component_id: 3
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
effect: Pastel Colors
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Effect Love
page_id: 12
component_id: 5
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
effect: Romance
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
- platform: nextion
name: $device_name Effect Redeye
page_id: 12
component_id: 6
on_press :
then:
- homeassistant.service:
service: light.turn_on
data:
effect: Relax
data_template:
entity_id: "{{ my_variable }}"
variables:
my_variable: |-
return id(hass_light).state;
sensor:
# Light slider
- platform: wifi_signal
name: $device_name WiFi Signal
update_interval: 60s
- platform: ntc
id: temperature
sensor: resistance_sensor
calibration:
b_constant: 3950
reference_temperature: 25°C
reference_resistance: 10kOhm
name: $device_name Temperature
- platform: resistance
id: resistance_sensor
sensor: ntc_source
configuration: DOWNSTREAM
resistor: 11.2kOhm
- platform: adc
id: ntc_source
pin: 38
update_interval: 10s
attenuation: 11db
- platform: nextion
id: "targetlight"
variable_name: "targetlight"
# Define some outputs
switch:
# The two relays
#- platform: gpio
# name: $device_name Relay 1
# id: relay_1
# pin:
# number: 22
#- platform: gpio
# name: $device_name Relay 2
# id: relay_2
# pin:
# number: 19
# Pin 4 always needs to be on to power up the display
- platform: gpio
id: screen_power
entity_category: config
pin:
number: 4
inverted: true
restore_mode: ALWAYS_ON
number:
- platform: template
name: $device_name Brightness
id: brightness
entity_category: config
unit_of_measurement: '%'
min_value: 0
max_value: 100
step: 1
initial_value: 30
set_action:
then:
- lambda: 'id(disp1).set_backlight_brightness(x/100);'
# Configure the internal bleeper
output:
- platform: ledc
id: buzzer_out
pin:
number: 21
# Enable ringtone music support
rtttl:
id: buzzer
output: buzzer_out
# Configure UART for communicating with the screen
uart:
id: tf_uart
tx_pin: 16
rx_pin: 17
baud_rate: 115200
# Configure the screen itself
display:
- platform: nextion
id: disp1
uart_id: tf_uart
tft_url: http://192.168.11.254:8123/local/tft/hmi_jf.tft
# A little fun...
on_setup:
then:
- number.set:
id: brightness
value: 30
# - lambda: |-
# id(disp1).set_component_text_printf(
# "temp", "%.1f ""\xb0""F", id(current_temperature).state
# );
# - rtttl.play: "twobits:d=4,o=5,b=220:c6,8g,8g,a,g,p,b,c6"
```
### Anything in the logs that might be useful for us?
```txt
Logs doesn't work :(
```
### Additional information
_No response_