esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

section `.iram0.text' will not fit in region `iram0_0_seg' #5906

Open tiimsvk opened 3 weeks ago

tiimsvk commented 3 weeks ago

The problem

Hello After updating openweathermap api 3.0 where there was a request for payments for integration, I decided to switch to another weather integration. Also on the basis of changing the reading of attributes from the weather entity in HA.

That's why I had to update the firmware on esp.

When updating at the very end, however, it throws me an error:

Linking .pioenvs/energy-elektromer/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/energy-elektromer/firmware.elf section `.iram0.text' will not fit in region `iram0_0_seg'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: IRAM0 segment data does not fit.
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: region `iram0_0_seg' overflowed by 408 bytes
collect2: error: ld returned 1 exit status
*** [.pioenvs/energy-elektromer/firmware.elf] Error 1

After some attempts, I discovered that if I remove the ble tracker, the update will take place without any problems. (I'm just reminding you that last year's version worked at that time)

Can you advise how to proceed?

Yaml:

Which version of ESPHome has the issue?

2024.5.5

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.6.2

What platform are you using?

ESP32-IDF

Board

esp32-dev

Component causing the issue

No response

Example YAML snippet

#-------------------------------------------
# BUG AND REPAIR AND PLANNED
#-------------------------------------------

#-------------------------------------------
# REVISION
#-------------------------------------------
# 2023.06.04.0.0
# 2023.08.04.2.1 - Replace broken pir AM312 to SR602
#                - Add 433MHz signal receiver and RTTTL piezo buzzer speaker for Doorbell
# 2023.08.04.2.2 - Set low LDR out
# 2023.08.04.2.3 - Set timeupdate 15s ldr interval

#-------------------------------------------
# SUBTITUTIONS
# basic definitions and description of the device
#-------------------------------------------
substitutions:
  device_name: energy-elektromer
  friendly_name: Energy-Elektromer
  created_by: StudioTiiM 2022-2024
  device_description: "Measure your energy consumption with the pulse LED on your smart meter and measure temperature, light, humidity, motion + control 2 led CW WW + Receiver doorbell signal and play song"

#-------------------------------------------
# POWER CONSUMPTION - whit multimeter
#-------------------------------------------
# Power consumption 12.0V
# First booting MCU:
# Booting MCU after connected to mqtt:

#-------------------------------------------
# DEFINE PINS AND VARIABILES
# CIRCUIT AND MODULES - basic definitions and description of the device
#-------------------------------------------

 # ----- MCU -----
  # Module: ESP32-S + adapter
   # Circuit: Solder on Prototype PCB expansion board ESP32 7x9cm

   # Power Consumption: Peak ~  / Normal wifi:  ~  / Normal: ~  / DeepSleep: ~ 
   # Specification: Chip Family: ESP32 / Chip Model: ESP32S / Chip ID:  / MAC Address:  / Number of Cores:  / CPU Frequency: 240MHz / Ram:  / Flash: 

   # Description pins:
   # Description pins:
    # PINS ESP32    | FUNCTION     | INPUT | OUTPUT | ADC | PWM | I2C           | SPI  | RESISTOR             | BOOT       | FLASH   | HIGH AT BOOT | BOOT FAILS | NOTES
    # -------------------------------------------------------------------------------------------------------------------------------------------------------------
    # EN     *      | RESET                                                            | 10.0k PULLUP PCB     |                                     |
    # GPIO0         | STRAPPING    | OK!   | OK!    |     | OK  | OK            |      | 10.0k PULLUP         | PULLUP    | PULLDOWN | PWM          | LOW
    # GPIO01 *      | TX           | OK!*1 | OK     |     | OK  | OK            |      |                      |           |          | HIGH         | 
    # GPIO02 *      | STATUS LED   | OK    | OK     |     | OK  | OK            |      | INTERNAL PULLDOWN    | PULLUP    |          | HIGH         |            | LED OR PULLUP 10k
    # GPIO03 *      | RX           | OK    | OK!*1  |     | OK  | OK            |      |                      |           |          | HIGH         |
    # GPIO04 *      |              | OK    | OK     |     | OK  | OK            |      | INTERNAL PULLDOWN    |           |          |              |
    # GPIO05        | STRAPPING    | OK    | OK!    |     | OK  | OK            |      | INTERNAL PULLUP      |           |          | PWM          | LOW
    # GPIO06        | INTERNAL SPI |       |        |     |     |               | CLK  |                      |           |          |              |
    # GPIO07        | INTERNAL SPI |       |        |     |     |               | MISO |                      |           |          |              |
    # GPIO08        | INTERNAL SPI |       |        |     |     |               | MOSI |                      |           |          |              |
    # GPIO09        | INTERNAL SPI |       |        |     |     |               | HD   |                      |           |          | HIGH         |
    # GPIO10        | INTERNAL SPI |       |        |     |     |               | WP   |                      |           |          | HIGH         |
    # GPIO11        | SPI CSC/CMD  |       |        |     |     |               | CS   |                      |           |          | HIGH         |
    # GPIO12 *      | STRAPPING    | OK!*3 | OK     |     | OK  | OK            |      |                      |           |          | LOW          | HIGH
    # GPIO13 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO14 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          | PWM          |
    # GPIO15        | STRAPPING    | OK!   | OK!    |     | OK  | OK            |      |                      | PULLDOWN  |          | PWM          | HIGH
    # GPIO16 *      | PSRAM*4      | OK    | OK     |     | OK  | OK            |      |                      |           |          | PWM          |
    # GPIO17 *      | PSRAM*4      | OK    | OK     |     | OK  | OK            |      |                      |           |          | PWM          |
    # GPIO18 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO19 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO21 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO22 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO23 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO25 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO26 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO27 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO32 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO33 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO34 *      |              | OK    |        | OK  |     |               |      |                      |           |          |              |
    # GPIO35 *      |              | OK    |        | OK  |     |               |      |                      |           |          |              |
    # GPIO36 *      | VP           | OK*5  |        | OK  |     |               |      |                      |           |          |              |
    # GPIO39        | VN           | OK*5  |        | OK  |     |               |      |                      |           |          |              |

    # * Connected on this project
    # *1 Disable hardware uart. logger baud_rate: 0
    # *2 recommended I2C
    # *3 May damage flash if low at boot on 1.8V flash chips
    # *4 GPIO 16 & 17 are usually connected to the SPI flash and PSRAM. These do show some activity during boot to detect the presence of PSRAM. For example GPIO 17 may still show some high frequency signal until it is specifically set to a high or low output state. When PSRAM is present, these pins should not be used.
    # *5 GPIO 36 & 39 should not be used for interrupts when also using ADC or WiFi and Bluetooth. These pins are on some boards labelled as: 
    #    The internal Hall sensor in the ESP32 is connected to these two pins.
    #    The Hall Sensor uses channels 0 and 3 of ADC1. Do not configure these channels for use as ADC channels when also reading from the Hall sensor.
    # *6 
    # GPIO08 and GPIO09 pulldown invalid on boot
    # Current draw 12mA max per GPIO
    # * used on project

# ----- ELECTRICITY -----
 # ----- POWER SUPPLY -----
  # Module: connected to UPS 12.0V

 # ----- LDO -----
  # Module1: 78L05 Positive voltage regulator SOT-89
   # Specification: Voltage in 7 ~ 20V out fixed 5.0V 2% / current max 0.1A / 
   # Protection: overtemperature / thermal overload protection
   # Power consumption: Quiescent current 3mA
   # Circuit: VIN -> ceramic 33μF -> GND / VOUT -> 10μF -> GND

  # Module2: Holtek HT7833 SOT-92
   # Specification: Voltage in 0 ~ 8V out fixed 3.3V 2% / max voltage drop 360mV / current max 0.5A / 
   # Protection: overtemperature / current limiting
   # Power consumption: Quiescent current 4µA
   # Circuit: VIN -> 2x ceramic 10μF -> GND / VOUT -> PPTC FUSE 0.5A 6V (marking 5) -> VOUT / VOUT -> 220μF 16.0V -> GND

 # ----- STEP UP MODULE -----
  # Module: Step up module MT3608 internal integration of very low RDS internal resistance 100mΩ metal oxide semiconductor field effect crystal (MOSFET) can achieve high current output up to 2A.
   # Chip: marking B628
   # Specification: Voltage in 2.0 ~ 24.0V out 2.0 ~ 28.0V / current max 2.0A / Switching frequency: 1.2MHz / Oscillation frequency 1.2MHz / efficiency 95%
   # Protection: short-circuit protection, overheat protection
   # Power consumption: quiscent: 0.55mA

 # ----- LEDS -----
  # Modul: Status and power led
   # Specification: red led 3mm
    # Circuit: 1KΩ resistor
    # Power consumption: 330µA
  status_pin: GPIO02

  # Modul: Consumption led
   # Specification: red led 3mm
    # Circuit: to gpio pin measure
    # Power consumption: 300µA

 # ----- POWER ELECTRICITY CONSUMPTION SENSORS -----
  # Module: MH Sensor series module: Photodiode whit LM393 comparator
   # Specification: adjustable digital potentiometer 103 / working voltage: 3.3 ~ 5.0V / Output current D0 15mA / PCB size: 3.2 cm * 1.4 cm
   # Modifiation: reverse solder photodiode fix

  # Measure electricty:
   # imp/kWh rate
  pulse_rate: "1000"
   # Max power filter
   # 25A Circuitbreaker 
  max_power_filter: "6000" # 25A * 240V = 6000W
  pulse_pin: GPIO34

 # ----- TEMPERATURE / HUMIDITY SENSOR -----
  # Module: DHT11
   # Specifications: Voltage: 3.3 ~ 5.5V / Operational Range: Temperature: 0 ~ +50°C Humidity: 0~90% / Resolution: Humidity: 1%RH, Temperature 1°C / Accuracy: Temperature: +-1°C Humidity: +-5% / Sample period: 1s
   # Circuit: Interface: one wire SDA
   # Power consumption: Measuring: 2.5 ~ 0.5mA / Average: 0.2 ~ 1.0mA / Standby 0.15mA / whit multimeter μA
   # Measure after enable min. 6s
  dht_pin: GPIO04

 # ----- LED LIGHT -----
  # Module: 2x Xiaomi Philips Zhirui CCT Downlight 
   # Specification: Lumens: 200lm / Kelvin: 3000k ~ 5700k / Leds: 6x WW, 6x CW / Voltage: 12V 0.2W per led connected in series 16 ~ 19V
   # Power consumption: 19V 36mA per led / 16V 120mA
   # Modification: unconnected power module only leds modules
   # Circuit: GPIO -> 1kΩ -> Gate (Logic mosfet 30N06L N - channal) / Gate -> 100kΩ -> Source / Source -> GND / Drain -> Leds / 12VCC -> StepUp module -> 16.0V -> VCC Led
  ww_led_pin: GPIO12
  cw_led_pin: GPIO14

 # ----- ROTATORY ENCODER -----
  # Module: Incremental encoder THT PEC11R-4220F-S0012
   # Specification: Encoder: incremental / THT / 12imp/revol / Pos: 24 / two phase A and B / Mechanical durability: 30000 cycles / Operating voltage:   5V DC / Max. operating current: 10mA / perating temperature:    -30 ~ + 70°C
  rotary_button: GPIO16
  rotary_a: GPIO17
  rotary_b: GPIO18

 # ----- SOLID STATE RELAY -----
  # Module: 1 Channel Solid State Relay Module SSR G3MB-202P
   # Specification: Low Level trigger / voltage: 5V / Channal 1 / Voltage relay: 240V 2A Output 
   # Protection: 2A Resistive Fuse
   # Power consumption: 10mA 5.0V
  relay_pin: GPIO19

 # ----- DISPLAY -----
  # Module: Waveshare 1.54" 200x200 ePaper displej modul BW
   # Specifications: Voltage: 2.2 ~ 3.7V / Color: black/white / full refresh time 4s / view angle >170° / Size 1.54 inch, 200x200px 188dpi 27x27mm
   # Power consumption: standby 2.0uA / refresh 1.5mA
   # Circuit: Interface: SPI 4wire
   # Feature: Partial refresh
  eink_en_pin: GPIO25
  eink_cs_pin: GPIO26
  eink_dc_pin: GPIO27
  eink_busy_pin: GPIO32

 # ----- REED SWITCH -----
  # Module: Reed magnetic switch induction 
  # Specification:  Dimension: 2x14MM / open magnetic induction switch glass white / inert gas are sealed in the glass tube and are not affected by the external atmosphere / Material: glass + conductive metal needle
  reed_pin: GPIO33

 # ----- PIR -----
  # Old Module: Pir sensor SB312/AM312
   # Specifications: Voltage: 2.7 ~ 12V / Delay time: 2s / Block time: 2s / / retrigger mode: repeatable / Sense: degree < 90° lengh: < 3m / Working temperature -20 ~ 60 °C
   # Chip: Pir: AS312 (Digital high / max 3.6V / max 100mA / No Sensitivity) / LDO: HT7533
   # Pinout Pir Bottom view:
    # 
    #            /
    #   * GND  * VCC
    #
    #       * OUT
    # 
   # Circuit: VCC, GND, Vout to GPIO
   # Power consumption: standby: 9uA / detected: 15uA

  # Module: Pir sensor SR602
   # Specifications: Voltage: 2.7 ~ 15V / Block time: 2s / retrigger mode: repeatable / Sense: degree < 90° lengh: < 3.5m / Working temperature -20 ~ 60 °C
   # Chip: Pir:  (Digital high / 6 pins) / LDO: HT7533
   # Pinout Pir Bottom view:
    # 
    #            /
    #   * OEN  * VDD
    #  * TIME   * VOUT
    #   * SENS * GND
    #
    # OEN: DARK ADJUST
    # TIME: DELAY TIME ADJUST
    # SENS: SENSITIVITY ADJUST
    #
   # Feature:
    # Sensitivity adjust resistor ( top on the left side LDO)
    # Photodiode (not LDR)
    # Delay time adjust resitor (bottom left side big capacitor)
     # Programtable delay time:
      # RL (kΩ) | Time (s)
      # ------------------
      # 0       | 2.5
      # 22      | 5
      # 39      | 8 (installed)
      # 56      | 11
      # 75      | 19
      # 91      | 35
      # 120     | 56
      # 130     | 67
      # 154     | 130
      # 174     | 265
      # 196     | 390
      # 221     | 522
      # 243     | 1050
      # 267     | 2095
      # 294     | 3150
      # 360M    | 4200
   # Circuit: +, -, Vout to GPIO
   # Power consumption: 20uA
  pir_sensor: GPIO35
  delay_time: 30s
   # Circuit: 33k

 # ----- AMBIENT LIGHT SENSOR -----
  # Module: GL5516 5-10k sensitivity
   # Circuit: VCC -> LDR -> GPIO -> 103 trimmer -> GND
  ldr_pin: GPIO36

 # ----- DOORBELL -----
  # Module: Piezo active buzzer SFM-20B 
   # Specification: Voltage: max. 3 ~ 24 V / Dimension: 22 / 10 mm / Volume 95dB / Current 10mA / Frequency: 3.9kHz
   # Circuit: 
    # - GPIO -> 1kΩ -> Base NPN S8050
    # - GND -> Collector NPN S8050
    # - Emitter NPN S8050 -> Trimmer 203 (volume control) -> pin 2 Inductor 10Ω -> pin1 Inductor -> piezo + 
    # - Piezo - -> pin3 140Ω to pin 2
    # - VCC -> Emitter PNP S8550
    # - Base PNP S8550 -> 220Ω -> Emitter NPN S8050
    # - Collectror PNP S8550 -> Inductor pin1
  piezo_pin: GPIO01 #TX

   # Module: 433MHz receiver SRX882S V2.0
    # Sepcification: Frequency: 433/315 MHz / Voltage: 2.4 ~ 5.5V / Working temperature: -30 ~ 80 °C / Receiving sensitivity: -110dBm
    # Antenna:
      # ANT1: Nickel Plated Spring Antenna (Wire diameter 0.8mm / Height 32mm)
      # ANT2:
       # Create: Tutorial: https://www.instructables.com/433-MHz-Coil-loaded-antenna/ PDF: https://drive.google.com/file/d/1E9KPAPJrZRgGLOQqwd2-3-Px0MuSVreY/view
        # 1. 0.6mm wire wrapped around a 2.5mm core.
        # 2. length of 25 cm wire 
        # 3. Start 17 mm long. 
        # 4. 16 turns over a 2.5 mm diameter core 
    # Circuit: ANT (two antenna connected) / CS pin (1 normal/ 0 Sleep) 470Ω -> VCC / Data -> GPIO
    # Power consumption: Standby: 0.1uA / Receiver: 3.2mA
  remote_pin: GPIO03 #RX

 # ----- IMPORTED SENSORS -----
  # WHEATER
  weather_temp:            sensor.weather_station_temperature
  weather_uv:              sensor.weather_station_uv_index
  weather_wind:            sensor.weather_station_wind_speed
  #weather_condition:       weather.zelenydom
  weather_condition:       sensor.weather_forecast
  forecast:                sensor.weather_forecast_present_day
  forecast_temp:           sensor.weather_forecast_max_temperature
  forecast_templow:        sensor.weather_forecast_min_temperature
  # ELECTRICITY
  el_consumption:          sensor.electricity_consumption_daily

#-------------------------------------------
# PROTOCOLS
#-------------------------------------------
 # ----- PROTOCOLS PINS -----
  # SPI
  spi_clk_pin: GPIO21
  spi_mosi_pin: GPIO13

  # I2C
  i2c_sda_pin: GPIO22
  i2c_scl_pin: GPIO23

 # ----- PROTOCOLS SETTINGS -----
# i2c:
#  sda: "$i2c_sda_pin"
  #scl: "$i2c_scl_pin"
 #  scan: true

spi:
  clk_pin: "$spi_clk_pin"
  mosi_pin: "$spi_mosi_pin"

#-------------------------------------------
# ESP main settings
#-------------------------------------------
esphome:
  name: energy-elektromer
  project:
    name: "studiotiim.elektromer"
    version: 2024.6.04.2.5
  on_boot:
    priority: 300.0
    then:
      #- logger.log: "---boot light on---"
      - light.turn_on:
          id: downlight
          brightness: 80%
          cold_white: 100%
          warm_white: 100%
      - delay: 20s
      - wait_until:
          binary_sensor.is_off: motion
      #- logger.log: "---boot light off motion off---"
      - light.turn_off: downlight
      - binary_sensor.template.publish:
          id: script_enable
          state: true

esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf

# Enable Home Assistant API
api:
  reboot_timeout: 60min
  services:
    - service: play_rtttl
      variables:
        song_str: string
      then:
        - rtttl.play:
            rtttl: !lambda 'return song_str;'
ota:
  #platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.31.243
    gateway: 192.168.31.1
    subnet: 255.255.255.0
  ap:
    ssid: "$device_name Hotspot"
    password: "passelektromer"

logger:
  logs:
    # Hidden warning: 
    # [00:00:00][W][component:204]: Component xxxxxx took a long time for an operation (x.xx s).
    # [00:00:00][W][component:205]: Components should block for at most 20-30ms.
    # Source: https://github.com/esphome/issues/issues/4717
    component: ERROR
  baud_rate: 0
  tx_buffer_size: 256

#-------------------------------------------
# BLUETOOTH TRACKER
#-------------------------------------------
esp32_ble_tracker:
  scan_parameters:
   interval: 1100ms
   window: 1100ms
   active: true
  on_ble_advertise:
    then:
      - binary_sensor.template.publish:
          id: bt_sensor
          state: true

#bluetooth_proxy:
#xiaomi_ble:

#-------------------------------------------
# STATUS LED
#-------------------------------------------
status_led:
  pin: 
    number: $status_pin
    inverted: False
    ignore_strapping_warning: true

script:
  id: light_page
  mode: restart
  then:
    - display.page.show: page_light
    - component.update: eink42
    - delay: 1s
    - display.page.show: page_one
    - component.update: eink42

#-------------------------------------------
# SENSORS
#-------------------------------------------
sensor:
#-------------------------------------------
# WIFI SIGNAL COMPONENT 
#-------------------------------------------
  - platform: wifi_signal
    name: "${friendly_name} Signal"
    update_interval: 320s
    id: sig_w

#-------------------------------------------
# Pulse meter - power consumption
# photodiode module - fixing polarite led
#-------------------------------------------
  - platform: pulse_meter
    name: '${friendly_name} Power consumption'
    unit_of_measurement: 'W'
    id: power_el
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    accuracy_decimals: 0
    pin: ${pulse_pin}
    internal_filter: 80ms
    filters:
      # multiply value = (60 / imp value) * 1000
      # - multiply: 60
      - lambda: return x * ((60.0 / $pulse_rate) * 1000.0);
      # No value greater than $max_watt fix greate value max 25A circuit breaker
      - lambda: 'return min((float)$max_power_filter, x);'
      - filter_out: $max_power_filter

    total:
      name: '${friendly_name} Total energy'
      unit_of_measurement: 'kWh'
      icon: mdi:circle-slice-3
      state_class: total_increasing
      device_class: energy
      accuracy_decimals: 2
      filters:
        # multiply value = 1 / imp value
        # - multiply: 0.001
        - lambda: return x * (1.0 / ${pulse_rate});

#-------------------------------------------
# Temperature humidity sensor - DHT11
#-------------------------------------------
  - platform: dht
    pin: $dht_pin
    temperature:
      name: "${friendly_name} Temperature"
      id: temp
      filters:
        - offset: -0.7
    humidity:
      name: "${friendly_name} Humidity"
      id: humi
    update_interval: 60s

#-------------------------------------------
# Rotary encoder
#-------------------------------------------
  - platform: rotary_encoder
    name: "${friendly_name} Rotary"
    pin_a: $rotary_a
    pin_b: $rotary_b
    restore_mode: ALWAYS_ZERO
    min_value: 0
    max_value: 10
    filters:
      - throttle: 0.01s
    on_clockwise:
      if: 
        condition:
          and:
            - light.is_on: downlight
            #- lambda: "return id(downlight).current_values.get_brightness() > 11;"
            - lambda: |-
                return (int(id(downlight).remote_values.get_brightness() * 255) > 15);
        then:
          - light.dim_relative:
              id: downlight
              relative_brightness: -10%
          - script.execute: light_page

    on_anticlockwise:
      if:
        condition:
          light.is_on: downlight
        then:
          - light.dim_relative:
              id: downlight
              relative_brightness: 10%
          - script.execute: light_page

#-------------------------------------------
# LIGHT BRIGHTNESS SENSOR
#-------------------------------------------
  - platform: template
    name: "${friendly_name} Brightness"
    lambda: return (id(downlight).remote_values.get_brightness());
    id: brigh_light
    internal: True

#-------------------------------------------
# LDR SENSOR - LIGHT lux Raw
#-------------------------------------------
  - platform: adc
    id: ambient_light
    pin: "$ldr_pin"
    attenuation: 12db
    #name: "${friendly_name} Illuminance Raw"
    internal: true
    unit_of_measurement: V
    device_class: illuminance
    accuracy_decimals: 3
    update_interval: never
    on_value:
      then:
        - component.update: ambient
        - if:
            condition:
              sensor.in_range:
                id: ambient_light
                above: 0.1425
            then:
              - binary_sensor.template.publish:
                  id: light_detect
                  state: True
            else:
              - binary_sensor.template.publish:
                  id: light_detect
                  state: False

#-------------------------------------------
# TEMPLATE - LDR SENSOR - LIGHT lux
#-------------------------------------------
  - platform: template
    id: ambient
    name: "${friendly_name} Illuminance"
    unit_of_measurement: lx
    device_class: illuminance
    accuracy_decimals: 0
    update_interval: never
    lambda: "return id(ambient_light).state;"
    filters:
      - calibrate_linear:
          - 0.1425 -> 0 # 3.4
          - 2.5 -> 1000
      - lambda: 'return max((float)0.0, x);' # No value lower than 0

#-------------------------------------------
# Home Assistant imported sensors
#-------------------------------------------
# ----- WHEATER -----
# Temperature now
  - platform: homeassistant
    internal: true
    #id: temp_now
    id: temp_now_temp
    entity_id: $weather_temp
# UV now
  - platform: homeassistant
    internal: true
    id: uv_now
    entity_id: $weather_uv
# Wind now
  - platform: homeassistant
    internal: true
    id: wind_now
    entity_id: $weather_wind
# ----- WHEATER FORECAST-----
# Temperature
  - platform: homeassistant
    internal: true
    id: cast_temp
    entity_id: $forecast_temp
# Temperature Low
  - platform: homeassistant
    internal: true
    id: cast_temp_low
    entity_id: $forecast_templow

# ----- ELECTRICITY -----
  - platform: homeassistant
    internal: true
    id: el_daily
    entity_id: $el_consumption

#-------------------------------------------
# TEXT SENSORS
#-------------------------------------------
text_sensor:
#-------------------------------------------
# Weather import home assistant sensor
#-------------------------------------------
##condition now
  - platform: homeassistant
    internal: true
    id: weather_now
    entity_id: $weather_condition

#-------------------------------------------
# Weather forecast - import home assistant sensor
#-------------------------------------------
  - platform: homeassistant
    internal: true
    entity_id: $forecast
    id: forecast_now

#-------------------------------------------
# BINARY SENSORS
#-------------------------------------------
binary_sensor:
#-------------------------------------------
# Remote receiver - Doorbell state
#-------------------------------------------
  - platform: remote_receiver
    name: "Doorbell"
    device_class: opening
    icon: mdi:doorbell-video
    rc_switch_raw:
      code: '110010011110001100001010'
      protocol: 1
    filters:
      - delayed_off: 3s
    on_press:
      then:
        - rtttl.play: Sticky:d=4,o=6,b=112:16c,16e,16a5,16c,16e,16a5,16c,16e,16d

        #- rtttl.play: Auld_L_S:d=8,o=5,b=200:c,8c,c,e,d,8c,d,8e,8d,c,8c,e,g,2a,a,g,8e,e,c,d,8c,d,8e,8d,c,2c
        #- rtttl.play: Fixyou:d=4,o=5,b=140:8p,16p,8e6,8e6,16c,16p,2e6,16f,8p,16p,8f,8c6,8c6,8c6,8f6,8f6,16f,16p,f6,e.6,
        #- rtttl.play: shinobi:d=6,o=5,b=250:b,f#6,d6,b,g,f#,e,2f#.,a,1f#,

#-------------------------------------------
# Template - Bluteooth detected
#-------------------------------------------
  - platform: template
    name: "${friendly_name} Bluetooth"
    icon: mdi:bluetooth
    id: bt_sensor
    internal: True

#-------------------------------------------
# Template - Light detected
#-------------------------------------------
  - platform: template
    name: "${friendly_name} Light detect"
    icon: mdi:home-lightbulb-outline
    id: light_detect

#-------------------------------------------
# Template - enable script after boot and no motion
#-------------------------------------------
  - platform: template
    name: "${friendly_name} Enable Script"
    id: script_enable

#-------------------------------------------
# Rotary encoder - Button
#-------------------------------------------
  - platform: gpio
    name: "${friendly_name} Rotary Button"
    pin: 
      number: $rotary_button
      inverted: true
    on_press:
      then:
        if:
          condition:
            light.is_on: downlight
          then:
            - binary_sensor.template.publish:
                id: script_enable
                state: false
            - light.turn_off: downlight
          else:
            if:
              condition:
                light.is_off: downlight
              then:
                # - binary_sensor.template.publish:
                #     id: script_enable
                #     state: false
                - light.turn_on:
                    id: downlight
                    brightness: 80%

#-------------------------------------------
# Magnetic reed switch
#-------------------------------------------
  - platform: gpio
    name: "${friendly_name} Magnet"
    pin: 
      number: $reed_pin
      inverted: true
    id: magnet
    device_class: door
    on_press:
      - if:
          condition:
            and:
                  - time.has_time:
                  - binary_sensor.is_off: light_detect
                  # - binary_sensor.is_on: script_enable
          then:
            - binary_sensor.template.publish:
                id: script_enable
                state: true
            - if:
                condition:
                  - lambda: 'return id(esptime).now().hour > 20;'
                then:

                  - light.turn_on:
                      id: downlight
                      brightness: 35%
                      cold_white: 0%
                      warm_white: 100%
                else:
                  - light.turn_on:
                      id: downlight
                      brightness: 60%
                      cold_white: 100%
                      warm_white: 100%
          else:
            if:
              condition:
                - not:
                    time.has_time:
                - and:
                    - binary_sensor.is_off: light_detect
                    # - binary_sensor.is_on: script_enable
              then:
                - binary_sensor.template.publish:
                    id: script_enable
                    state: true
                #- logger.log: "NOT TIME SET - MAGNET"
                - light.turn_on:
                    id: downlight
                    brightness: 50%
                    cold_white: 0%
                    warm_white: 100%
    on_release:
      - delay: 5s
      - if:
          condition:
            # - binary_sensor.is_on: script_enable
            - not:
                binary_sensor.is_on: motion
          then:
            - delay: 5s
            - light.turn_off: downlight

#-------------------------------------------
# Pir sensor SB312 
# motion enabled ESP and prevent deepsleep
#-------------------------------------------
  - platform: gpio
    pin: 
      number: "$pir_sensor"
    name: "${friendly_name} Motion"
    id: motion
    device_class: motion
    filters:
      - delayed_off: $delay_time
      # - delayed_on: 500ms

    on_press:
      - if:
          condition:
            and:
                  - time.has_time:
                  - binary_sensor.is_off: light_detect
                  - binary_sensor.is_on: script_enable
                  # - binary_sensor.is_off: blocking_motion
                  # - binary_sensor.is_off: magnet
          then:
            - if:
                condition:
                  - lambda: 'return id(esptime).now().hour > 20;'
                then:
                  - light.turn_on:
                      id: downlight
                      brightness: 35%
                      cold_white: 0%
                      warm_white: 100%
                else:
                  - light.turn_on:
                      id: downlight
                      brightness: 60%
                      cold_white: 100%
                      warm_white: 100%
          else:
            if:
              condition:
                - not:
                    time.has_time:
                - and:
                    - binary_sensor.is_off: light_detect
                    - binary_sensor.is_on: script_enable
              then:
                #- logger.log: "NOT TIME SET - PIR"
                - light.turn_on:
                    id: downlight
                    brightness: 50%
                    cold_white: 0%
                    warm_white: 100%
    # motion off
    on_release:
      - if:
          condition:
            - binary_sensor.is_on: script_enable
          then:
            - light.turn_off: downlight

#-------------------------------------------
# Status online
#-------------------------------------------
  - platform: status
    name: "${friendly_name} Status"

#-------------------------------------------
# INTERVAL
#-------------------------------------------
interval:
#-------------------------------------------
# Lux interval
#-------------------------------------------
  - interval: 20s
    then:
      - if:
          condition:
            - switch.is_on: interval_lux
          then:
            - component.update: ambient_light

#-------------------------------------------
# SWITCHES
#-------------------------------------------
switch:
#-------------------------------------------
# Solid relay
#-------------------------------------------
  - platform: gpio
    restore_mode: ALWAYS_OFF
    pin:
      number: "$relay_pin"
      #inverted: true
    name: "${friendly_name} Relay Light"

#-------------------------------------------
# Switch interval lux
#-------------------------------------------
  - platform: template
    name: "${friendly_name} Interval Lux"
    id: interval_lux
    entity_category: config
    optimistic: True

#-------------------------------------------
# OUTPUTS
#-------------------------------------------
output:
#-------------------------------------------
# PWM component - cold white led 
# PROBLEM: low under 25% no light
#-------------------------------------------
  - platform: ledc
    pin: "$cw_led_pin"
    id: output_cw

#-------------------------------------------
# PWM component - warm white led
# PROBLEM: low under 25% no light
#-------------------------------------------
  - platform: ledc
    pin: 
      number: "$ww_led_pin"
      ignore_strapping_warning: true
    id: output_ww

#-------------------------------------------
# PWM RTTTL
#-------------------------------------------  
  - platform: ledc
    pin: $piezo_pin
    id: rtttl_out

#-------------------------------------------
# RTTTL
#-------------------------------------------  
rtttl:
  output: rtttl_out

#-------------------------------------------
# REMOTE RECEIVER
#-------------------------------------------  
remote_receiver:
    pin: 
      number: $remote_pin
    dump: rc_switch

#-------------------------------------------
# LIGHTS
#-------------------------------------------
light:
  - platform: cwww
    name: "${friendly_name} Light"
    icon: mdi:spotlight
    id: downlight
    cold_white: output_cw
    warm_white: output_ww
    cold_white_color_temperature: 5700 K
    warm_white_color_temperature: 3000 K
    on_turn_off:
      then:
        if:
          condition:
            binary_sensor.is_on: script_enable
          then:
            switch.turn_on: interval_lux
    on_turn_on:
      then:
        - switch.turn_off: interval_lux

#-------------------------------------------
# TIME COMPONENT
#-------------------------------------------
time:
  - platform: homeassistant
    id: esptime
    timezone: "Europe/Bratislava"

#-------------------------------------------
# DISPLAY
#-------------------------------------------
display:
  - platform: waveshare_epaper
    cs_pin:    "$eink_cs_pin"
    dc_pin:    "$eink_dc_pin"
    busy_pin:  "$eink_busy_pin"
    reset_pin: "$eink_en_pin"
    model: 1.54in
    rotation: 90°
    update_interval: 20s
    full_update_every: 60
    id: eink42
    pages:
#-------------------------------------------
# PAGE 1 - PAGE RUN
#-------------------------------------------
      - id: page_one
        lambda: |-
          //--------------------------------------------------------------------------
          // START PAGE - log updating display
          //--------------------------------------------------------------------------
          ESP_LOGI("display", "Updating Eink42 Display...");

          //--------------------------------------------------------------------------
          // INTERNAL TEMPERATURE AND HUMIDITY SENSOR
          //--------------------------------------------------------------------------
          it.printf(0, 1, id(fontpixel_height), "%.1fŘ%.0f%%", id(temp).state, id(humi).state);

          //--------------------------------------------------------------------------
          // BLUETOOTH ADVERTISE
          //--------------------------------------------------------------------------
          if (id(bt_sensor).state) { it.printf(it.get_width() - 17, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F00B0");} 
          else                            { it.printf(it.get_width() - 17, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F00AF");}

          //--------------------------------------------------------------------------
          // WIFI SIGNAL SENSOR mdi print
          //--------------------------------------------------------------------------
          int signal_wifi = int(id(sig_w).state);  //convert state to int
          if (signal_wifi < 0 && signal_wifi >= -50)    { it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BE");}
          if (signal_wifi < -50 && signal_wifi >= -70)  { it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BD");}
          if (signal_wifi < -70 && signal_wifi >= -100) { it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BC");}
          else                                          { it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BF");}

          //--------------------------------------------------------------------------
          // LINE
          //--------------------------------------------------------------------------
          it.line(0, 19, it.get_width(), 19);

          // line horizontal
          it.line(0, 75, 100, 75);

          // line vertical
          it.line(100, 19, 100, 176);

          //--------------------------------------------------------------------------
          // TIME
          //--------------------------------------------------------------------------
          it.strftime(8, 11, id(fontlarge), "%H:%M", id(esptime).now());

          //--------------------------------------------------------------------------
          // WEATHER
          //--------------------------------------------------------------------------
          // Map weather states to MDI characters.
          std::map<std::string, std::string> weather_icon_map
            {
              {"cloudy", "\U000F0590"},
              {"cloudy-alert", "\U000F0F2F"},
              {"cloudy-arrow-right", "\U000F0E6E"},
              {"fog", "\U000F0591"},
              {"hail", "\U000F0592"},
              {"hazy", "\U000F0F30"},
              {"hurricane", "\U000F0898"},
              {"lightning", "\U000F0593"},
              {"lightning-rainy", "\U000F067E"},
              {"night", "\U000F0594"},
              {"clear-night", "\U000F0594"},
              {"night-partly-cloudy", "\U000F0F31"},
              {"partlycloudy", "\U000F0595"},
              {"partly-lightning", "\U000F0F32"},
              {"partly-rainy", "\U000F0F33"},
              {"partly-snowy", "\U000F0F34"},
              {"partly-snowy-rainy", "\U000F0F35"},
              {"pouring", "\U000F0596"},
              {"rainy", "\U000F0597"},
              {"snowy", "\U000F0598"},
              {"snowy-heavy", "\U000F0F36"},
              {"snowy-rainy", "\U000F067F"},
              {"sunny", "\U000F0599"},
              {"sunny-alert", "\U000F0F37"},
              {"sunny-off", "\U000F14E4"},
              {"sunset", "\U000F059A"},
              {"sunset-down", "\U000F059B"},
              {"sunset-up", "\U000F059C"},
              {"tornado", "\U000F0F38"},
              {"windy", "\U000F059D"},
              {"windy-variant", "\U000F059E"},
            };

          // temp
          it.printf(150, 104, id(font2), TextAlign::TOP_CENTER, "%.1f°C", id(temp_now_temp).state);

          // uv, wind
          it.printf(150, 178, id(font1), TextAlign::BOTTOM_CENTER, "%.1fUV %.1fkm/h", id(uv_now).state, id(wind_now).state);

          // condition now
          it.printf(100, 17, id(fontweater_large), TextAlign::TOP_LEFT, "%s", weather_icon_map[id(weather_now).state.c_str()].c_str());

          //--------------------------------------------------------------------------
          // WEATHER FORECAST
          //--------------------------------------------------------------------------
          it.print(50, 78, id(font1), TextAlign::TOP_CENTER, "PREDPOVEĎ");
          it.printf(50, 100, id(fontweater_medium), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(forecast_now).state.c_str()].c_str());
          it.printf(50, 178, id(font1), TextAlign::BOTTOM_CENTER, "%.1f°C | %.1f°C", id(cast_temp).state, id(cast_temp_low).state);

          //--------------------------------------------------------------------------
          // LINE
          //--------------------------------------------------------------------------
          it.line(0, it.get_height() - 23, it.get_width(), it.get_height() - 23);

          //--------------------------------------------------------------------------
          // ELEKTROMER
          //--------------------------------------------------------------------------
          it.printf(100, it.get_height(), id(fontpixel_height), TextAlign::BOTTOM_CENTER, "%.1f W %.2f kWh", id(power_el).state, id(el_daily).state);
#-------------------------------------------
# PAGE 2 - PAGE LIGHT
#-------------------------------------------
      - id: page_light
        lambda: |-
          //--------------------------------------------------------------------------
          // START PAGE - log updating display
          //--------------------------------------------------------------------------
          ESP_LOGI("display", "Updating Eink42 Display...");

          //--------------------------------------------------------------------------
          // INTERNAL TEMPERATURE AND HUMIDITY SENSOR - AHT10
          //--------------------------------------------------------------------------
          it.printf(0, 1, id(fontpixel_height), "%.1fŘ%.0f%%", id(temp).state, id(humi).state);

          //--------------------------------------------------------------------------
          // BLUETOOTH ADVERTISE
          //--------------------------------------------------------------------------
          if (id(bt_sensor).state) {
            it.printf(it.get_width() - 17, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F00B0");
          } else {
            it.printf(it.get_width() - 17, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F00AF");
          }
          //--------------------------------------------------------------------------
          // WIFI SIGNAL SENSOR mdi print
          //--------------------------------------------------------------------------
          int signal_wifi = int(id(sig_w).state);  //convert state to int

          if (signal_wifi < 0 && signal_wifi >= -50) {
            it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BE");
          }
          if (signal_wifi < -50 && signal_wifi >= -70) {
            it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BD");
          }
          if (signal_wifi < -70 && signal_wifi >= -100) {
            it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BC");
          }
          else {
            it.printf(it.get_width(), 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BF");
          }

          //--------------------------------------------------------------------------
          // LINE
          //--------------------------------------------------------------------------
          it.line(0, 19, it.get_width(), 19);

          // line horizontal
          it.line(0, 75, 100, 75);

          // line vertical
          it.line(100, 19, 100, 176);

          //--------------------------------------------------------------------------
          // TIME
          //--------------------------------------------------------------------------
          it.strftime(8, 11, id(fontlarge), "%H:%M", id(esptime).now());

          //--------------------------------------------------------------------------
          // WEATHER
          //--------------------------------------------------------------------------
          // Map weather states to MDI characters.
          std::map<std::string, std::string> weather_icon_map
            {
              {"cloudy", "\U000F0590"},
              {"cloudy-alert", "\U000F0F2F"},
              {"cloudy-arrow-right", "\U000F0E6E"},
              {"fog", "\U000F0591"},
              {"hail", "\U000F0592"},
              {"hazy", "\U000F0F30"},
              {"hurricane", "\U000F0898"},
              {"lightning", "\U000F0593"},
              {"lightning-rainy", "\U000F067E"},
              {"night", "\U000F0594"},
              {"clear-night", "\U000F0594"},
              {"night-partly-cloudy", "\U000F0F31"},
              {"partlycloudy", "\U000F0595"},
              {"partly-lightning", "\U000F0F32"},
              {"partly-rainy", "\U000F0F33"},
              {"partly-snowy", "\U000F0F34"},
              {"partly-snowy-rainy", "\U000F0F35"},
              {"pouring", "\U000F0596"},
              {"rainy", "\U000F0597"},
              {"snowy", "\U000F0598"},
              {"snowy-heavy", "\U000F0F36"},
              {"snowy-rainy", "\U000F067F"},
              {"sunny", "\U000F0599"},
              {"sunny-alert", "\U000F0F37"},
              {"sunny-off", "\U000F14E4"},
              {"sunset", "\U000F059A"},
              {"sunset-down", "\U000F059B"},
              {"sunset-up", "\U000F059C"},
              {"tornado", "\U000F0F38"},
              {"windy", "\U000F059D"},
              {"windy-variant", "\U000F059E"},
            };

          // temp
          it.printf(150, 104, id(font2), TextAlign::TOP_CENTER, "%.1f°C", id(temp_now_temp).state);

          // uv, wind
          it.printf(150, 178, id(font1), TextAlign::BOTTOM_CENTER, "%.1fUV %.1fkm/h", id(uv_now).state, id(wind_now).state);

          // condition now
          it.printf(100, 17, id(fontweater_large), TextAlign::TOP_LEFT, "%s", weather_icon_map[id(weather_now).state.c_str()].c_str());

          //--------------------------------------------------------------------------
          // LINE
          //--------------------------------------------------------------------------
          it.line(0, it.get_height() - 23, it.get_width(), it.get_height() - 23);

          //--------------------------------------------------------------------------
          // ELEKTROMER
          //--------------------------------------------------------------------------
          it.printf(100, it.get_height(), id(fontpixel_height), TextAlign::BOTTOM_CENTER, "%.1f W %.2f kWh", id(power_el).state, id(el_daily).state);

          //--------------------------------------------------------------------------
          // DOWNLIGHT
          //--------------------------------------------------------------------------
          float light_level = (id(downlight).remote_values.get_brightness() * 70);
          if (light_level >= 70) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08FA");
          }
          else if (light_level < 70 && light_level >= 60) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08F9");
          }
          else if (light_level < 60 && light_level >= 50) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08F8");
          }
          else if (light_level < 50 && light_level >= 40) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08F7");
          }
          else if (light_level < 40 && light_level >= 30) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08F6");
          }
          else if (light_level < 30 && light_level >= 20) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08F4");
          }
          else if (light_level < 20 && light_level >= 10) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08F5");
          }
          else if (light_level < 10 && light_level >= 0) {
            it.printf(50, 100, id(fontlight), TextAlign::TOP_CENTER, "\U000F08FE");
          }

#-------------------------------------------
# FONTS
#-------------------------------------------
font:
  - file: 'fonts/bahnschrift2.ttf'
    id: fonttext2
    size: 18
    glyphs:
      ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
       '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
       'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
       'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
       'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
       'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³','ý','Ý', ž, á, š, Š, ľ, ó, Č, č, í, Ľ, ú, é, ť, ň, ď, Ž]

  - file: 'fonts/pixeloperator-height.ttf'
    id: fontpixel_height
    size: 18
    glyphs:
      ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'Ř', 'ř', '°', 'C', '/', '%', '.',
       'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
       'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', W, ' ',]

  - file: 'fonts/icons.ttf'
    id: fonticon
    size: 16 
    glyphs: [
      "\U000F08BF", # no wifi
      "\U000F08BC", # wifi low
      "\U000F08BD", # mwifi middle
      "\U000F08BE", # wifi high

      "\U000F06A5", # power
      "\U000F10C2", # temp
      "\U000F058E", # HUMIDITY
      "\U000F0875", # PRESSURE

      "\U000F1358", # GAS
      "\U000F1402", # MOTOR
      "\U000F1357", # WATER TANK
      "\U000F1067", # PUMP

      "\U000F0A7A", # WASTE TRASH
      "\U000F00ED", # CALENDAR
      "\U000F04E0", # SUNGLASS UV
      "\U000F059D", # WIND
      "\U000F0597", # RAIN
      "\U000F05B1", # WINDOW OPEN

      "\U000F04B2", # SLEEP

      "\U000F00AF", # BLUETOOTH
      "\U000F00B0", # BLUETOOTH ADVERTISE
      ]

  - file: 'fonts/icons.ttf'
    id: fontlight
    size: 54 
    glyphs: [
      "\U000F08F5", # 12.5
      "\U000F08F4", # 25.0
      "\U000F08F6", # 37.5
      "\U000F08F7", # 50.0
      "\U000F08F8", # 62.5
      "\U000F08F9", # 75
      "\U000F08FA", # 87.5
      "\U000F08FE", # 100

      "\U000F081A", # DOOR CLOSED
      "\U000F081C", # DOOR OPEN
      ]

  - file: 'fonts/font-bd-large.ttf'
    id: fontlarge
    size: 54

  - file: 'fonts/materialdesignicons-webfont.ttf'
    id: fontweater_large
    size: 104
    glyphs: &mdi-weather-glyphs
      - "\U000F0590" # mdi-weather-cloudy
      - "\U000F0F2F" # mdi-weather-cloudy-alert
      - "\U000F0E6E" # mdi-weather-cloudy-arrow-right
      - "\U000F0591" # mdi-weather-fog
      - "\U000F0592" # mdi-weather-hail
      - "\U000F0F30" # mdi-weather-hazy
      - "\U000F0898" # mdi-weather-hurricane
      - "\U000F0593" # mdi-weather-lightning
      - "\U000F067E" # mdi-weather-lightning-rainy
      - "\U000F0594" # mdi-weather-night
      - "\U000F0F31" # mdi-weather-night-partly-cloudy
      - "\U000F0595" # mdi-weather-partly-cloudy
      - "\U000F0F32" # mdi-weather-partly-lightning
      - "\U000F0F33" # mdi-weather-partly-rainy
      - "\U000F0F34" # mdi-weather-partly-snowy
      - "\U000F0F35" # mdi-weather-partly-snowy-rainy
      - "\U000F0596" # mdi-weather-pouring
      - "\U000F0597" # mdi-weather-rainy
      - "\U000F0598" # mdi-weather-snowy
      - "\U000F0F36" # mdi-weather-snowy-heavy
      - "\U000F067F" # mdi-weather-snowy-rainy
      - "\U000F0599" # mdi-weather-sunny
      - "\U000F0F37" # mdi-weather-sunny-alert
      - "\U000F14E4" # mdi-weather-sunny-off
      - "\U000F059A" # mdi-weather-sunset
      - "\U000F059B" # mdi-weather-sunset-down
      - "\U000F059C" # mdi-weather-sunset-up
      - "\U000F0F38" # mdi-weather-tornado
      - "\U000F059D" # mdi-weather-windy
      - "\U000F059E" # mdi-weather-windy-variant

  - file: 'fonts/materialdesignicons-webfont.ttf'
    id: fontweater_medium
    size: 54
    glyphs: *mdi-weather-glyphs

  - file: 'fonts/font_bd.ttf'
    id: font2
    size: 42

  - file: 'fonts/steelfishedit.ttf'
    id: font1
    size: 22
    glyphs:
      ['!', ',', '.', '"', '%', '(', ')', '+', '-', ':', '°', '0',
       '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
       'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
       'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
       'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'č', 'ö', '/', '|', 'º','µ','³','ý','Ý', Š, ľ, Ď,]

Anything in the logs that might be useful for us?

Linking .pioenvs/energy-elektromer/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/energy-elektromer/firmware.elf section `.iram0.text' will not fit in region `iram0_0_seg'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: IRAM0 segment data does not fit.
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: region `iram0_0_seg' overflowed by 408 bytes
collect2: error: ld returned 1 exit status
*** [.pioenvs/energy-elektromer/firmware.elf] Error 1

Additional information

No response

tiimsvk commented 2 weeks ago

I tried to free some memory so I used this command.

framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32_WIFI_RX_IRAM_OPT: "n"

And it helped even at the expense of wifi performance.