ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
esphome Namespace Reference

Providing packet encoding functions for exchanging data with a remote host. More...

Namespaces

namespace  a01nyub
 
namespace  a02yyuw
 
namespace  a4988
 
namespace  absolute_humidity
 
namespace  ac_dimmer
 
namespace  adalight
 
namespace  adc
 
namespace  adc128s102
 
namespace  addressable_light
 
namespace  ade7880
 
namespace  ade7953_base
 
namespace  ade7953_i2c
 
namespace  ade7953_spi
 
namespace  ads1115
 
namespace  ads1118
 
namespace  ags10
 
namespace  aht10
 
namespace  aic3204
 
namespace  airthings_ble
 
namespace  airthings_wave_base
 
namespace  airthings_wave_mini
 
namespace  airthings_wave_plus
 
namespace  alarm_control_panel
 
namespace  alpha3
 
namespace  am2315c
 
namespace  am2320
 
namespace  am43
 
namespace  analog_threshold
 
namespace  animation
 
namespace  anova
 
namespace  apds9306
 
namespace  apds9960
 
namespace  api
 
namespace  aqi
 
namespace  as3935
 
namespace  as3935_i2c
 
namespace  as3935_spi
 
namespace  as5600
 
namespace  as7341
 
namespace  at581x
 
namespace  atc_mithermometer
 
namespace  atm90e26
 
namespace  atm90e32
 
namespace  audio
 
namespace  audio_adc
 
namespace  audio_dac
 
namespace  axs15231
 
namespace  b_parasite
 
namespace  ballu
 
namespace  bang_bang
 
namespace  bedjet
 
namespace  beken_spi_led_strip
 
namespace  bh1750
 
namespace  bh1900nux
 
namespace  binary
 
namespace  binary_sensor
 
namespace  binary_sensor_map
 
namespace  bl0906
 
namespace  bl0939
 
namespace  bl0940
 
namespace  bl0942
 
namespace  ble_client
 
namespace  ble_nus
 
namespace  ble_presence
 
namespace  ble_rssi
 
namespace  ble_scanner
 
namespace  bluetooth_proxy
 
namespace  bm8563
 
namespace  bme280_base
 
namespace  bme280_i2c
 
namespace  bme280_spi
 
namespace  bme680
 
namespace  bme680_bsec
 
namespace  bme68x_bsec2
 
namespace  bme68x_bsec2_i2c
 
namespace  bmi160
 
namespace  bmp085
 
namespace  bmp280_base
 
namespace  bmp280_i2c
 
namespace  bmp280_spi
 
namespace  bmp3xx_base
 
namespace  bmp3xx_i2c
 
namespace  bmp3xx_spi
 
namespace  bmp581
 
namespace  bp1658cj
 
namespace  bp5758d
 
namespace  bthome_mithermometer
 
namespace  button
 
namespace  bytebuffer
 
namespace  camera
 
namespace  camera_encoder
 
namespace  canbus
 
namespace  cap1188
 
namespace  captive_portal
 
namespace  cc1101
 
namespace  ccs811
 
namespace  cd74hc4067
 
namespace  ch422g
 
namespace  chsc6x
 
namespace  climate
 
namespace  climate_ir
 
namespace  climate_ir_lg
 
namespace  cm1106
 
namespace  color_temperature
 
namespace  combination
 
namespace  coolix
 
namespace  copy
 
namespace  cover
 
namespace  cs5460a
 
namespace  cse7761
 
namespace  cse7766
 
namespace  cst226
 
namespace  cst816
 
namespace  ct_clamp
 
namespace  current_based
 
namespace  cwww
 
namespace  dac7678
 
namespace  daikin
 
namespace  daikin_arc
 
namespace  daikin_brc
 
namespace  dallas_temp
 
namespace  daly_bms
 
namespace  dashboard_import
 
namespace  datetime
 
namespace  debug
 
namespace  deep_sleep
 
namespace  delonghi
 
namespace  demo
 
namespace  dfplayer
 
namespace  dfrobot_sen0395
 
namespace  dht
 
namespace  dht12
 
namespace  display
 
namespace  display_menu_base
 
namespace  dps310
 
namespace  ds1307
 
namespace  ds2484
 
namespace  dsmr
 
namespace  duty_cycle
 
namespace  duty_time_sensor
 
namespace  e131
 
namespace  ee895
 
namespace  ektf2232
 
namespace  emc2101
 
namespace  emmeti
 
namespace  endstop
 
namespace  ens160_base
 
namespace  ens160_i2c
 
namespace  ens160_spi
 
namespace  ens210
 
namespace  epaper_spi
 
namespace  es7210
 
namespace  es7243e
 
namespace  es8156
 
namespace  es8311
 
namespace  es8388
 
namespace  esp32
 
namespace  esp32_ble
 
namespace  esp32_ble_beacon
 
namespace  esp32_ble_client
 
namespace  esp32_ble_server
 
namespace  esp32_ble_tracker
 
namespace  esp32_camera
 
namespace  esp32_camera_web_server
 
namespace  esp32_can
 
namespace  esp32_dac
 
namespace  esp32_hosted
 
namespace  esp32_improv
 
namespace  esp32_rmt_led_strip
 
namespace  esp32_touch
 
namespace  esp8266
 
namespace  esp8266_pwm
 
namespace  esp_ldo
 
namespace  espnow
 
namespace  ethernet
 
namespace  ethernet_info
 
namespace  event
 
namespace  exposure_notifications
 
namespace  ezo
 
namespace  ezo_pmp
 
namespace  factory_reset
 
namespace  fan
 
namespace  fastled_base
 
namespace  feedback
 
namespace  fingerprint_grow
 
namespace  font
 
namespace  fs3000
 
namespace  ft5x06
 
namespace  ft63x6
 
namespace  fujitsu_general
 
namespace  gcja5
 
namespace  gdk101
 
namespace  gl_r01_i2c
 
namespace  globals
 
namespace  gp2y1010au0f
 
namespace  gp8403
 
namespace  gpio
 
namespace  gpio_expander
 
namespace  gps
 
namespace  graph
 
namespace  graphical_display_menu
 
namespace  gree
 
namespace  grove_gas_mc_v2
 
namespace  grove_tb6612fng
 
namespace  growatt_solar
 
namespace  gt911
 
namespace  haier
 
namespace  havells_solar
 
namespace  hbridge
 
namespace  hc8
 
namespace  hdc1080
 
namespace  hdc2010
 
namespace  he60r
 
namespace  heatpumpir
 
namespace  hitachi_ac344
 
namespace  hitachi_ac424
 
namespace  hlk_fm22x
 
namespace  hlw8012
 
namespace  hlw8032
 
namespace  hm3301
 
namespace  hmac_md5
 
namespace  hmac_sha256
 
namespace  hmc5883l
 
namespace  homeassistant
 
namespace  honeywell_hih_i2c
 
namespace  honeywellabp
 
namespace  honeywellabp2_i2c
 
namespace  host
 
namespace  hrxl_maxsonar_wr
 
namespace  hte501
 
namespace  http_request
 
namespace  htu21d
 
namespace  htu31d
 
namespace  hub75
 
namespace  hx711
 
namespace  hydreon_rgxx
 
namespace  hyt271
 
namespace  i2c
 
namespace  i2c_device
 
namespace  i2s_audio
 
namespace  iaqcore
 
namespace  ili9xxx
 
namespace  image
 
namespace  improv_base
 
namespace  improv_serial
 
namespace  ina219
 
namespace  ina226
 
namespace  ina260
 
namespace  ina2xx_base
 
namespace  ina2xx_i2c
 
namespace  ina2xx_spi
 
namespace  ina3221
 
namespace  inkbird_ibsth1_mini
 
namespace  inkplate
 
namespace  integration
 
namespace  internal
 
namespace  internal_temperature
 
namespace  interval
 
namespace  jsn_sr04t
 
namespace  json
 
namespace  kamstrup_kmp
 
namespace  key_collector
 
namespace  key_provider
 
namespace  kmeteriso
 
namespace  kuntze
 
namespace  lc709203f
 
namespace  lcd_base
 
namespace  lcd_gpio
 
namespace  lcd_menu
 
namespace  lcd_pcf8574
 
namespace  ld2410
 
namespace  ld2412
 
namespace  ld2420
 
namespace  ld2450
 
namespace  ld24xx
 
namespace  ledc
 
namespace  libretiny
 
namespace  libretiny_pwm
 
namespace  light
 
namespace  lightwaverf
 
namespace  lilygo_t5_47
 
namespace  lm75b
 
namespace  lock
 
namespace  logger
 
namespace  lps22
 
namespace  ltr390
 
namespace  ltr501
 
namespace  ltr_als_ps
 
namespace  lvgl
 
namespace  m5stack_8angle
 
namespace  mapping
 
namespace  matrix_keypad
 
namespace  max17043
 
namespace  max31855
 
namespace  max31856
 
namespace  max31865
 
namespace  max44009
 
namespace  max6675
 
namespace  max6956
 
namespace  max7219
 
namespace  max7219digit
 
namespace  max9611
 
namespace  mcp23008
 
namespace  mcp23016
 
namespace  mcp23017
 
namespace  mcp23s08
 
namespace  mcp23s17
 
namespace  mcp23x08_base
 
namespace  mcp23x17_base
 
namespace  mcp23xxx_base
 
namespace  mcp2515
 
namespace  mcp3008
 
namespace  mcp3204
 
namespace  mcp3221
 
namespace  mcp4461
 
namespace  mcp4725
 
namespace  mcp4728
 
namespace  mcp47a1
 
namespace  mcp9600
 
namespace  mcp9808
 
namespace  md5
 
namespace  mdns
 
namespace  media_player
 
namespace  mhz19
 
namespace  micro_wake_word
 
namespace  micronova
 
namespace  microphone
 
namespace  mics_4514
 
namespace  midea
 
namespace  midea_ir
 
namespace  mipi_dsi
 
namespace  mipi_rgb
 
namespace  mipi_spi
 
namespace  mitsubishi
 
namespace  mixer_speaker
 
namespace  mlx90393
 
namespace  mlx90614
 
namespace  mmc5603
 
namespace  mmc5983
 
namespace  modbus
 
namespace  modbus_controller
 
namespace  monochromatic
 
namespace  mopeka_ble
 
namespace  mopeka_pro_check
 
namespace  mopeka_std_check
 
namespace  mpl3115a2
 
namespace  mpr121
 
namespace  mpu6050
 
namespace  mpu6886
 
namespace  mqtt
 
namespace  mqtt_subscribe
 
namespace  ms5611
 
namespace  ms8607
 
namespace  msa3xx
 
namespace  my9231
 
namespace  nau7802
 
namespace  neopixelbus
 
namespace  network
 
namespace  nextion
 
namespace  nfc
 
namespace  noblex
 
namespace  npi19
 
namespace  nrf52
 
namespace  ntc
 
namespace  number
 
namespace  one_wire
 
namespace  online_image
 
namespace  opentherm
 
namespace  openthread
 
namespace  openthread_info
 
namespace  opt3001
 
namespace  ota
 
namespace  output
 
namespace  packet_transport
 
namespace  partition
 
namespace  pca6416a
 
namespace  pca9554
 
namespace  pca9685
 
namespace  pcd8544
 
namespace  pcf85063
 
namespace  pcf8563
 
namespace  pcf8574
 
namespace  pi4ioe5v6408
 
namespace  pid
 
namespace  pipsolar
 
namespace  pm1006
 
namespace  pm2005
 
namespace  pmsa003i
 
namespace  pmsx003
 
namespace  pmwcs3
 
namespace  pn532
 
namespace  pn532_i2c
 
namespace  pn532_spi
 
namespace  pn7150
 
namespace  pn7150_i2c
 
namespace  pn7160
 
namespace  pn7160_i2c
 
namespace  pn7160_spi
 
namespace  power_supply
 
namespace  preferences
 
namespace  prometheus
 
namespace  psram
 
namespace  pulse_counter
 
namespace  pulse_meter
 
namespace  pulse_width
 
namespace  pvvx_mithermometer
 
namespace  pylontech
 
namespace  pzem004t
 
namespace  pzemac
 
namespace  pzemdc
 
namespace  qmc5883l
 
namespace  qmp6988
 
namespace  qr_code
 
namespace  qspi_dbi
 
namespace  qwiic_pir
 
namespace  radon_eye_ble
 
namespace  radon_eye_rd200
 
namespace  rc522
 
namespace  rc522_i2c
 
namespace  rc522_spi
 Library based on https://github.com/miguelbalboa/rfid and adapted to ESPHome by @glmnet.
 
namespace  rdm6300
 
namespace  remote_base
 
namespace  remote_receiver
 
namespace  remote_transmitter
 
namespace  resampler
 
namespace  resistance
 
namespace  restart
 
namespace  rf_bridge
 
namespace  rgb
 
namespace  rgbct
 
namespace  rgbw
 
namespace  rgbww
 
namespace  rotary_encoder
 
namespace  rp2040
 
namespace  rp2040_pio_led_strip
 
namespace  rp2040_pwm
 
namespace  rpi_dpi_rgb
 
namespace  rtttl
 
namespace  runtime_stats
 
namespace  ruuvi_ble
 
namespace  ruuvitag
 
namespace  rx8130
 
namespace  safe_mode
 
namespace  scd30
 
namespace  scd4x
 
namespace  script
 
namespace  sdl
 
namespace  sdm_meter
 
namespace  sdp3x
 
namespace  sds011
 
namespace  seeed_mr24hpc1
 
namespace  seeed_mr60bha2
 
namespace  seeed_mr60fda2
 
namespace  selec_meter
 
namespace  select
 
namespace  sen0321_sensor
 
namespace  sen21231_sensor
 
namespace  sen5x
 
namespace  senseair
 
namespace  sensirion_common
 
namespace  sensor
 
namespace  servo
 
namespace  setup_priority
 Default setup priorities for components of different types.
 
namespace  sfa30
 
namespace  sgp30
 
namespace  sgp4x
 
namespace  sha256
 
namespace  shelly_dimmer
 
namespace  sht3xd
 
namespace  sht4x
 
namespace  shtcx
 
namespace  shutdown
 
namespace  sigma_delta_output
 
namespace  sim800l
 
namespace  slow_pwm
 
namespace  sm10bit_base
 
namespace  sm16716
 
namespace  sm2135
 
namespace  sm2235
 
namespace  sm2335
 
namespace  sm300d2
 
namespace  sml
 
namespace  smt100
 
namespace  sn74hc165
 
namespace  sn74hc595
 
namespace  sntp
 
namespace  socket
 
namespace  sonoff_d1
 
namespace  sound_level
 
namespace  speaker
 
namespace  speed
 
namespace  spi
 Implementation of SPI Controller mode.
 
namespace  spi_device
 
namespace  spi_led_strip
 
namespace  split_buffer
 
namespace  sprinkler
 
namespace  sps30
 
namespace  ssd1306_base
 
namespace  ssd1306_i2c
 
namespace  ssd1306_spi
 
namespace  ssd1322_base
 
namespace  ssd1322_spi
 
namespace  ssd1325_base
 
namespace  ssd1325_spi
 
namespace  ssd1327_base
 
namespace  ssd1327_i2c
 
namespace  ssd1327_spi
 
namespace  ssd1331_base
 
namespace  ssd1331_spi
 
namespace  ssd1351_base
 
namespace  ssd1351_spi
 
namespace  st7567_base
 
namespace  st7567_i2c
 
namespace  st7567_spi
 
namespace  st7701s
 
namespace  st7735
 
namespace  st7789v
 
namespace  st7920
 
namespace  statsd
 
namespace  status
 
namespace  status_led
 
namespace  stepper
 
namespace  sts3x
 
namespace  stts22h
 
namespace  sun
 
namespace  sun_gtil2
 
namespace  switch_
 
namespace  sx126x
 
namespace  sx127x
 
namespace  sx1509
 Here you'll find the Arduino code used to interface with the SX1509 I2C 16 I/O expander.
 
namespace  syslog
 
namespace  t6615
 
namespace  tc74
 
namespace  tca9548a
 
namespace  tca9555
 
namespace  tcl112
 
namespace  tcs34725
 
namespace  tee501
 
namespace  teleinfo
 
namespace  tem3200
 
namespace  template_
 
namespace  text
 
namespace  text_sensor
 
namespace  thermopro_ble
 
namespace  thermostat
 
namespace  time
 
namespace  time_based
 
namespace  tinyusb
 
namespace  tlc59208f
 
namespace  tlc5947
 
namespace  tlc5971
 
namespace  tm1621
 
namespace  tm1637
 
namespace  tm1638
 
namespace  tm1651
 
namespace  tmp102
 
namespace  tmp1075
 
namespace  tmp117
 
namespace  tof10120
 
namespace  tormatic
 
namespace  toshiba
 
namespace  total_daily_energy
 
namespace  touchscreen
 
namespace  tsl2561
 
namespace  tsl2591
 
namespace  tt21100
 
namespace  ttp229_bsf
 
namespace  ttp229_lsf
 
namespace  tuya
 
namespace  tx20
 
namespace  uart
 
namespace  udp
 
namespace  ufire_ec
 
namespace  ufire_ise
 
namespace  uln2003
 
namespace  ultrasonic
 
namespace  update
 
namespace  uponor_smatrix
 
namespace  uptime
 
namespace  usb_cdc_acm
 
namespace  usb_host
 
namespace  usb_uart
 
namespace  valve
 
namespace  vbus
 
namespace  veml3235
 
namespace  veml7700
 
namespace  version
 
namespace  vl53l0x
 
namespace  voice_assistant
 
namespace  voltage_sampler
 
namespace  wake_on_lan
 
namespace  watchdog
 
namespace  water_heater
 
namespace  waveshare_epaper
 
namespace  web_server
 
namespace  web_server_base
 
namespace  web_server_idf
 
namespace  weikai
 
namespace  weikai_i2c
 
namespace  weikai_spi
 
namespace  whirlpool
 
namespace  whynter
 
namespace  wiegand
 
namespace  wifi
 
namespace  wifi_info
 
namespace  wifi_signal
 
namespace  wireguard
 
namespace  wk2132_i2c
 
namespace  wl_134
 
namespace  wled
 
namespace  wts01
 
namespace  x9c
 
namespace  xgzp68xx
 
namespace  xiaomi_ble
 
namespace  xiaomi_cgd1
 
namespace  xiaomi_cgdk2
 
namespace  xiaomi_cgg1
 
namespace  xiaomi_cgpr1
 
namespace  xiaomi_gcls002
 
namespace  xiaomi_hhccjcy01
 
namespace  xiaomi_hhccjcy10
 
namespace  xiaomi_hhccpot002
 
namespace  xiaomi_jqjcy01ym
 
namespace  xiaomi_lywsd02
 
namespace  xiaomi_lywsd02mmc
 
namespace  xiaomi_lywsd03mmc
 
namespace  xiaomi_lywsdcgq
 
namespace  xiaomi_mhoc303
 
namespace  xiaomi_mhoc401
 
namespace  xiaomi_miscale
 
namespace  xiaomi_mjyd02yla
 
namespace  xiaomi_mue4094rt
 
namespace  xiaomi_rtcgq02lm
 
namespace  xiaomi_wx08zm
 
namespace  xiaomi_xmwsdj04mmc
 
namespace  xl9535
 
namespace  xpt2046
 
namespace  xxtea
 
namespace  yashima
 
namespace  zephyr
 
namespace  zephyr_ble_server
 
namespace  zhlt01
 
namespace  zio_ultrasonic
 
namespace  zwave_proxy
 
namespace  zyaura
 

Data Structures

class  Action
 
class  ActionList
 
class  AndCondition
 
class  Application
 
class  Area
 
class  Automation
 
class  CallbackManager
 
class  CallbackManager< void(Ts...)>
 Helper class to allow having multiple subscribers to a callback. More...
 
struct  Color
 
class  Component
 
class  ComponentIterator
 
class  Condition
 Base class for all automation conditions. More...
 
class  ConstVector
 Lightweight read-only view over a const array stored in RODATA (will typically be in flash memory) Avoids copying data from flash to RAM by keeping a pointer to the flash data. More...
 
class  ContinuationAction
 Simple continuation action that calls play_next_ on a parent action. More...
 
class  Controller
 
class  ControllerRegistry
 Global registry for Controllers to receive entity state updates. More...
 
class  Deduplicator
 Helper class to deduplicate items in a series of values. More...
 
struct  DefaultBitPolicy
 Default bit mapping policy for contiguous enums starting at 0 Provides 1:1 mapping where enum value equals bit position. More...
 
class  DelayAction
 
class  Device
 
class  EntityBase
 
class  EntityBase_DeviceClass
 
class  EntityBase_UnitOfMeasurement
 
class  ESPHomeOTAComponent
 ESPHomeOTAComponent provides a simple way to integrate Over-the-Air updates into your app using ArduinoOTA. More...
 
class  ESPPreferenceBackend
 
class  ESPPreferenceObject
 
class  ESPPreferences
 
struct  ESPTime
 A more user-friendly version of struct tm from time.h. More...
 
class  EventPool
 
class  FiniteSetMask
 Generic bitmask for storing a finite set of discrete values efficiently. More...
 
class  FixedVector
 Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template overhead (_M_realloc_insert, _M_default_append) when size is known at initialization but not at compile time. More...
 
class  ForCondition
 
struct  gens< 0, S... >
 
class  GPIOPin
 
class  HashBase
 Base class for hash algorithms. More...
 
class  HighFrequencyLoopRequester
 Helper class to request loop() to be called as fast as possible. More...
 
class  IfAction
 
struct  int24_t
 24-bit signed integer type, transparently converting to 32-bit. More...
 
class  InternalGPIOPin
 
class  InterruptLock
 Helper class to disable interrupts. More...
 
class  ISRInternalGPIOPin
 Copy of GPIOPin that is safe to use from ISRs (with no virtual functions) More...
 
class  LambdaAction
 
class  LambdaCondition
 
class  LazyCallbackManager
 
class  LazyCallbackManager< void(Ts...)>
 Lazy-allocating callback manager that only allocates memory when callbacks are registered. More...
 
class  LockFreeQueue
 
class  LockGuard
 Helper class that wraps a mutex with a RAII-style API. More...
 
class  LoopTrigger
 
class  LwIPLock
 Helper class to lock the lwIP TCPIP core when making lwIP API calls from non-TCPIP threads. More...
 
class  Mutex
 Mutex implementation, with API based on the unavailable std::mutex. More...
 
class  NotCondition
 
class  NotifyingLockFreeQueue
 
struct  nullopt_t
 
class  optional
 
class  OrCondition
 
class  Parented
 Helper class to easily give an object a parent of type T. More...
 
class  PollingComponent
 This class simplifies creating components that periodically check a state. More...
 
class  ProjectUpdateTrigger
 
class  RAMAllocator
 An STL allocator that uses SPI or internal RAM. More...
 
class  RepeatAction
 
class  RepeatLoopContinuation
 Loop continuation for RepeatAction that increments iteration and repeats or continues. More...
 
class  ResumeComponentAction
 
class  RingBuffer
 
class  ShutdownTrigger
 
class  StartupTrigger
 
class  StatefulEntityBase
 An entity that has a state. More...
 
class  StatelessLambdaAction
 Optimized lambda action for stateless lambdas (no capture). More...
 
class  StatelessLambdaCondition
 Optimized lambda condition for stateless lambdas (no capture). More...
 
class  StaticVector
 Minimal static vector - saves memory by avoiding std::vector overhead. More...
 
class  StringRef
 StringRef is a reference to a string owned by something else. More...
 
class  SuspendComponentAction
 
class  TemplatableValue
 
class  TemplateLambda
 Lightweight wrapper for template platform lambdas (stateless function pointers only). More...
 
class  Trigger
 
struct  uint24_t
 24-bit unsigned integer type, transparently converting to 32-bit. More...
 
class  UpdateComponentAction
 
class  WaitUntilAction
 Wait until a condition is true to continue execution. More...
 
class  WarnIfComponentBlockingGuard
 
class  WhileAction
 
class  WhileLoopContinuation
 Loop continuation for WhileAction that checks condition and repeats or continues. More...
 
class  XorCondition
 

Concepts

concept  comparable_with
 Functions to constrain the range of arithmetic values.
 

Typedefs

using uint64_be_t = internal::BigEndianLayout<uint64_t>
 
using uint32_be_t = internal::BigEndianLayout<uint32_t>
 
using uint24_be_t = internal::BigEndianLayout<uint24_t>
 
using uint16_be_t = internal::BigEndianLayout<uint16_t>
 
using int64_be_t = internal::BigEndianLayout<int64_t>
 
using int32_be_t = internal::BigEndianLayout<int32_t>
 
using int24_be_t = internal::BigEndianLayout<int24_t>
 
using int16_be_t = internal::BigEndianLayout<int16_t>
 
using uint64_le_t = internal::LittleEndianLayout<uint64_t>
 
using uint32_le_t = internal::LittleEndianLayout<uint32_t>
 
using uint24_le_t = internal::LittleEndianLayout<uint24_t>
 
using uint16_le_t = internal::LittleEndianLayout<uint16_t>
 
using int64_le_t = internal::LittleEndianLayout<int64_t>
 
using int32_le_t = internal::LittleEndianLayout<int32_t>
 
using int24_le_t = internal::LittleEndianLayout<int24_t>
 
using int16_le_t = internal::LittleEndianLayout<int16_t>
 

Enumerations

enum class  RetryResult { DONE , RETRY }
 
enum  EntityCategory : uint8_t { ENTITY_CATEGORY_NONE = 0 , ENTITY_CATEGORY_CONFIG = 1 , ENTITY_CATEGORY_DIAGNOSTIC = 2 }
 

Functions

void IRAM_ATTR HOT yield ()
 
uint32_t IRAM_ATTR HOT millis ()
 
void IRAM_ATTR HOT delay (uint32_t ms)
 
uint32_t IRAM_ATTR HOT micros ()
 
void IRAM_ATTR HOT delayMicroseconds (uint32_t us)
 
void arch_restart ()
 
void arch_init ()
 
void IRAM_ATTR HOT arch_feed_wdt ()
 
uint8_t progmem_read_byte (const uint8_t *addr)
 
uint32_t arch_get_cpu_cycle_count ()
 
uint32_t arch_get_cpu_freq_hz ()
 
void loop_task (void *pv_params)
 
void app_main ()
 
void force_link_symbols ()
 
void resetPins ()
 
template<int... >
struct ESPDEPRECATED ("Use std::index_sequence instead. Removed in 2026.6.0", "2025.12.0") seq
 
void log_update_interval (const char *tag, PollingComponent *component)
 
void clear_setup_priority_overrides ()
 
struct esphome::uint24_t __attribute__ ((packed))
 
void __attribute__ ((noreturn)) arch_restart()
 
template<int(*)(int) fn>
std::string str_ctype_transform (const std::string &str)
 
std::string str_snprintf (const char *fmt, size_t len,...)
 
std::string str_sprintf (const char *fmt,...)
 
std::string format_mac_address_pretty (const uint8_t *mac)
 
void HOT esp_log_printf_ (int level, const char *tag, int line, const char *format,...)
 
void HOT esp_log_printf_ (int level, const char *tag, int line, const __FlashStringHelper *format,...)
 
void HOT esp_log_vprintf_ (int level, const char *tag, int line, const char *format, va_list args)
 
void HOT esp_log_vprintf_ (int level, const char *tag, int line, const __FlashStringHelper *format, va_list args)
 
int HOT esp_idf_log_vprintf_ (const char *format, va_list args)
 
const nullopt_t nullopt ((nullopt_t::init()))
 
template<typename T , typename U >
bool operator== (optional< T > const &x, optional< U > const &y)
 
template<typename T , typename U >
bool operator!= (optional< T > const &x, optional< U > const &y)
 
template<typename T , typename U >
bool operator< (optional< T > const &x, optional< U > const &y)
 
template<typename T , typename U >
bool operator> (optional< T > const &x, optional< U > const &y)
 
template<typename T , typename U >
bool operator<= (optional< T > const &x, optional< U > const &y)
 
template<typename T , typename U >
bool operator>= (optional< T > const &x, optional< U > const &y)
 
template<typename T >
bool operator== (optional< T > const &x, nullopt_t)
 
template<typename T >
bool operator== (nullopt_t, optional< T > const &x)
 
template<typename T >
bool operator!= (optional< T > const &x, nullopt_t)
 
template<typename T >
bool operator!= (nullopt_t, optional< T > const &x)
 
template<typename T >
bool operator< (optional< T > const &, nullopt_t)
 
template<typename T >
bool operator< (nullopt_t, optional< T > const &x)
 
template<typename T >
bool operator<= (optional< T > const &x, nullopt_t)
 
template<typename T >
bool operator<= (nullopt_t, optional< T > const &)
 
template<typename T >
bool operator> (optional< T > const &x, nullopt_t)
 
template<typename T >
bool operator> (nullopt_t, optional< T > const &)
 
template<typename T >
bool operator>= (optional< T > const &, nullopt_t)
 
template<typename T >
bool operator>= (nullopt_t, optional< T > const &x)
 
template<typename T , typename U >
bool operator== (optional< T > const &x, U const &v)
 
template<typename T , typename U >
bool operator== (U const &v, optional< T > const &x)
 
template<typename T , typename U >
bool operator!= (optional< T > const &x, U const &v)
 
template<typename T , typename U >
bool operator!= (U const &v, optional< T > const &x)
 
template<typename T , typename U >
bool operator< (optional< T > const &x, U const &v)
 
template<typename T , typename U >
bool operator< (U const &v, optional< T > const &x)
 
template<typename T , typename U >
bool operator<= (optional< T > const &x, U const &v)
 
template<typename T , typename U >
bool operator<= (U const &v, optional< T > const &x)
 
template<typename T , typename U >
bool operator> (optional< T > const &x, U const &v)
 
template<typename T , typename U >
bool operator> (U const &v, optional< T > const &x)
 
template<typename T , typename U >
bool operator>= (optional< T > const &x, U const &v)
 
template<typename T , typename U >
bool operator>= (U const &v, optional< T > const &x)
 
template<typename T >
void swap (optional< T > &x, optional< T > &y) noexcept
 
template<typename T >
optional< T > make_optional (T const &v)
 
void retry_handler (const std::shared_ptr< RetryArgs > &args)
 
bool operator== (const StringRef &lhs, const StringRef &rhs)
 
bool operator== (const StringRef &lhs, const std::string &rhs)
 
bool operator== (const std::string &lhs, const StringRef &rhs)
 
bool operator== (const StringRef &lhs, const char *rhs)
 
bool operator== (const char *lhs, const StringRef &rhs)
 
bool operator!= (const StringRef &lhs, const StringRef &rhs)
 
bool operator!= (const StringRef &lhs, const std::string &rhs)
 
bool operator!= (const std::string &lhs, const StringRef &rhs)
 
bool operator!= (const StringRef &lhs, const char *rhs)
 
bool operator!= (const char *lhs, const StringRef &rhs)
 
bool operator< (const StringRef &lhs, const StringRef &rhs)
 
std::string & operator+= (std::string &lhs, const StringRef &rhs)
 
std::string operator+ (const char *lhs, const StringRef &rhs)
 
std::string operator+ (const StringRef &lhs, const char *rhs)
 
std::string operator+ (const StringRef &lhs, const std::string &rhs)
 
std::string operator+ (const std::string &lhs, const StringRef &rhs)
 
void convertToJson (const StringRef &src, JsonVariant dst)
 
uint8_t days_in_month (uint8_t month, uint16_t year)
 
template<typename T >
bool increment_time_value (T &current, uint16_t begin, uint16_t end)
 
bool api_is_connected ()
 Return whether the node has at least one client connected to the native API.
 
bool mqtt_is_connected ()
 Return whether the node has an active connection to an MQTT broker.
 
bool remote_is_connected ()
 Return whether the node has any form of "remote" connection via the API or to an MQTT broker.
 
System APIs
void get_mac_address_raw (uint8_t *mac)
 Get the device MAC address as raw bytes, written into the provided byte array (6 bytes).
 
void set_mac_address (uint8_t *mac)
 Set the MAC address to use from the provided byte array (6 bytes).
 
bool has_custom_mac_address ()
 Check if a custom MAC address is set (ESP32 & variants)
 
std::string get_mac_address ()
 Get the device MAC address as a string, in lowercase hex notation.
 
std::string get_mac_address_pretty ()
 Get the device MAC address as a string, in colon-separated uppercase hex notation.
 
void get_mac_address_into_buffer (std::span< char, MAC_ADDRESS_BUFFER_SIZE > buf)
 Get the device MAC address into the given buffer, in lowercase hex notation.
 
const char * get_mac_address_pretty_into_buffer (std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
 Get the device MAC address into the given buffer, in colon-separated uppercase hex notation.
 
bool mac_address_is_valid (const uint8_t *mac)
 Check if the MAC address is not all zeros or all ones.
 
void IRAM_ATTR HOT delay_microseconds_safe (uint32_t us)
 Delay for the given amount of microseconds, possibly yielding to other processes during the wait.
 
Colors
float gamma_correct (float value, float gamma)
 Applies gamma correction of gamma to value.
 
float gamma_uncorrect (float value, float gamma)
 Reverts gamma correction of gamma to value.
 
void rgb_to_hsv (float red, float green, float blue, int &hue, float &saturation, float &value)
 Convert red, green and blue (all 0-1) values to hue (0-360), saturation (0-1) and value (0-1).
 
void hsv_to_rgb (int hue, float saturation, float value, float &red, float &green, float &blue)
 Convert hue (0-360), saturation (0-1) and value (0-1) to red, green and blue (all 0-1).
 
STL backports
template<typename To , typename From , enable_if_t< sizeof(To)==sizeof(From) &&is_trivially_copyable< From >::value &&is_trivially_copyable< To >::value, int > = 0>
To bit_cast (const From &src)
 Convert data between types, without aliasing issues or undefined behaviour.
 
float lerp (float completion, float start, float end)=delete
 
template<typename T >
constexpr T byteswap (T n)
 
template<>
constexpr uint8_t byteswap (uint8_t n)
 
template<>
uint16_t byteswap (uint16_t n)
 
template<>
uint32_t byteswap (uint32_t n)
 
template<>
uint64_t byteswap (uint64_t n)
 
template<>
int8_t byteswap (int8_t n)
 
template<>
int16_t byteswap (int16_t n)
 
template<>
int32_t byteswap (int32_t n)
 
template<>
int64_t byteswap (int64_t n)
 
template<>
constexpr uint16_t byteswap (uint16_t n)
 
template<>
constexpr uint32_t byteswap (uint32_t n)
 
template<>
constexpr uint64_t byteswap (uint64_t n)
 
template<>
constexpr int8_t byteswap (int8_t n)
 
template<>
constexpr int16_t byteswap (int16_t n)
 
template<>
constexpr int32_t byteswap (int32_t n)
 
template<>
constexpr int64_t byteswap (int64_t n)
 
Bit manipulation
constexpr uint16_t encode_uint16 (uint8_t msb, uint8_t lsb)
 Encode a 16-bit value given the most and least significant byte.
 
constexpr uint32_t encode_uint24 (uint8_t byte1, uint8_t byte2, uint8_t byte3)
 Encode a 24-bit value given three bytes in most to least significant byte order.
 
constexpr uint32_t encode_uint32 (uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
 Encode a 32-bit value given four bytes in most to least significant byte order.
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
constexpr T encode_value (const uint8_t *bytes)
 Encode a value from its constituent bytes (from most to least significant) in an array with length sizeof(T).
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
constexpr T encode_value (const std::array< uint8_t, sizeof(T)> bytes)
 Encode a value from its constituent bytes (from most to least significant) in an std::array with length sizeof(T).
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
constexpr std::array< uint8_t, sizeof(T)> decode_value (T val)
 Decode a value into its constituent bytes (from most to least significant).
 
uint8_t reverse_bits (uint8_t x)
 Reverse the order of 8 bits.
 
uint16_t reverse_bits (uint16_t x)
 Reverse the order of 16 bits.
 
uint32_t reverse_bits (uint32_t x)
 Reverse the order of 32 bits.
 
template<typename T >
constexpr T convert_big_endian (T val)
 Convert a value between host byte order and big endian (most significant byte first) order.
 
template<typename T >
constexpr T convert_little_endian (T val)
 Convert a value between host byte order and little endian (least significant byte first) order.
 
Units
constexpr float celsius_to_fahrenheit (float value)
 Convert degrees Celsius to degrees Fahrenheit.
 
constexpr float fahrenheit_to_celsius (float value)
 Convert degrees Fahrenheit to degrees Celsius.
 
Internal functions
template<typename T , enable_if_t<!std::is_pointer< T >::value, int > = 0>
id (T value)
 Helper function to make id(var) known from lambdas work in custom components.
 
template<typename T , enable_if_t< std::is_pointer< T * >::value, int > = 0>
T & id (T *value)
 Helper function to make id(var) known from lambdas work in custom components.
 

Variables

TaskHandle_t loop_task_handle = nullptr
 
ESPPreferencesglobal_preferences
 
runtime_stats::RuntimeStatsCollectorglobal_runtime_stats
 
Application App
 Global storage of Application pointer - only one Application can exist.
 
const uint8_t COMPONENT_STATE_MASK = 0x07
 
const uint8_t COMPONENT_STATE_CONSTRUCTION = 0x00
 
const uint8_t COMPONENT_STATE_SETUP = 0x01
 
const uint8_t COMPONENT_STATE_LOOP = 0x02
 
const uint8_t COMPONENT_STATE_FAILED = 0x03
 
const uint8_t COMPONENT_STATE_LOOP_DONE = 0x04
 
const uint8_t STATUS_LED_MASK = 0x18
 
const uint8_t STATUS_LED_OK = 0x00
 
const uint8_t STATUS_LED_WARNING = 0x08
 
const uint8_t STATUS_LED_ERROR = 0x10
 
const uint16_t WARN_IF_BLOCKING_OVER_MS = 50U
 Initial blocking time allowed without warning.
 
const uint16_t WARN_IF_BLOCKING_INCREMENT_MS = 10U
 How long the blocking time must be larger to warn again.
 
uint32_t global_state = 0
 

Parsing & formatting

enum  ParseOnOffState : uint8_t { PARSE_NONE = 0 , PARSE_ON , PARSE_OFF , PARSE_TOGGLE }
 Return values for parse_on_off(). More...
 
size_t parse_hex (const char *str, size_t len, uint8_t *data, size_t count)
 Parse bytes from a hex-encoded string into a byte array.
 
char * format_hex_to (char *buffer, size_t buffer_size, const uint8_t *data, size_t length)
 Format byte array as lowercase hex to buffer (base implementation).
 
std::string format_hex (const uint8_t *data, size_t length)
 Format the byte array data of length len in lowercased hex.
 
std::string format_hex (const std::vector< uint8_t > &data)
 Format the vector data in lowercased hex.
 
char * format_hex_pretty_to (char *buffer, size_t buffer_size, const uint8_t *data, size_t length, char separator=':')
 Format byte array as uppercase hex to buffer (base implementation).
 
std::string format_hex_pretty (const uint8_t *data, size_t length, char separator='.', bool show_length=true)
 Format a byte array in pretty-printed, human-readable hex format.
 
std::string format_hex_pretty (const std::vector< uint8_t > &data, char separator='.', bool show_length=true)
 Format a byte vector in pretty-printed, human-readable hex format.
 
std::string format_hex_pretty (const uint16_t *data, size_t length, char separator='.', bool show_length=true)
 Format a 16-bit word array in pretty-printed, human-readable hex format.
 
std::string format_hex_pretty (const std::vector< uint16_t > &data, char separator='.', bool show_length=true)
 Format a 16-bit word vector in pretty-printed, human-readable hex format.
 
std::string format_hex_pretty (const std::string &data, char separator='.', bool show_length=true)
 Format a string's bytes in pretty-printed, human-readable hex format.
 
std::string format_bin (const uint8_t *data, size_t length)
 Format the byte array data of length len in binary.
 
ParseOnOffState parse_on_off (const char *str, const char *on=nullptr, const char *off=nullptr)
 Parse a string that contains either on, off or toggle.
 
std::string value_accuracy_to_string (float value, int8_t accuracy_decimals)
 Create a string from a value and an accuracy in decimals.
 
size_t value_accuracy_to_buf (std::span< char, VALUE_ACCURACY_MAX_LEN > buf, float value, int8_t accuracy_decimals)
 Format value with accuracy to buffer, returns chars written (excluding null)
 
size_t value_accuracy_with_uom_to_buf (std::span< char, VALUE_ACCURACY_MAX_LEN > buf, float value, int8_t accuracy_decimals, StringRef unit_of_measurement)
 Format value with accuracy and UOM to buffer, returns chars written (excluding null)
 
int8_t step_to_accuracy_decimals (float step)
 Derive accuracy in decimals from an increment step.
 
std::string base64_encode (const std::vector< uint8_t > &buf)
 
std::string base64_encode (const uint8_t *buf, size_t buf_len)
 
size_t base64_decode (const std::string &encoded_string, uint8_t *buf, size_t buf_len)
 
size_t base64_decode (const uint8_t *encoded_data, size_t encoded_len, uint8_t *buf, size_t buf_len)
 
std::vector< uint8_t > base64_decode (const std::string &encoded_string)
 
template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_unsigned< T >::value), int > = 0>
optional< T > parse_number (const char *str)
 Parse an unsigned decimal number from a null-terminated string.
 
template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_unsigned< T >::value), int > = 0>
optional< T > parse_number (const std::string &str)
 Parse an unsigned decimal number.
 
bool parse_hex (const char *str, uint8_t *data, size_t count)
 Parse count bytes from the hex-encoded string str of at least 2*count characters into array data.
 
bool parse_hex (const std::string &str, uint8_t *data, size_t count)
 Parse count bytes from the hex-encoded string str of at least 2*count characters into array data.
 
bool parse_hex (const char *str, std::vector< uint8_t > &data, size_t count)
 Parse count bytes from the hex-encoded string str of at least 2*count characters into vector data.
 
bool parse_hex (const std::string &str, std::vector< uint8_t > &data, size_t count)
 Parse count bytes from the hex-encoded string str of at least 2*count characters into vector data.
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
optional< T > parse_hex (const char *str, size_t len)
 Parse a hex-encoded string into an unsigned integer.
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
optional< T > parse_hex (const char *str)
 Parse a hex-encoded null-terminated string (starting with the most significant byte) into an unsigned integer.
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
optional< T > parse_hex (const std::string &str)
 Parse a hex-encoded null-terminated string (starting with the most significant byte) into an unsigned integer.
 
constexpr uint8_t parse_hex_char (char c)
 Parse a hex character to its nibble value (0-15), returns 255 on invalid input.
 
char format_hex_char (uint8_t v, char base)
 Convert a nibble (0-15) to hex char with specified base ('a' for lowercase, 'A' for uppercase)
 
char format_hex_char (uint8_t v)
 Convert a nibble (0-15) to lowercase hex char.
 
char format_hex_pretty_char (uint8_t v)
 Convert a nibble (0-15) to uppercase hex char (used for pretty printing)
 
char * int8_to_str (char *buf, int8_t val)
 Write int8 value to buffer without modulo operations.
 
template<size_t N>
char * format_hex_to (char(&buffer)[N], const uint8_t *data, size_t length)
 Format byte array as lowercase hex to buffer.
 
template<size_t N, typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
char * format_hex_to (char(&buffer)[N], T val)
 Format an unsigned integer in lowercased hex to buffer, starting with the most significant byte.
 
constexpr size_t format_hex_pretty_size (size_t byte_count)
 Calculate buffer size needed for format_hex_pretty_to with separator: "XX:XX:...:XX\0".
 
template<size_t N>
char * format_hex_pretty_to (char(&buffer)[N], const uint8_t *data, size_t length, char separator=':')
 Format byte array as uppercase hex with separator to buffer. Automatically deduces buffer size.
 
void format_mac_addr_upper (const uint8_t *mac, char *output)
 Format MAC address as XX:XX:XX:XX:XX:XX (uppercase, colon separators)
 
void format_mac_addr_lower_no_sep (const uint8_t *mac, char *output)
 Format MAC address as xxxxxxxxxxxxxx (lowercase, no separators)
 
std::string format_mac_address_pretty (const uint8_t mac[6])
 Format the six-byte array mac into a MAC address.
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string format_hex (T val)
 Format an unsigned integer in lowercased hex, starting with the most significant byte.
 
template<std::size_t N>
std::string format_hex (const std::array< uint8_t, N > &data)
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string format_hex_pretty (T val, char separator='.', bool show_length=true)
 Format an unsigned integer in pretty-printed, human-readable hex format.
 
template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string format_bin (T val)
 Format an unsigned integer in binary, starting with the most significant byte.
 

Memory management

template<class T >
using ExternalRAMAllocator = RAMAllocator<T>
 
template<std::totally_ordered T, comparable_with< T > U>
clamp_at_least (T value, U min)
 
template<std::totally_ordered T, comparable_with< T > U>
clamp_at_most (T value, U max)
 

Mathematics

constexpr uint32_t FNV1_OFFSET_BASIS = 2166136261UL
 FNV-1 32-bit offset basis.
 
constexpr uint32_t FNV1_PRIME = 16777619UL
 FNV-1 32-bit prime.
 
uint32_t random_uint32 ()
 Return a random 32-bit unsigned integer.
 
bool random_bytes (uint8_t *data, size_t len)
 Generate len number of random bytes.
 
uint8_t crc8 (const uint8_t *data, uint8_t len, uint8_t crc=0x00, uint8_t poly=0x8C, bool msb_first=false)
 Calculate a CRC-8 checksum of data with size len.
 
uint16_t crc16 (const uint8_t *data, uint16_t len, uint16_t crc=0xffff, uint16_t reverse_poly=0xa001, bool refin=false, bool refout=false)
 Calculate a CRC-16 checksum of data with size len.
 
uint16_t crc16be (const uint8_t *data, uint16_t len, uint16_t crc, uint16_t poly, bool refin, bool refout)
 
uint32_t fnv1_hash (const char *str)
 Calculate a FNV-1 hash of str.
 
float random_float ()
 Return a random float between 0 and 1.
 
template<typename T , typename U >
remap (U value, U min, U max, T min_out, T max_out)
 Remap value from the range (min, max) to (min_out, max_out).
 
uint32_t fnv1_hash (const std::string &str)
 
constexpr uint32_t fnv1a_hash_extend (uint32_t hash, const char *str)
 Extend a FNV-1a hash with additional string data.
 
uint32_t fnv1a_hash_extend (uint32_t hash, const std::string &str)
 
constexpr uint32_t fnv1a_hash (const char *str)
 Calculate a FNV-1a hash of str.
 
uint32_t fnv1a_hash (const std::string &str)
 

Strings

std::string size_t len
 
bool str_equals_case_insensitive (const std::string &a, const std::string &b)
 Compare strings for equality in case-insensitive manner.
 
bool str_startswith (const std::string &str, const std::string &start)
 Check whether a string starts with a value.
 
bool str_endswith (const std::string &str, const std::string &end)
 Check whether a string ends with a value.
 
std::string str_truncate (const std::string &str, size_t length)
 Truncate a string to a specific length.
 
std::string str_until (const char *str, char ch)
 Extract the part of the string until either the first occurrence of the specified character, or the end (requires str to be null-terminated).
 
std::string str_until (const std::string &str, char ch)
 Extract the part of the string until either the first occurrence of the specified character, or the end.
 
std::string str_lower_case (const std::string &str)
 Convert the string to lower case.
 
std::string str_upper_case (const std::string &str)
 Convert the string to upper case.
 
std::string str_snake_case (const std::string &str)
 Convert the string to snake case (lowercase with underscores).
 
std::string str_sanitize (const std::string &str)
 Sanitizes the input string by removing all characters but alphanumerics, dashes and underscores.
 
size_t make_name_with_suffix_to (char *buffer, size_t buffer_size, const char *name, size_t name_len, char sep, const char *suffix_ptr, size_t suffix_len)
 Zero-allocation version: format name + separator + suffix directly into buffer.
 
std::string make_name_with_suffix (const char *name, size_t name_len, char sep, const char *suffix_ptr, size_t suffix_len)
 Optimized string concatenation: name + separator + suffix (const char* overload) Uses a fixed stack buffer to avoid heap allocations.
 
std::string make_name_with_suffix (const std::string &name, char sep, const char *suffix_ptr, size_t suffix_len)
 Concatenate a name with a separator and suffix using an efficient stack-based approach.
 
constexpr char to_snake_case_char (char c)
 Convert a single char to snake_case: lowercase and space to underscore.
 
constexpr char to_sanitized_char (char c)
 Sanitize a single char: keep alphanumerics, dashes, underscores; replace others with underscore.
 
std::string __attribute__ ((format(printf, 1, 3))) str_snprintf(const char *fmt
 snprintf-like function returning std::string of maximum length len (excluding null terminator).
 
std::string size_t std::string __attribute__ ((format(printf, 1, 2))) str_sprintf(const char *fmt
 sprintf-like function returning std::string.
 

Detailed Description

Providing packet encoding functions for exchanging data with a remote host.

When the TEST_COMPONENT flag is defined we include some auto-test methods.

This file implements the UART protocol spoken over the on-board Micro-USB (Type B) connector of Tormatic and Novoferm gates manufactured as of 2016.

Author: Gustavo Ambrozio Based on work by: Atsushi Sasaki (https://github.com/aselectroworks/Arduino-FT6336U)

A transport is required to send the data; this is provided by a child class. The child class should implement the virtual functions send_packet_ and get_max_packet_size_. On receipt of a data packet, it should call this->process_() with the data.

All communication is initiated by the component. The unit doesn't send data without being asked first.

There are two main message types: status requests and commands.

Querying the gate's status:

| sequence | length | type | payload | | 0xF3 0xCB | 0x00 0x00 0x00 0x06 | 0x01 0x04 | 0x00 0x0A 0x00 0x01 | | 0xF3 0xCB | 0x00 0x00 0x00 0x05 | 0x01 0x04 | 0x02 0x03 0x00 |

This request asks for the gate status (0x0A); the only other value observed in the request was 0x0B, but replies were always zero. Presumably this queries another sensor on the unit like a safety breaker, but this is not relevant for an esphome cover component.

The second byte of the reply is set to 0x03 when the gate is in fully open position. Other valid values for the second byte are: (0x0) Paused, (0x1) Closed, (0x2) Ventilating, (0x3) Opened, (0x4) Opening, (0x5) Closing. The meaning of the other bytes is currently unknown and ignored by the component.

Controlling the gate:

| sequence | length | type | payload | | 0x40 0xFF | 0x00 0x00 0x00 0x06 | 0x01 0x06 | 0x00 0x0A 0x00 0x03 | | 0x40 0xFF | 0x00 0x00 0x00 0x06 | 0x01 0x06 | 0x00 0x0A 0x00 0x03 |

The unit acks any commands by echoing back the message in full. However, this does not mean the gate has started closing. The component only considers status replies as authoritative and simply fires off commands, ignoring the echoed messages.

The payload structure is as follows: [0x00, 0x0A] (gate), followed by one of the states normally carried in status replies: (0x0) Pause, (0x1) Close, (0x2) Ventilate (open ~20%), (0x3) Open/high-torque reverse. The protocol implementation in this file simply reuses the GateStatus enum for this purpose.

Used to test the software during development but can also be used in situ to test if the component is working correctly. For release we do not set it by default but you can set it by using the following lines in you configuration file:

platformio_options:
build_flags:
- -DTEST_COMPONENT
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7

Typedef Documentation

◆ ExternalRAMAllocator

template<class T >
using esphome::ExternalRAMAllocator = RAMAllocator<T>

Definition at line 1375 of file helpers.h.

◆ int16_be_t

Definition at line 51 of file datatypes.h.

◆ int16_le_t

Definition at line 59 of file datatypes.h.

◆ int24_be_t

Definition at line 50 of file datatypes.h.

◆ int24_le_t

◆ int32_be_t

Definition at line 49 of file datatypes.h.

◆ int32_le_t

Definition at line 57 of file datatypes.h.

◆ int64_be_t

Definition at line 48 of file datatypes.h.

◆ int64_le_t

Definition at line 56 of file datatypes.h.

◆ uint16_be_t

Definition at line 47 of file datatypes.h.

◆ uint16_le_t

Definition at line 55 of file datatypes.h.

◆ uint24_be_t

◆ uint24_le_t

◆ uint32_be_t

Definition at line 45 of file datatypes.h.

◆ uint32_le_t

Definition at line 53 of file datatypes.h.

◆ uint64_be_t

Definition at line 44 of file datatypes.h.

◆ uint64_le_t

Definition at line 52 of file datatypes.h.

Enumeration Type Documentation

◆ EntityCategory

enum esphome::EntityCategory : uint8_t
Enumerator
ENTITY_CATEGORY_NONE 
ENTITY_CATEGORY_CONFIG 
ENTITY_CATEGORY_DIAGNOSTIC 

Definition at line 19 of file entity_base.h.

◆ ParseOnOffState

enum esphome::ParseOnOffState : uint8_t

Return values for parse_on_off().

Enumerator
PARSE_NONE 
PARSE_ON 
PARSE_OFF 
PARSE_TOGGLE 

Definition at line 940 of file helpers.h.

◆ RetryResult

enum class esphome::RetryResult
strong
Enumerator
DONE 
RETRY 

Definition at line 71 of file component.h.

Function Documentation

◆ __attribute__() [1/4]

std::string size_t std::string esphome::__attribute__ ( (format(printf, 1, 2)) ) const

sprintf-like function returning std::string.

◆ __attribute__() [2/4]

std::string esphome::__attribute__ ( (format(printf, 1, 3)) ) const

snprintf-like function returning std::string of maximum length len (excluding null terminator).

◆ __attribute__() [3/4]

void esphome::__attribute__ ( (noreturn) )

◆ __attribute__() [4/4]

struct esphome::int24_t esphome::__attribute__ ( (packed) )

◆ api_is_connected()

bool esphome::api_is_connected ( )

Return whether the node has at least one client connected to the native API.

Definition at line 17 of file util.cpp.

◆ app_main()

void esphome::app_main ( )

Definition at line 66 of file core.cpp.

◆ arch_feed_wdt()

void esphome::arch_feed_wdt ( )

Definition at line 47 of file core.cpp.

◆ arch_get_cpu_cycle_count()

uint32_t esphome::arch_get_cpu_cycle_count ( )

Definition at line 50 of file core.cpp.

◆ arch_get_cpu_freq_hz()

uint32_t esphome::arch_get_cpu_freq_hz ( )

Definition at line 51 of file core.cpp.

◆ arch_init()

void esphome::arch_init ( )

Definition at line 37 of file core.cpp.

◆ arch_restart()

void esphome::arch_restart ( )

Definition at line 29 of file core.cpp.

◆ base64_decode() [1/3]

std::vector< uint8_t > esphome::base64_decode ( const std::string & encoded_string)

Definition at line 584 of file helpers.cpp.

◆ base64_decode() [2/3]

size_t esphome::base64_decode ( const std::string & encoded_string,
uint8_t * buf,
size_t buf_len )

Definition at line 519 of file helpers.cpp.

◆ base64_decode() [3/3]

size_t esphome::base64_decode ( const uint8_t * encoded_data,
size_t encoded_len,
uint8_t * buf,
size_t buf_len )

Definition at line 523 of file helpers.cpp.

◆ base64_encode() [1/2]

std::string esphome::base64_encode ( const std::vector< uint8_t > & buf)

Definition at line 477 of file helpers.cpp.

◆ base64_encode() [2/2]

std::string esphome::base64_encode ( const uint8_t * buf,
size_t buf_len )

Definition at line 479 of file helpers.cpp.

◆ bit_cast()

template<typename To , typename From , enable_if_t< sizeof(To)==sizeof(From) &&is_trivially_copyable< From >::value &&is_trivially_copyable< To >::value, int > = 0>
To esphome::bit_cast ( const From & src)

Convert data between types, without aliasing issues or undefined behaviour.

Definition at line 71 of file helpers.h.

◆ byteswap() [1/16]

template<>
int16_t esphome::byteswap ( int16_t n)
inline

Definition at line 96 of file helpers.h.

◆ byteswap() [2/16]

template<>
int16_t esphome::byteswap ( int16_t n)
constexpr

Definition at line 104 of file helpers.h.

◆ byteswap() [3/16]

template<>
int32_t esphome::byteswap ( int32_t n)
inline

Definition at line 97 of file helpers.h.

◆ byteswap() [4/16]

template<>
int32_t esphome::byteswap ( int32_t n)
constexpr

Definition at line 105 of file helpers.h.

◆ byteswap() [5/16]

template<>
int64_t esphome::byteswap ( int64_t n)
inline

Definition at line 98 of file helpers.h.

◆ byteswap() [6/16]

template<>
int64_t esphome::byteswap ( int64_t n)
constexpr

Definition at line 106 of file helpers.h.

◆ byteswap() [7/16]

template<>
int8_t esphome::byteswap ( int8_t n)
inline

Definition at line 95 of file helpers.h.

◆ byteswap() [8/16]

template<>
int8_t esphome::byteswap ( int8_t n)
constexpr

Definition at line 103 of file helpers.h.

◆ byteswap() [9/16]

template<typename T >
T esphome::byteswap ( T n)
constexpr

Definition at line 83 of file helpers.h.

◆ byteswap() [10/16]

template<>
uint16_t esphome::byteswap ( uint16_t n)
inline

Definition at line 92 of file helpers.h.

◆ byteswap() [11/16]

template<>
uint16_t esphome::byteswap ( uint16_t n)
constexpr

Definition at line 100 of file helpers.h.

◆ byteswap() [12/16]

template<>
uint32_t esphome::byteswap ( uint32_t n)
inline

Definition at line 93 of file helpers.h.

◆ byteswap() [13/16]

template<>
uint32_t esphome::byteswap ( uint32_t n)
constexpr

Definition at line 101 of file helpers.h.

◆ byteswap() [14/16]

template<>
uint64_t esphome::byteswap ( uint64_t n)
inline

Definition at line 94 of file helpers.h.

◆ byteswap() [15/16]

template<>
uint64_t esphome::byteswap ( uint64_t n)
constexpr

Definition at line 102 of file helpers.h.

◆ byteswap() [16/16]

template<>
uint8_t esphome::byteswap ( uint8_t n)
constexpr

Definition at line 89 of file helpers.h.

◆ celsius_to_fahrenheit()

float esphome::celsius_to_fahrenheit ( float value)
constexpr

Convert degrees Celsius to degrees Fahrenheit.

Definition at line 992 of file helpers.h.

◆ clamp_at_least()

template<std::totally_ordered T, comparable_with< T > U>
T esphome::clamp_at_least ( T value,
U min )

Definition at line 1387 of file helpers.h.

◆ clamp_at_most()

template<std::totally_ordered T, comparable_with< T > U>
T esphome::clamp_at_most ( T value,
U max )

Definition at line 1392 of file helpers.h.

◆ clear_setup_priority_overrides()

void esphome::clear_setup_priority_overrides ( )

Definition at line 501 of file component.cpp.

◆ convert_big_endian()

template<typename T >
T esphome::convert_big_endian ( T val)
constexpr

Convert a value between host byte order and big endian (most significant byte first) order.

Definition at line 476 of file helpers.h.

◆ convert_little_endian()

template<typename T >
T esphome::convert_little_endian ( T val)
constexpr

Convert a value between host byte order and little endian (least significant byte first) order.

Definition at line 485 of file helpers.h.

◆ convertToJson()

void esphome::convertToJson ( const StringRef & src,
JsonVariant dst )
inline

Definition at line 144 of file string_ref.h.

◆ crc16()

uint16_t esphome::crc16 ( const uint8_t * data,
uint16_t len,
uint16_t crc,
uint16_t reverse_poly,
bool refin,
bool refout )

Calculate a CRC-16 checksum of data with size len.

Definition at line 72 of file helpers.cpp.

◆ crc16be()

uint16_t esphome::crc16be ( const uint8_t * data,
uint16_t len,
uint16_t crc,
uint16_t poly,
bool refin,
bool refout )

Definition at line 112 of file helpers.cpp.

◆ crc8()

uint8_t esphome::crc8 ( const uint8_t * data,
uint8_t len,
uint8_t crc,
uint8_t poly,
bool msb_first )

Calculate a CRC-8 checksum of data with size len.

Definition at line 45 of file helpers.cpp.

◆ days_in_month()

uint8_t esphome::days_in_month ( uint8_t month,
uint16_t year )

Definition at line 8 of file time.cpp.

◆ decode_value()

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::array< uint8_t, sizeof(T)> esphome::decode_value ( T val)
constexpr

Decode a value into its constituent bytes (from most to least significant).

Definition at line 449 of file helpers.h.

◆ delay()

void esphome::delay ( uint32_t ms)

Definition at line 26 of file core.cpp.

◆ delay_microseconds_safe()

void esphome::delay_microseconds_safe ( uint32_t us)

Delay for the given amount of microseconds, possibly yielding to other processes during the wait.

Definition at line 736 of file helpers.cpp.

◆ delayMicroseconds()

void esphome::delayMicroseconds ( uint32_t us)

Definition at line 28 of file core.cpp.

◆ encode_uint16()

uint16_t esphome::encode_uint16 ( uint8_t msb,
uint8_t lsb )
constexpr

Encode a 16-bit value given the most and least significant byte.

Definition at line 420 of file helpers.h.

◆ encode_uint24()

uint32_t esphome::encode_uint24 ( uint8_t byte1,
uint8_t byte2,
uint8_t byte3 )
constexpr

Encode a 24-bit value given three bytes in most to least significant byte order.

Definition at line 424 of file helpers.h.

◆ encode_uint32()

uint32_t esphome::encode_uint32 ( uint8_t byte1,
uint8_t byte2,
uint8_t byte3,
uint8_t byte4 )
constexpr

Encode a 32-bit value given four bytes in most to least significant byte order.

Definition at line 428 of file helpers.h.

◆ encode_value() [1/2]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
T esphome::encode_value ( const std::array< uint8_t, sizeof(T)> bytes)
constexpr

Encode a value from its constituent bytes (from most to least significant) in an std::array with length sizeof(T).

Definition at line 444 of file helpers.h.

◆ encode_value() [2/2]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
T esphome::encode_value ( const uint8_t * bytes)
constexpr

Encode a value from its constituent bytes (from most to least significant) in an array with length sizeof(T).

Definition at line 434 of file helpers.h.

◆ esp_idf_log_vprintf_()

int esphome::esp_idf_log_vprintf_ ( const char * format,
va_list args )

Definition at line 50 of file log.cpp.

◆ esp_log_printf_() [1/2]

void void esphome::esp_log_printf_ ( int level,
const char * tag,
int line,
const __FlashStringHelper * format,
... )

Definition at line 18 of file log.cpp.

◆ esp_log_printf_() [2/2]

void esphome::esp_log_printf_ ( int level,
const char * tag,
int line,
const char * format,
... )

Definition at line 11 of file log.cpp.

◆ esp_log_vprintf_() [1/2]

void esphome::esp_log_vprintf_ ( int level,
const char * tag,
int line,
const __FlashStringHelper * format,
va_list args )

Definition at line 37 of file log.cpp.

◆ esp_log_vprintf_() [2/2]

void esphome::esp_log_vprintf_ ( int level,
const char * tag,
int line,
const char * format,
va_list args )

Definition at line 26 of file log.cpp.

◆ ESPDEPRECATED()

template<int... >
struct esphome::ESPDEPRECATED ( "Use std::index_sequence instead. Removed in 2026.6.0" ,
"2025.12.0"  )

Definition at line 1 of file automation.h.

◆ fahrenheit_to_celsius()

float esphome::fahrenheit_to_celsius ( float value)
constexpr

Convert degrees Fahrenheit to degrees Celsius.

Definition at line 994 of file helpers.h.

◆ fnv1_hash() [1/2]

uint32_t esphome::fnv1_hash ( const char * str)

Calculate a FNV-1 hash of str.

Note: FNV-1a (fnv1a_hash) is preferred for new code due to better avalanche characteristics.

Definition at line 147 of file helpers.cpp.

◆ fnv1_hash() [2/2]

uint32_t esphome::fnv1_hash ( const std::string & str)
inline

Definition at line 383 of file helpers.h.

◆ fnv1a_hash() [1/2]

uint32_t esphome::fnv1a_hash ( const char * str)
constexpr

Calculate a FNV-1a hash of str.

Definition at line 404 of file helpers.h.

◆ fnv1a_hash() [2/2]

uint32_t esphome::fnv1a_hash ( const std::string & str)
inline

Definition at line 405 of file helpers.h.

◆ fnv1a_hash_extend() [1/2]

uint32_t esphome::fnv1a_hash_extend ( uint32_t hash,
const char * str )
constexpr

Extend a FNV-1a hash with additional string data.

Definition at line 391 of file helpers.h.

◆ fnv1a_hash_extend() [2/2]

uint32_t esphome::fnv1a_hash_extend ( uint32_t hash,
const std::string & str )
inline

Definition at line 400 of file helpers.h.

◆ force_link_symbols()

void esphome::force_link_symbols ( )

Definition at line 38 of file core.cpp.

◆ format_bin() [1/2]

std::string esphome::format_bin ( const uint8_t * data,
size_t length )

Format the byte array data of length len in binary.

Definition at line 380 of file helpers.cpp.

◆ format_bin() [2/2]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string esphome::format_bin ( T val)

Format an unsigned integer in binary, starting with the most significant byte.

Definition at line 934 of file helpers.h.

◆ format_hex() [1/4]

template<std::size_t N>
std::string esphome::format_hex ( const std::array< uint8_t, N > & data)

Definition at line 782 of file helpers.h.

◆ format_hex() [2/4]

std::string esphome::format_hex ( const std::vector< uint8_t > & data)

Format the vector data in lowercased hex.

Definition at line 329 of file helpers.cpp.

◆ format_hex() [3/4]

std::string esphome::format_hex ( const uint8_t * data,
size_t length )

Format the byte array data of length len in lowercased hex.

Definition at line 323 of file helpers.cpp.

◆ format_hex() [4/4]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string esphome::format_hex ( T val)

Format an unsigned integer in lowercased hex, starting with the most significant byte.

Definition at line 778 of file helpers.h.

◆ format_hex_char() [1/2]

char esphome::format_hex_char ( uint8_t v)
inline

Convert a nibble (0-15) to lowercase hex char.

Definition at line 684 of file helpers.h.

◆ format_hex_char() [2/2]

char esphome::format_hex_char ( uint8_t v,
char base )
inline

Convert a nibble (0-15) to hex char with specified base ('a' for lowercase, 'A' for uppercase)

Definition at line 681 of file helpers.h.

◆ format_hex_pretty() [1/6]

std::string esphome::format_hex_pretty ( const std::string & data,
char separator = '.',
bool show_length = true )

Format a string's bytes in pretty-printed, human-readable hex format.

Treats each character in the string as a byte and formats it in hex. Useful for debugging binary data stored in std::string containers.

Parameters
dataString whose bytes should be formatted as hex.
separatorCharacter to use between hex bytes (default: '.').
show_lengthWhether to append the byte count in parentheses (default: true).
Returns
Formatted hex string representation of the string's byte contents.
Note
The length will only be appended if show_length is true AND the string length is greater than 4.

Example:

std::string data = "ABC"; // ASCII: 0x41, 0x42, 0x43
format_hex_pretty(data); // Returns "41.42.43" (no length shown for <= 4 parts)
std::string data2 = "ABCDE";
format_hex_pretty(data2); // Returns "41.42.43.44.45 (5)"
std::string format_hex_pretty(const uint8_t *data, size_t length, char separator, bool show_length)
Format a byte array in pretty-printed, human-readable hex format.
Definition helpers.cpp:348

Definition at line 376 of file helpers.cpp.

◆ format_hex_pretty() [2/6]

std::string esphome::format_hex_pretty ( const std::vector< uint16_t > & data,
char separator = '.',
bool show_length = true )

Format a 16-bit word vector in pretty-printed, human-readable hex format.

Convenience overload for std::vector<uint16_t>. Each 16-bit word is formatted as a 4-digit uppercase hex value in big-endian order.

Parameters
dataVector of 16-bit words to format.
separatorCharacter to use between hex words (default: '.').
show_lengthWhether to append the word count in parentheses (default: true).
Returns
Formatted hex string representation of the vector contents.
Note
The length will only be appended if show_length is true AND the vector size is greater than 4.

Example:

std::vector<uint16_t> data = {0x1234, 0x5678};
format_hex_pretty(data); // Returns "1234.5678" (no length shown for <= 4 parts)
std::vector<uint16_t> data2 = {0x1234, 0x5678, 0x9ABC};
format_hex_pretty(data2); // Returns "1234.5678.9ABC (3)"

Definition at line 373 of file helpers.cpp.

◆ format_hex_pretty() [3/6]

std::string esphome::format_hex_pretty ( const std::vector< uint8_t > & data,
char separator = '.',
bool show_length = true )

Format a byte vector in pretty-printed, human-readable hex format.

Convenience overload for std::vector<uint8_t>. Formats each byte as a two-digit uppercase hex value with customizable separator.

Parameters
dataVector of bytes to format.
separatorCharacter to use between hex bytes (default: '.').
show_lengthWhether to append the byte count in parentheses (default: true).
Returns
Formatted hex string representation of the vector contents.
Note
The length will only be appended if show_length is true AND the vector size is greater than 4.

Example:

std::vector<uint8_t> data = {0xDE, 0xAD, 0xBE, 0xEF};
format_hex_pretty(data); // Returns "DE.AD.BE.EF" (no length shown for <= 4 parts)
std::vector<uint8_t> data2 = {0xDE, 0xAD, 0xBE, 0xEF, 0xCA};
format_hex_pretty(data2); // Returns "DE.AD.BE.EF.CA (5)"
format_hex_pretty(data2, '-'); // Returns "DE-AD-BE-EF-CA (5)"

Definition at line 351 of file helpers.cpp.

◆ format_hex_pretty() [4/6]

std::string esphome::format_hex_pretty ( const uint16_t * data,
size_t length,
char separator = '.',
bool show_length = true )

Format a 16-bit word array in pretty-printed, human-readable hex format.

Similar to the byte array version, but formats 16-bit words as 4-digit hex values.

Parameters
dataPointer to the 16-bit word array to format.
lengthNumber of 16-bit words in the array.
separatorCharacter to use between hex words (default: '.').
show_lengthWhether to append the word count in parentheses (default: true).
Returns
Formatted hex string with 4-digit hex values per word.
Note
The length will only be appended if show_length is true AND the length is greater than 4.

Example:

uint16_t data[] = {0xA1B2, 0xC3D4};
format_hex_pretty(data, 2); // Returns "A1B2.C3D4" (no length shown for <= 4 parts)
uint16_t data2[] = {0xA1B2, 0xC3D4, 0xE5F6};
format_hex_pretty(data2, 3); // Returns "A1B2.C3D4.E5F6 (3)"

Definition at line 355 of file helpers.cpp.

◆ format_hex_pretty() [5/6]

std::string esphome::format_hex_pretty ( const uint8_t * data,
size_t length,
char separator = '.',
bool show_length = true )

Format a byte array in pretty-printed, human-readable hex format.

Converts binary data to a hexadecimal string representation with customizable formatting. Each byte is displayed as a two-digit uppercase hex value, separated by the specified separator. Optionally includes the total byte count in parentheses at the end.

Parameters
dataPointer to the byte array to format.
lengthNumber of bytes in the array.
separatorCharacter to use between hex bytes (default: '.').
show_lengthWhether to append the byte count in parentheses (default: true).
Returns
Formatted hex string, e.g., "A1.B2.C3.D4.E5 (5)" or "A1:B2:C3" depending on parameters.
Note
Returns empty string if data is nullptr or length is 0.
The length will only be appended if show_length is true AND the length is greater than 4.

Example:

uint8_t data[] = {0xA1, 0xB2, 0xC3};
format_hex_pretty(data, 3); // Returns "A1.B2.C3" (no length shown for <= 4 parts)
uint8_t data2[] = {0xA1, 0xB2, 0xC3, 0xD4, 0xE5};
format_hex_pretty(data2, 5); // Returns "A1.B2.C3.D4.E5 (5)"
format_hex_pretty(data2, 5, ':'); // Returns "A1:B2:C3:D4:E5 (5)"
format_hex_pretty(data2, 5, '.', false); // Returns "A1.B2.C3.D4.E5"

Definition at line 348 of file helpers.cpp.

◆ format_hex_pretty() [6/6]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
std::string esphome::format_hex_pretty ( T val,
char separator = '.',
bool show_length = true )

Format an unsigned integer in pretty-printed, human-readable hex format.

Converts the integer to big-endian byte order and formats each byte as hex. The most significant byte appears first in the output string.

Template Parameters
TUnsigned integer type (uint8_t, uint16_t, uint32_t, uint64_t, etc.).
Parameters
valThe unsigned integer value to format.
separatorCharacter to use between hex bytes (default: '.').
show_lengthWhether to append the byte count in parentheses (default: true).
Returns
Formatted hex string with most significant byte first.
Note
The length will only be appended if show_length is true AND sizeof(T) is greater than 4.

Example:

uint32_t value = 0x12345678;
format_hex_pretty(value); // Returns "12.34.56.78" (no length shown for <= 4 parts)
uint64_t value2 = 0x123456789ABCDEF0;
format_hex_pretty(value2); // Returns "12.34.56.78.9A.BC.DE.F0 (8)"
format_hex_pretty(value2, ':'); // Returns "12:34:56:78:9A:BC:DE:F0 (8)"
format_hex_pretty<uint16_t>(0x1234); // Returns "12.34"

Definition at line 926 of file helpers.h.

◆ format_hex_pretty_char()

char esphome::format_hex_pretty_char ( uint8_t v)
inline

Convert a nibble (0-15) to uppercase hex char (used for pretty printing)

Definition at line 687 of file helpers.h.

◆ format_hex_pretty_size()

size_t esphome::format_hex_pretty_size ( size_t byte_count)
constexpr

Calculate buffer size needed for format_hex_pretty_to with separator: "XX:XX:...:XX\0".

Definition at line 732 of file helpers.h.

◆ format_hex_pretty_to() [1/2]

char * esphome::format_hex_pretty_to ( char * buffer,
size_t buffer_size,
const uint8_t * data,
size_t length,
char separator = ':' )

Format byte array as uppercase hex to buffer (base implementation).

Parameters
bufferOutput buffer to write to.
buffer_sizeSize of the output buffer.
dataPointer to the byte array to format.
lengthNumber of bytes in the array.
separatorCharacter to use between hex bytes, or '\0' for no separator.
Returns
Pointer to buffer.

Buffer size needed: length * 3 with separator (for "XX:XX:XX\0"), length * 2 + 1 without.

Definition at line 331 of file helpers.cpp.

◆ format_hex_pretty_to() [2/2]

template<size_t N>
char * esphome::format_hex_pretty_to ( char(&) buffer[N],
const uint8_t * data,
size_t length,
char separator = ':' )
inline

Format byte array as uppercase hex with separator to buffer. Automatically deduces buffer size.

Definition at line 749 of file helpers.h.

◆ format_hex_to() [1/3]

char * esphome::format_hex_to ( char * buffer,
size_t buffer_size,
const uint8_t * data,
size_t length )

Format byte array as lowercase hex to buffer (base implementation).

Definition at line 319 of file helpers.cpp.

◆ format_hex_to() [2/3]

template<size_t N>
char * esphome::format_hex_to ( char(&) buffer[N],
const uint8_t * data,
size_t length )
inline

Format byte array as lowercase hex to buffer.

Automatically deduces buffer size. Truncates output if data exceeds buffer capacity. Returns pointer to buffer.

Definition at line 718 of file helpers.h.

◆ format_hex_to() [3/3]

template<size_t N, typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
char * esphome::format_hex_to ( char(&) buffer[N],
T val )
inline

Format an unsigned integer in lowercased hex to buffer, starting with the most significant byte.

Definition at line 725 of file helpers.h.

◆ format_mac_addr_lower_no_sep()

void esphome::format_mac_addr_lower_no_sep ( const uint8_t * mac,
char * output )
inline

Format MAC address as xxxxxxxxxxxxxx (lowercase, no separators)

Definition at line 767 of file helpers.h.

◆ format_mac_addr_upper()

void esphome::format_mac_addr_upper ( const uint8_t * mac,
char * output )
inline

Format MAC address as XX:XX:XX:XX:XX:XX (uppercase, colon separators)

Definition at line 762 of file helpers.h.

◆ format_mac_address_pretty() [1/2]

std::string esphome::format_mac_address_pretty ( const uint8_t * mac)

Definition at line 283 of file helpers.cpp.

◆ format_mac_address_pretty() [2/2]

std::string esphome::format_mac_address_pretty ( const uint8_t mac[6])

Format the six-byte array mac into a MAC address.

◆ gamma_correct()

float esphome::gamma_correct ( float value,
float gamma )

Applies gamma correction of gamma to value.

Definition at line 595 of file helpers.cpp.

◆ gamma_uncorrect()

float esphome::gamma_uncorrect ( float value,
float gamma )

Reverts gamma correction of gamma to value.

Definition at line 603 of file helpers.cpp.

◆ get_mac_address()

std::string esphome::get_mac_address ( )

Get the device MAC address as a string, in lowercase hex notation.

Definition at line 691 of file helpers.cpp.

◆ get_mac_address_into_buffer()

void esphome::get_mac_address_into_buffer ( std::span< char, MAC_ADDRESS_BUFFER_SIZE > buf)

Get the device MAC address into the given buffer, in lowercase hex notation.

Assumes buffer length is MAC_ADDRESS_BUFFER_SIZE (12 digits for hexadecimal representation followed by null terminator).

Definition at line 704 of file helpers.cpp.

◆ get_mac_address_pretty()

std::string esphome::get_mac_address_pretty ( )

Get the device MAC address as a string, in colon-separated uppercase hex notation.

Definition at line 699 of file helpers.cpp.

◆ get_mac_address_pretty_into_buffer()

const char * esphome::get_mac_address_pretty_into_buffer ( std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)

Get the device MAC address into the given buffer, in colon-separated uppercase hex notation.

Buffer must be exactly MAC_ADDRESS_PRETTY_BUFFER_SIZE bytes (17 for "XX:XX:XX:XX:XX:XX" + null terminator). Returns pointer to the buffer for convenience.

Definition at line 710 of file helpers.cpp.

◆ get_mac_address_raw()

void esphome::get_mac_address_raw ( uint8_t * mac)

Get the device MAC address as raw bytes, written into the provided byte array (6 bytes).

Definition at line 73 of file helpers.cpp.

◆ has_custom_mac_address()

bool esphome::has_custom_mac_address ( )

Check if a custom MAC address is set (ESP32 & variants)

Returns
True if a custom MAC address is set (ESP32 & variants), else false

Definition at line 93 of file helpers.cpp.

◆ hsv_to_rgb()

void esphome::hsv_to_rgb ( int hue,
float saturation,
float value,
float & red,
float & green,
float & blue )

Convert hue (0-360), saturation (0-1) and value (0-1) to red, green and blue (all 0-1).

Definition at line 635 of file helpers.cpp.

◆ id() [1/2]

template<typename T , enable_if_t< std::is_pointer< T * >::value, int > = 0>
T & esphome::id ( T * value)

Helper function to make id(var) known from lambdas work in custom components.

This function is not called from lambdas, the code generator replaces calls to it with the appropriate variable.

Definition at line 1410 of file helpers.h.

◆ id() [2/2]

template<typename T , enable_if_t<!std::is_pointer< T >::value, int > = 0>
T esphome::id ( T value)

Helper function to make id(var) known from lambdas work in custom components.

This function is not called from lambdas, the code generator replaces calls to it with the appropriate variable.

Definition at line 1405 of file helpers.h.

◆ increment_time_value()

template<typename T >
bool esphome::increment_time_value ( T & current,
uint16_t begin,
uint16_t end )

Definition at line 215 of file time.cpp.

◆ int8_to_str()

char * esphome::int8_to_str ( char * buf,
int8_t val )
inline

Write int8 value to buffer without modulo operations.

Buffer must have at least 4 bytes free. Returns pointer past last char written.

Definition at line 691 of file helpers.h.

◆ lerp()

float esphome::lerp ( float completion,
float start,
float end )
inlinedelete

◆ log_update_interval()

void esphome::log_update_interval ( const char * tag,
PollingComponent * component )

Definition at line 392 of file component.cpp.

◆ loop_task()

void esphome::loop_task ( void * pv_params)

Definition at line 59 of file core.cpp.

◆ mac_address_is_valid()

bool esphome::mac_address_is_valid ( const uint8_t * mac)

Check if the MAC address is not all zeros or all ones.

Returns
True if MAC is valid, else false

Definition at line 721 of file helpers.cpp.

◆ make_name_with_suffix() [1/2]

std::string esphome::make_name_with_suffix ( const char * name,
size_t name_len,
char sep,
const char * suffix_ptr,
size_t suffix_len )

Optimized string concatenation: name + separator + suffix (const char* overload) Uses a fixed stack buffer to avoid heap allocations.

Parameters
nameThe base name string
name_lenLength of the name
sepSingle character separator
suffix_ptrPointer to the suffix characters
suffix_lenLength of the suffix
Returns
The concatenated string: name + sep + suffix

Definition at line 259 of file helpers.cpp.

◆ make_name_with_suffix() [2/2]

std::string size_t std::string std::string esphome::make_name_with_suffix ( const std::string & name,
char sep,
const char * suffix_ptr,
size_t suffix_len )

Concatenate a name with a separator and suffix using an efficient stack-based approach.

This avoids multiple heap allocations during string construction. Maximum name length supported is 120 characters for friendly names.

Parameters
nameThe base name string
sepThe separator character (e.g., '-', ' ', or '.')
suffix_ptrPointer to the suffix characters
suffix_lenLength of the suffix
Returns
The concatenated string: name + sep + suffix

Definition at line 266 of file helpers.cpp.

◆ make_name_with_suffix_to()

size_t esphome::make_name_with_suffix_to ( char * buffer,
size_t buffer_size,
const char * name,
size_t name_len,
char sep,
const char * suffix_ptr,
size_t suffix_len )

Zero-allocation version: format name + separator + suffix directly into buffer.

Parameters
bufferOutput buffer (must have space for result + null terminator)
buffer_sizeSize of the output buffer
nameThe base name string
name_lenLength of the name
sepSingle character separator
suffix_ptrPointer to the suffix characters
suffix_lenLength of the suffix
Returns
Length written (excluding null terminator)

Definition at line 239 of file helpers.cpp.

◆ make_optional()

template<typename T >
optional< T > esphome::make_optional ( T const & v)
inline

Definition at line 218 of file optional.h.

◆ micros()

uint32_t esphome::micros ( )

Definition at line 27 of file core.cpp.

◆ millis()

uint32_t esphome::millis ( )

Definition at line 25 of file core.cpp.

◆ mqtt_is_connected()

bool esphome::mqtt_is_connected ( )

Return whether the node has an active connection to an MQTT broker.

Definition at line 26 of file util.cpp.

◆ nullopt()

const nullopt_t esphome::nullopt ( (nullopt_t::init()) )

◆ operator!=() [1/10]

bool esphome::operator!= ( const char * lhs,
const StringRef & rhs )
inline

Definition at line 108 of file string_ref.h.

◆ operator!=() [2/10]

bool esphome::operator!= ( const std::string & lhs,
const StringRef & rhs )
inline

Definition at line 104 of file string_ref.h.

◆ operator!=() [3/10]

bool esphome::operator!= ( const StringRef & lhs,
const char * rhs )
inline

Definition at line 106 of file string_ref.h.

◆ operator!=() [4/10]

bool esphome::operator!= ( const StringRef & lhs,
const std::string & rhs )
inline

Definition at line 102 of file string_ref.h.

◆ operator!=() [5/10]

bool esphome::operator!= ( const StringRef & lhs,
const StringRef & rhs )
inline

Definition at line 100 of file string_ref.h.

◆ operator!=() [6/10]

template<typename T >
bool esphome::operator!= ( nullopt_t ,
optional< T > const & x )
inline

Definition at line 144 of file optional.h.

◆ operator!=() [7/10]

template<typename T >
bool esphome::operator!= ( optional< T > const & x,
nullopt_t  )
inline

Definition at line 142 of file optional.h.

◆ operator!=() [8/10]

template<typename T , typename U >
bool esphome::operator!= ( optional< T > const & x,
optional< U > const & y )
inline

Definition at line 122 of file optional.h.

◆ operator!=() [9/10]

template<typename T , typename U >
bool esphome::operator!= ( optional< T > const & x,
U const & v )
inline

Definition at line 172 of file optional.h.

◆ operator!=() [10/10]

template<typename T , typename U >
bool esphome::operator!= ( U const & v,
optional< T > const & x )
inline

Definition at line 176 of file optional.h.

◆ operator+() [1/4]

std::string esphome::operator+ ( const char * lhs,
const StringRef & rhs )
inline

Definition at line 119 of file string_ref.h.

◆ operator+() [2/4]

std::string esphome::operator+ ( const std::string & lhs,
const StringRef & rhs )
inline

Definition at line 137 of file string_ref.h.

◆ operator+() [3/4]

std::string esphome::operator+ ( const StringRef & lhs,
const char * rhs )
inline

Definition at line 125 of file string_ref.h.

◆ operator+() [4/4]

std::string esphome::operator+ ( const StringRef & lhs,
const std::string & rhs )
inline

Definition at line 131 of file string_ref.h.

◆ operator+=()

std::string & esphome::operator+= ( std::string & lhs,
const StringRef & rhs )
inline

Definition at line 114 of file string_ref.h.

◆ operator<() [1/6]

bool esphome::operator< ( const StringRef & lhs,
const StringRef & rhs )
inline

Definition at line 110 of file string_ref.h.

◆ operator<() [2/6]

template<typename T >
bool esphome::operator< ( nullopt_t ,
optional< T > const & x )
inline

Definition at line 148 of file optional.h.

◆ operator<() [3/6]

template<typename T >
bool esphome::operator< ( optional< T > const & ,
nullopt_t  )
inline

Definition at line 146 of file optional.h.

◆ operator<() [4/6]

template<typename T , typename U >
bool esphome::operator< ( optional< T > const & x,
optional< U > const & y )
inline

Definition at line 126 of file optional.h.

◆ operator<() [5/6]

template<typename T , typename U >
bool esphome::operator< ( optional< T > const & x,
U const & v )
inline

Definition at line 180 of file optional.h.

◆ operator<() [6/6]

template<typename T , typename U >
bool esphome::operator< ( U const & v,
optional< T > const & x )
inline

Definition at line 184 of file optional.h.

◆ operator<=() [1/5]

template<typename T >
bool esphome::operator<= ( nullopt_t ,
optional< T > const &  )
inline

Definition at line 152 of file optional.h.

◆ operator<=() [2/5]

template<typename T >
bool esphome::operator<= ( optional< T > const & x,
nullopt_t  )
inline

Definition at line 150 of file optional.h.

◆ operator<=() [3/5]

template<typename T , typename U >
bool esphome::operator<= ( optional< T > const & x,
optional< U > const & y )
inline

Definition at line 132 of file optional.h.

◆ operator<=() [4/5]

template<typename T , typename U >
bool esphome::operator<= ( optional< T > const & x,
U const & v )
inline

Definition at line 188 of file optional.h.

◆ operator<=() [5/5]

template<typename T , typename U >
bool esphome::operator<= ( U const & v,
optional< T > const & x )
inline

Definition at line 192 of file optional.h.

◆ operator==() [1/10]

bool esphome::operator== ( const char * lhs,
const StringRef & rhs )
inline

Definition at line 98 of file string_ref.h.

◆ operator==() [2/10]

bool esphome::operator== ( const std::string & lhs,
const StringRef & rhs )
inline

Definition at line 92 of file string_ref.h.

◆ operator==() [3/10]

bool esphome::operator== ( const StringRef & lhs,
const char * rhs )
inline

Definition at line 94 of file string_ref.h.

◆ operator==() [4/10]

bool esphome::operator== ( const StringRef & lhs,
const std::string & rhs )
inline

Definition at line 88 of file string_ref.h.

◆ operator==() [5/10]

bool esphome::operator== ( const StringRef & lhs,
const StringRef & rhs )
inline

Definition at line 84 of file string_ref.h.

◆ operator==() [6/10]

template<typename T >
bool esphome::operator== ( nullopt_t ,
optional< T > const & x )
inline

Definition at line 140 of file optional.h.

◆ operator==() [7/10]

template<typename T >
bool esphome::operator== ( optional< T > const & x,
nullopt_t  )
inline

Definition at line 138 of file optional.h.

◆ operator==() [8/10]

template<typename T , typename U >
bool esphome::operator== ( optional< T > const & x,
optional< U > const & y )
inline

Definition at line 118 of file optional.h.

◆ operator==() [9/10]

template<typename T , typename U >
bool esphome::operator== ( optional< T > const & x,
U const & v )
inline

Definition at line 164 of file optional.h.

◆ operator==() [10/10]

template<typename T , typename U >
bool esphome::operator== ( U const & v,
optional< T > const & x )
inline

Definition at line 168 of file optional.h.

◆ operator>() [1/5]

template<typename T >
bool esphome::operator> ( nullopt_t ,
optional< T > const &  )
inline

Definition at line 156 of file optional.h.

◆ operator>() [2/5]

template<typename T >
bool esphome::operator> ( optional< T > const & x,
nullopt_t  )
inline

Definition at line 154 of file optional.h.

◆ operator>() [3/5]

template<typename T , typename U >
bool esphome::operator> ( optional< T > const & x,
optional< U > const & y )
inline

Definition at line 130 of file optional.h.

◆ operator>() [4/5]

template<typename T , typename U >
bool esphome::operator> ( optional< T > const & x,
U const & v )
inline

Definition at line 196 of file optional.h.

◆ operator>() [5/5]

template<typename T , typename U >
bool esphome::operator> ( U const & v,
optional< T > const & x )
inline

Definition at line 200 of file optional.h.

◆ operator>=() [1/5]

template<typename T >
bool esphome::operator>= ( nullopt_t ,
optional< T > const & x )
inline

Definition at line 160 of file optional.h.

◆ operator>=() [2/5]

template<typename T >
bool esphome::operator>= ( optional< T > const & ,
nullopt_t  )
inline

Definition at line 158 of file optional.h.

◆ operator>=() [3/5]

template<typename T , typename U >
bool esphome::operator>= ( optional< T > const & x,
optional< U > const & y )
inline

Definition at line 134 of file optional.h.

◆ operator>=() [4/5]

template<typename T , typename U >
bool esphome::operator>= ( optional< T > const & x,
U const & v )
inline

Definition at line 204 of file optional.h.

◆ operator>=() [5/5]

template<typename T , typename U >
bool esphome::operator>= ( U const & v,
optional< T > const & x )
inline

Definition at line 208 of file optional.h.

◆ parse_hex() [1/8]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
optional< T > esphome::parse_hex ( const char * str)

Parse a hex-encoded null-terminated string (starting with the most significant byte) into an unsigned integer.

Definition at line 661 of file helpers.h.

◆ parse_hex() [2/8]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
optional< T > esphome::parse_hex ( const char * str,
size_t len )

Parse a hex-encoded string into an unsigned integer.

Parameters
strString to read from, starting with the most significant byte.
lenLength of str (excluding optional null-terminator), is a limit on the number of characters parsed.

Definition at line 654 of file helpers.h.

◆ parse_hex() [3/8]

size_t esphome::parse_hex ( const char * str,
size_t len,
uint8_t * data,
size_t count )

Parse bytes from a hex-encoded string into a byte array.

When len is less than 2*count, the result is written to the back of data (i.e. this function treats str as if it were padded with zeros at the front).

Parameters
strString to read from.
lenLength of str (excluding optional null-terminator), is a limit on the number of characters parsed.
dataByte array to write to.
countLength of data.
Returns
The number of characters parsed from str.

Definition at line 272 of file helpers.cpp.

◆ parse_hex() [4/8]

bool esphome::parse_hex ( const char * str,
std::vector< uint8_t > & data,
size_t count )
inline

Parse count bytes from the hex-encoded string str of at least 2*count characters into vector data.

Definition at line 639 of file helpers.h.

◆ parse_hex() [5/8]

bool esphome::parse_hex ( const char * str,
uint8_t * data,
size_t count )
inline

Parse count bytes from the hex-encoded string str of at least 2*count characters into array data.

Definition at line 631 of file helpers.h.

◆ parse_hex() [6/8]

template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0>
optional< T > esphome::parse_hex ( const std::string & str)

Parse a hex-encoded null-terminated string (starting with the most significant byte) into an unsigned integer.

Definition at line 665 of file helpers.h.

◆ parse_hex() [7/8]

bool esphome::parse_hex ( const std::string & str,
std::vector< uint8_t > & data,
size_t count )
inline

Parse count bytes from the hex-encoded string str of at least 2*count characters into vector data.

Definition at line 644 of file helpers.h.

◆ parse_hex() [8/8]

bool esphome::parse_hex ( const std::string & str,
uint8_t * data,
size_t count )
inline

Parse count bytes from the hex-encoded string str of at least 2*count characters into array data.

Definition at line 635 of file helpers.h.

◆ parse_hex_char()

uint8_t esphome::parse_hex_char ( char c)
constexpr

Parse a hex character to its nibble value (0-15), returns 255 on invalid input.

Definition at line 670 of file helpers.h.

◆ parse_number() [1/2]

template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_unsigned< T >::value), int > = 0>
optional< T > esphome::parse_number ( const char * str)

Parse an unsigned decimal number from a null-terminated string.

Parse a decimal floating-point number from a null-terminated string.

Parse a signed decimal number from a null-terminated string.

Definition at line 578 of file helpers.h.

◆ parse_number() [2/2]

template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_unsigned< T >::value), int > = 0>
optional< T > esphome::parse_number ( const std::string & str)

Parse an unsigned decimal number.

Parse a decimal floating-point number.

Parse a signed decimal number.

Definition at line 587 of file helpers.h.

◆ parse_on_off()

ParseOnOffState esphome::parse_on_off ( const char * str,
const char * on,
const char * off )

Parse a string that contains either on, off or toggle.

Definition at line 392 of file helpers.cpp.

◆ progmem_read_byte()

uint8_t esphome::progmem_read_byte ( const uint8_t * addr)

Definition at line 49 of file core.cpp.

◆ random_bytes()

bool esphome::random_bytes ( uint8_t * data,
size_t len )

Generate len number of random bytes.

Definition at line 18 of file helpers.cpp.

◆ random_float()

float esphome::random_float ( )

Return a random float between 0 and 1.

Definition at line 158 of file helpers.cpp.

◆ random_uint32()

uint32_t esphome::random_uint32 ( )

Return a random 32-bit unsigned integer.

Definition at line 17 of file helpers.cpp.

◆ remap()

template<typename T , typename U >
T esphome::remap ( U value,
U min,
U max,
T min_out,
T max_out )

Remap value from the range (min, max) to (min_out, max_out).

Definition at line 367 of file helpers.h.

◆ remote_is_connected()

bool esphome::remote_is_connected ( )

Return whether the node has any form of "remote" connection via the API or to an MQTT broker.

Definition at line 35 of file util.cpp.

◆ resetPins()

void esphome::resetPins ( )

Definition at line 52 of file core.cpp.

◆ retry_handler()

void esphome::retry_handler ( const std::shared_ptr< RetryArgs > & args)

Definition at line 224 of file scheduler.cpp.

◆ reverse_bits() [1/3]

uint16_t esphome::reverse_bits ( uint16_t x)
inline

Reverse the order of 16 bits.

Definition at line 466 of file helpers.h.

◆ reverse_bits() [2/3]

uint32_t esphome::reverse_bits ( uint32_t x)
inline

Reverse the order of 32 bits.

Definition at line 470 of file helpers.h.

◆ reverse_bits() [3/3]

uint8_t esphome::reverse_bits ( uint8_t x)
inline

Reverse the order of 8 bits.

Definition at line 459 of file helpers.h.

◆ rgb_to_hsv()

void esphome::rgb_to_hsv ( float red,
float green,
float blue,
int & hue,
float & saturation,
float & value )

Convert red, green and blue (all 0-1) values to hue (0-360), saturation (0-1) and value (0-1).

Definition at line 612 of file helpers.cpp.

◆ set_mac_address()

void esphome::set_mac_address ( uint8_t * mac)

Set the MAC address to use from the provided byte array (6 bytes).

Definition at line 91 of file helpers.cpp.

◆ step_to_accuracy_decimals()

int8_t esphome::step_to_accuracy_decimals ( float step)

Derive accuracy in decimals from an increment step.

Definition at line 445 of file helpers.cpp.

◆ str_ctype_transform()

template<int(*)(int) fn>
std::string esphome::str_ctype_transform ( const std::string & str)

Definition at line 184 of file helpers.cpp.

◆ str_endswith()

bool esphome::str_endswith ( const std::string & str,
const std::string & end )

Check whether a string ends with a value.

Definition at line 167 of file helpers.cpp.

◆ str_equals_case_insensitive()

bool esphome::str_equals_case_insensitive ( const std::string & a,
const std::string & b )

Compare strings for equality in case-insensitive manner.

Definition at line 162 of file helpers.cpp.

◆ str_lower_case()

std::string esphome::str_lower_case ( const std::string & str)

Convert the string to lower case.

Definition at line 190 of file helpers.cpp.

◆ str_sanitize()

std::string esphome::str_sanitize ( const std::string & str)

Sanitizes the input string by removing all characters but alphanumerics, dashes and underscores.

Definition at line 199 of file helpers.cpp.

◆ str_snake_case()

std::string esphome::str_snake_case ( const std::string & str)

Convert the string to snake case (lowercase with underscores).

Definition at line 192 of file helpers.cpp.

◆ str_snprintf()

std::string esphome::str_snprintf ( const char * fmt,
size_t len,
... )

Definition at line 206 of file helpers.cpp.

◆ str_sprintf()

std::string esphome::str_sprintf ( const char * fmt,
... )

Definition at line 220 of file helpers.cpp.

◆ str_startswith()

bool esphome::str_startswith ( const std::string & str,
const std::string & start )

Check whether a string starts with a value.

Definition at line 166 of file helpers.cpp.

◆ str_truncate()

std::string esphome::str_truncate ( const std::string & str,
size_t length )

Truncate a string to a specific length.

Definition at line 174 of file helpers.cpp.

◆ str_until() [1/2]

std::string esphome::str_until ( const char * str,
char ch )

Extract the part of the string until either the first occurrence of the specified character, or the end (requires str to be null-terminated).

Definition at line 177 of file helpers.cpp.

◆ str_until() [2/2]

std::string esphome::str_until ( const std::string & str,
char ch )

Extract the part of the string until either the first occurrence of the specified character, or the end.

Definition at line 181 of file helpers.cpp.

◆ str_upper_case()

std::string esphome::str_upper_case ( const std::string & str)

Convert the string to upper case.

Definition at line 191 of file helpers.cpp.

◆ swap()

template<typename T >
void esphome::swap ( optional< T > & x,
optional< T > & y )
noexcept

Definition at line 214 of file optional.h.

◆ to_sanitized_char()

char esphome::to_sanitized_char ( char c)
constexpr

Sanitize a single char: keep alphanumerics, dashes, underscores; replace others with underscore.

Definition at line 526 of file helpers.h.

◆ to_snake_case_char()

char esphome::to_snake_case_char ( char c)
constexpr

Convert a single char to snake_case: lowercase and space to underscore.

Definition at line 521 of file helpers.h.

◆ value_accuracy_to_buf()

size_t esphome::value_accuracy_to_buf ( std::span< char, VALUE_ACCURACY_MAX_LEN > buf,
float value,
int8_t accuracy_decimals )

Format value with accuracy to buffer, returns chars written (excluding null)

Definition at line 421 of file helpers.cpp.

◆ value_accuracy_to_string()

std::string esphome::value_accuracy_to_string ( float value,
int8_t accuracy_decimals )

Create a string from a value and an accuracy in decimals.

Definition at line 415 of file helpers.cpp.

◆ value_accuracy_with_uom_to_buf()

size_t esphome::value_accuracy_with_uom_to_buf ( std::span< char, VALUE_ACCURACY_MAX_LEN > buf,
float value,
int8_t accuracy_decimals,
StringRef unit_of_measurement )

Format value with accuracy and UOM to buffer, returns chars written (excluding null)

Definition at line 431 of file helpers.cpp.

◆ yield()

void esphome::yield ( )

Definition at line 24 of file core.cpp.

Variable Documentation

◆ App

Application esphome::App

Global storage of Application pointer - only one Application can exist.

Definition at line 652 of file application.cpp.

◆ COMPONENT_STATE_CONSTRUCTION

const uint8_t esphome::COMPONENT_STATE_CONSTRUCTION = 0x00

Definition at line 96 of file component.cpp.

◆ COMPONENT_STATE_FAILED

const uint8_t esphome::COMPONENT_STATE_FAILED = 0x03

Definition at line 99 of file component.cpp.

◆ COMPONENT_STATE_LOOP

const uint8_t esphome::COMPONENT_STATE_LOOP = 0x02

Definition at line 98 of file component.cpp.

◆ COMPONENT_STATE_LOOP_DONE

const uint8_t esphome::COMPONENT_STATE_LOOP_DONE = 0x04

Definition at line 100 of file component.cpp.

◆ COMPONENT_STATE_MASK

const uint8_t esphome::COMPONENT_STATE_MASK = 0x07

Definition at line 95 of file component.cpp.

◆ COMPONENT_STATE_SETUP

const uint8_t esphome::COMPONENT_STATE_SETUP = 0x01

Definition at line 97 of file component.cpp.

◆ FNV1_OFFSET_BASIS

uint32_t esphome::FNV1_OFFSET_BASIS = 2166136261UL
constexpr

FNV-1 32-bit offset basis.

Definition at line 386 of file helpers.h.

◆ FNV1_PRIME

uint32_t esphome::FNV1_PRIME = 16777619UL
constexpr

FNV-1 32-bit prime.

Definition at line 388 of file helpers.h.

◆ global_preferences

ESPPreferences * esphome::global_preferences

Definition at line 211 of file preferences.cpp.

◆ global_runtime_stats

runtime_stats::RuntimeStatsCollector * esphome::global_runtime_stats
Initial value:
=
nullptr

Definition at line 84 of file runtime_stats.cpp.

◆ global_state

uint32_t esphome::global_state = 0

Definition at line 110 of file component.cpp.

◆ len

std::string size_t esphome::len

Definition at line 533 of file helpers.h.

◆ loop_task_handle

TaskHandle_t esphome::loop_task_handle = nullptr

Definition at line 57 of file core.cpp.

◆ STATUS_LED_ERROR

const uint8_t esphome::STATUS_LED_ERROR = 0x10

Definition at line 105 of file component.cpp.

◆ STATUS_LED_MASK

const uint8_t esphome::STATUS_LED_MASK = 0x18

Definition at line 102 of file component.cpp.

◆ STATUS_LED_OK

const uint8_t esphome::STATUS_LED_OK = 0x00

Definition at line 103 of file component.cpp.

◆ STATUS_LED_WARNING

const uint8_t esphome::STATUS_LED_WARNING = 0x08

Definition at line 104 of file component.cpp.

◆ WARN_IF_BLOCKING_INCREMENT_MS

const uint16_t esphome::WARN_IF_BLOCKING_INCREMENT_MS = 10U

How long the blocking time must be larger to warn again.

Definition at line 108 of file component.cpp.

◆ WARN_IF_BLOCKING_OVER_MS

const uint16_t esphome::WARN_IF_BLOCKING_OVER_MS = 50U

Initial blocking time allowed without warning.

Definition at line 107 of file component.cpp.