esphome 2025.7.4__py3-none-any.whl → 2025.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (758) hide show
  1. esphome/__main__.py +190 -83
  2. esphome/automation.py +2 -4
  3. esphome/build_gen/__init__.py +0 -0
  4. esphome/build_gen/platformio.py +102 -0
  5. esphome/components/a4988/a4988.cpp +0 -1
  6. esphome/components/absolute_humidity/absolute_humidity.cpp +0 -2
  7. esphome/components/absolute_humidity/sensor.py +2 -2
  8. esphome/components/adc/__init__.py +123 -85
  9. esphome/components/adc/adc_sensor.h +98 -35
  10. esphome/components/adc/adc_sensor_common.cpp +10 -4
  11. esphome/components/adc/adc_sensor_esp32.cpp +291 -123
  12. esphome/components/adc/adc_sensor_esp8266.cpp +1 -4
  13. esphome/components/adc/adc_sensor_libretiny.cpp +1 -2
  14. esphome/components/adc/adc_sensor_rp2040.cpp +1 -2
  15. esphome/components/adc/adc_sensor_zephyr.cpp +207 -0
  16. esphome/components/adc/sensor.py +61 -27
  17. esphome/components/adc128s102/adc128s102.cpp +1 -4
  18. esphome/components/ade7880/sensor.py +75 -49
  19. esphome/components/ads1115/ads1115.cpp +0 -1
  20. esphome/components/ads1118/ads1118.cpp +0 -1
  21. esphome/components/ags10/ags10.cpp +0 -4
  22. esphome/components/aht10/aht10.cpp +0 -4
  23. esphome/components/aic3204/aic3204.cpp +0 -2
  24. esphome/components/airthings_wave_plus/__init__.py +1 -1
  25. esphome/components/airthings_wave_plus/airthings_wave_plus.cpp +22 -4
  26. esphome/components/airthings_wave_plus/airthings_wave_plus.h +10 -1
  27. esphome/components/airthings_wave_plus/sensor.py +55 -28
  28. esphome/components/alarm_control_panel/__init__.py +4 -9
  29. esphome/components/am2315c/am2315c.cpp +0 -2
  30. esphome/components/am2320/am2320.cpp +0 -1
  31. esphome/components/animation/__init__.py +14 -11
  32. esphome/components/apds9306/apds9306.cpp +0 -4
  33. esphome/components/apds9960/apds9960.cpp +0 -1
  34. esphome/components/api/__init__.py +29 -4
  35. esphome/components/api/api_connection.cpp +378 -401
  36. esphome/components/api/api_connection.h +112 -56
  37. esphome/components/api/api_frame_helper.cpp +69 -896
  38. esphome/components/api/api_frame_helper.h +31 -126
  39. esphome/components/api/api_frame_helper_noise.cpp +583 -0
  40. esphome/components/api/api_frame_helper_noise.h +68 -0
  41. esphome/components/api/api_frame_helper_plaintext.cpp +290 -0
  42. esphome/components/api/api_frame_helper_plaintext.h +53 -0
  43. esphome/components/api/api_noise_context.h +2 -4
  44. esphome/components/api/api_pb2.cpp +1601 -1808
  45. esphome/components/api/api_pb2.h +367 -323
  46. esphome/components/api/api_pb2_dump.cpp +1137 -3466
  47. esphome/components/api/api_pb2_includes.h +34 -0
  48. esphome/components/api/api_pb2_service.cpp +94 -105
  49. esphome/components/api/api_pb2_service.h +27 -16
  50. esphome/components/api/api_server.cpp +18 -17
  51. esphome/components/api/api_server.h +8 -5
  52. esphome/components/api/client.py +16 -8
  53. esphome/components/api/custom_api_device.h +68 -14
  54. esphome/components/api/homeassistant_service.h +24 -19
  55. esphome/components/api/list_entities.cpp +3 -5
  56. esphome/components/api/list_entities.h +2 -4
  57. esphome/components/api/proto.cpp +3 -5
  58. esphome/components/api/proto.h +239 -274
  59. esphome/components/api/subscribe_state.cpp +2 -4
  60. esphome/components/api/subscribe_state.h +2 -4
  61. esphome/components/api/user_services.cpp +2 -4
  62. esphome/components/api/user_services.h +8 -8
  63. esphome/components/as3935/as3935.cpp +0 -2
  64. esphome/components/as3935_spi/as3935_spi.cpp +0 -2
  65. esphome/components/as5600/__init__.py +1 -1
  66. esphome/components/as5600/as5600.cpp +0 -2
  67. esphome/components/as5600/sensor/__init__.py +0 -1
  68. esphome/components/as7341/as7341.cpp +0 -1
  69. esphome/components/async_tcp/__init__.py +1 -1
  70. esphome/components/at581x/at581x.cpp +1 -1
  71. esphome/components/atm90e26/atm90e26.cpp +0 -1
  72. esphome/components/atm90e32/atm90e32.cpp +475 -116
  73. esphome/components/atm90e32/atm90e32.h +43 -5
  74. esphome/components/audio/audio.h +2 -2
  75. esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp +0 -2
  76. esphome/components/beken_spi_led_strip/led_strip.cpp +0 -2
  77. esphome/components/bh1750/bh1750.cpp +0 -1
  78. esphome/components/binary_sensor/__init__.py +14 -12
  79. esphome/components/ble_client/__init__.py +4 -7
  80. esphome/components/bluetooth_proxy/__init__.py +40 -3
  81. esphome/components/bluetooth_proxy/bluetooth_connection.cpp +392 -81
  82. esphome/components/bluetooth_proxy/bluetooth_connection.h +16 -5
  83. esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +102 -311
  84. esphome/components/bluetooth_proxy/bluetooth_proxy.h +30 -14
  85. esphome/components/bme280_base/bme280_base.cpp +15 -16
  86. esphome/components/bme680/bme680.cpp +2 -3
  87. esphome/components/bme680_bsec/bme680_bsec.cpp +0 -2
  88. esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +0 -2
  89. esphome/components/bmi160/bmi160.cpp +0 -1
  90. esphome/components/bmp085/bmp085.cpp +0 -1
  91. esphome/components/bmp280_base/bmp280_base.cpp +13 -14
  92. esphome/components/bmp3xx_base/bmp3xx_base.cpp +0 -1
  93. esphome/components/bmp581/bmp581.cpp +0 -2
  94. esphome/components/bp1658cj/bp1658cj.cpp +0 -1
  95. esphome/components/bp5758d/bp5758d.cpp +0 -1
  96. esphome/components/button/__init__.py +0 -1
  97. esphome/components/canbus/__init__.py +2 -3
  98. esphome/components/canbus/canbus.cpp +0 -1
  99. esphome/components/cap1188/cap1188.cpp +0 -2
  100. esphome/components/captive_portal/__init__.py +1 -1
  101. esphome/components/cd74hc4067/cd74hc4067.cpp +0 -2
  102. esphome/components/ch422g/ch422g.cpp +0 -1
  103. esphome/components/chsc6x/chsc6x_touchscreen.cpp +0 -3
  104. esphome/components/climate/__init__.py +0 -1
  105. esphome/components/climate/climate_traits.h +24 -0
  106. esphome/components/cm1106/cm1106.cpp +0 -1
  107. esphome/components/const/__init__.py +6 -0
  108. esphome/components/cover/__init__.py +0 -1
  109. esphome/components/cover/cover.cpp +9 -13
  110. esphome/components/cs5460a/cs5460a.cpp +0 -2
  111. esphome/components/cse7761/cse7761.cpp +0 -1
  112. esphome/components/cst226/touchscreen/cst226_touchscreen.cpp +0 -2
  113. esphome/components/cst816/touchscreen/cst816_touchscreen.cpp +0 -2
  114. esphome/components/dac7678/dac7678_output.cpp +0 -2
  115. esphome/components/dallas_temp/dallas_temp.cpp +0 -1
  116. esphome/components/datetime/__init__.py +0 -2
  117. esphome/components/debug/__init__.py +15 -1
  118. esphome/components/debug/debug_zephyr.cpp +281 -0
  119. esphome/components/debug/sensor.py +2 -1
  120. esphome/components/deep_sleep/deep_sleep_component.cpp +0 -1
  121. esphome/components/deep_sleep/deep_sleep_esp32.cpp +20 -1
  122. esphome/components/dfrobot_sen0395/__init__.py +1 -2
  123. esphome/components/dht/dht.cpp +0 -1
  124. esphome/components/dht12/dht12.cpp +0 -1
  125. esphome/components/display/__init__.py +16 -3
  126. esphome/components/display_menu_base/__init__.py +1 -1
  127. esphome/components/dps310/dps310.cpp +0 -2
  128. esphome/components/ds1307/ds1307.cpp +0 -1
  129. esphome/components/ds2484/ds2484.cpp +0 -1
  130. esphome/components/duty_cycle/duty_cycle_sensor.cpp +0 -1
  131. esphome/components/ee895/ee895.cpp +0 -1
  132. esphome/components/ektf2232/touchscreen/ektf2232.cpp +0 -1
  133. esphome/components/emc2101/emc2101.cpp +0 -2
  134. esphome/components/ens160_base/ens160_base.cpp +0 -2
  135. esphome/components/ens210/ens210.cpp +0 -1
  136. esphome/components/es7210/es7210.cpp +0 -2
  137. esphome/components/es7243e/es7243e.cpp +0 -2
  138. esphome/components/es8156/es8156.cpp +0 -2
  139. esphome/components/es8311/es8311.cpp +0 -2
  140. esphome/components/es8388/es8388.cpp +0 -2
  141. esphome/components/esp32/__init__.py +203 -60
  142. esphome/components/esp32/boards.py +17 -0
  143. esphome/components/esp32/gpio.cpp +0 -1
  144. esphome/components/esp32/gpio.py +1 -2
  145. esphome/components/esp32/gpio_esp32_h2.py +2 -7
  146. esphome/components/esp32/gpio_esp32_p4.py +2 -7
  147. esphome/components/esp32/post_build.py.script +112 -61
  148. esphome/components/esp32_ble/__init__.py +41 -2
  149. esphome/components/esp32_ble/ble.cpp +14 -10
  150. esphome/components/esp32_ble/ble.h +18 -18
  151. esphome/components/esp32_ble/ble_advertising.cpp +5 -5
  152. esphome/components/esp32_ble/ble_advertising.h +7 -5
  153. esphome/components/esp32_ble/ble_event.h +139 -73
  154. esphome/components/esp32_ble/ble_scan_result.h +2 -4
  155. esphome/components/esp32_ble/ble_uuid.cpp +5 -5
  156. esphome/components/esp32_ble/ble_uuid.h +6 -5
  157. esphome/components/esp32_ble_beacon/__init__.py +4 -0
  158. esphome/components/esp32_ble_client/__init__.py +1 -1
  159. esphome/components/esp32_ble_client/ble_characteristic.cpp +4 -4
  160. esphome/components/esp32_ble_client/ble_characteristic.h +6 -4
  161. esphome/components/esp32_ble_client/ble_client_base.cpp +155 -104
  162. esphome/components/esp32_ble_client/ble_client_base.h +17 -6
  163. esphome/components/esp32_ble_client/ble_descriptor.h +6 -4
  164. esphome/components/esp32_ble_client/ble_service.cpp +4 -4
  165. esphome/components/esp32_ble_client/ble_service.h +6 -4
  166. esphome/components/esp32_ble_server/__init__.py +15 -12
  167. esphome/components/esp32_ble_tracker/__init__.py +79 -11
  168. esphome/components/esp32_ble_tracker/automation.h +4 -4
  169. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +264 -261
  170. esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +103 -37
  171. esphome/components/esp32_camera/__init__.py +13 -1
  172. esphome/components/esp32_camera/esp32_camera.cpp +7 -2
  173. esphome/components/esp32_camera/esp32_camera.h +1 -0
  174. esphome/components/esp32_dac/esp32_dac.cpp +3 -19
  175. esphome/components/esp32_dac/esp32_dac.h +4 -8
  176. esphome/components/esp32_rmt_led_strip/led_strip.cpp +1 -6
  177. esphome/components/esp32_rmt_led_strip/light.py +1 -1
  178. esphome/components/esp32_touch/__init__.py +2 -3
  179. esphome/components/esp32_touch/esp32_touch.h +9 -6
  180. esphome/components/esp32_touch/esp32_touch_common.cpp +2 -0
  181. esphome/components/esp32_touch/esp32_touch_v1.cpp +7 -9
  182. esphome/components/esp32_touch/esp32_touch_v2.cpp +10 -6
  183. esphome/components/esp8266/__init__.py +3 -1
  184. esphome/components/esp8266_pwm/esp8266_pwm.cpp +0 -1
  185. esphome/components/esphome/ota/__init__.py +1 -2
  186. esphome/components/esphome/ota/ota_esphome.cpp +150 -77
  187. esphome/components/esphome/ota/ota_esphome.h +8 -1
  188. esphome/components/espnow/__init__.py +309 -0
  189. esphome/components/espnow/automation.h +175 -0
  190. esphome/components/espnow/espnow_component.cpp +468 -0
  191. esphome/components/espnow/espnow_component.h +183 -0
  192. esphome/components/espnow/espnow_err.h +19 -0
  193. esphome/components/espnow/espnow_packet.h +166 -0
  194. esphome/components/ethernet/__init__.py +7 -1
  195. esphome/components/ethernet/esp_eth_phy_jl1101.c +5 -0
  196. esphome/components/ethernet/ethernet_component.cpp +0 -1
  197. esphome/components/ethernet/ethernet_component.h +4 -0
  198. esphome/components/ethernet_info/ethernet_info_text_sensor.h +0 -3
  199. esphome/components/event/__init__.py +0 -1
  200. esphome/components/factory_reset/__init__.py +92 -0
  201. esphome/components/factory_reset/factory_reset.cpp +76 -0
  202. esphome/components/factory_reset/factory_reset.h +43 -0
  203. esphome/components/fan/__init__.py +0 -1
  204. esphome/components/fan/fan_traits.h +16 -0
  205. esphome/components/fastled_base/fastled_light.cpp +0 -1
  206. esphome/components/fastled_spi/light.py +1 -3
  207. esphome/components/fingerprint_grow/fingerprint_grow.cpp +0 -2
  208. esphome/components/font/__init__.py +9 -1
  209. esphome/components/fs3000/fs3000.cpp +0 -2
  210. esphome/components/ft5x06/touchscreen/ft5x06_touchscreen.cpp +0 -2
  211. esphome/components/ft63x6/ft63x6.cpp +0 -1
  212. esphome/components/gdk101/gdk101.cpp +0 -1
  213. esphome/components/gl_r01_i2c/gl_r01_i2c.cpp +0 -1
  214. esphome/components/gl_r01_i2c/sensor.py +1 -1
  215. esphome/components/gpio/one_wire/gpio_one_wire.cpp +0 -1
  216. esphome/components/gpio/switch/gpio_switch.cpp +0 -2
  217. esphome/components/gpio_expander/cached_gpio.h +24 -15
  218. esphome/components/gps/__init__.py +6 -2
  219. esphome/components/gps/gps.cpp +50 -49
  220. esphome/components/gps/gps.h +4 -8
  221. esphome/components/gps/time/gps_time.cpp +3 -9
  222. esphome/components/gps/time/gps_time.h +4 -7
  223. esphome/components/graph/__init__.py +1 -1
  224. esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.cpp +0 -1
  225. esphome/components/grove_tb6612fng/grove_tb6612fng.cpp +0 -1
  226. esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +21 -12
  227. esphome/components/gt911/touchscreen/gt911_touchscreen.h +26 -2
  228. esphome/components/haier/climate.py +5 -10
  229. esphome/components/haier/haier_base.cpp +0 -1
  230. esphome/components/hbridge/switch/hbridge_switch.cpp +0 -2
  231. esphome/components/hdc1080/hdc1080.cpp +0 -2
  232. esphome/components/heatpumpir/climate.py +2 -2
  233. esphome/components/hlw8012/hlw8012.cpp +0 -1
  234. esphome/components/hm3301/hm3301.cpp +0 -1
  235. esphome/components/hmc5883l/hmc5883l.cpp +0 -1
  236. esphome/components/homeassistant/__init__.py +1 -0
  237. esphome/components/homeassistant/number/__init__.py +1 -0
  238. esphome/components/homeassistant/number/homeassistant_number.cpp +11 -7
  239. esphome/components/homeassistant/switch/__init__.py +1 -0
  240. esphome/components/homeassistant/switch/homeassistant_switch.cpp +9 -5
  241. esphome/components/honeywellabp/honeywellabp.cpp +1 -4
  242. esphome/components/host/__init__.py +2 -0
  243. esphome/components/hte501/hte501.cpp +0 -1
  244. esphome/components/http_request/__init__.py +2 -3
  245. esphome/components/http_request/http_request_idf.cpp +2 -2
  246. esphome/components/htu21d/htu21d.cpp +0 -2
  247. esphome/components/htu31d/htu31d.cpp +0 -2
  248. esphome/components/hx711/hx711.cpp +0 -1
  249. esphome/components/hydreon_rgxx/hydreon_rgxx.cpp +0 -1
  250. esphome/components/hydreon_rgxx/sensor.py +4 -5
  251. esphome/components/i2c/i2c_bus.h +1 -1
  252. esphome/components/i2c/i2c_bus_arduino.cpp +1 -2
  253. esphome/components/i2c/i2c_bus_esp_idf.cpp +192 -17
  254. esphome/components/i2c/i2c_bus_esp_idf.h +11 -1
  255. esphome/components/i2s_audio/__init__.py +6 -5
  256. esphome/components/i2s_audio/i2s_audio.cpp +0 -2
  257. esphome/components/i2s_audio/media_player/i2s_audio_media_player.cpp +1 -4
  258. esphome/components/i2s_audio/microphone/__init__.py +4 -6
  259. esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +46 -19
  260. esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +4 -3
  261. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +273 -269
  262. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +19 -34
  263. esphome/components/ili9xxx/display.py +4 -3
  264. esphome/components/ili9xxx/ili9xxx_display.cpp +0 -2
  265. esphome/components/image/__init__.py +123 -92
  266. esphome/components/improv_serial/__init__.py +7 -8
  267. esphome/components/ina219/ina219.cpp +0 -1
  268. esphome/components/ina226/ina226.cpp +0 -2
  269. esphome/components/ina260/ina260.cpp +0 -2
  270. esphome/components/ina2xx_base/__init__.py +2 -5
  271. esphome/components/ina2xx_base/ina2xx_base.cpp +0 -2
  272. esphome/components/ina3221/ina3221.cpp +0 -1
  273. esphome/components/internal_temperature/internal_temperature.cpp +0 -2
  274. esphome/components/interval/interval.h +5 -9
  275. esphome/components/json/__init__.py +1 -1
  276. esphome/components/kmeteriso/kmeteriso.cpp +0 -2
  277. esphome/components/lc709203f/lc709203f.cpp +0 -2
  278. esphome/components/lcd_gpio/display.py +1 -3
  279. esphome/components/lcd_gpio/gpio_lcd_display.cpp +0 -1
  280. esphome/components/lcd_pcf8574/pcf8574_display.cpp +0 -1
  281. esphome/components/ld2410/__init__.py +4 -6
  282. esphome/components/ld2410/binary_sensor.py +4 -0
  283. esphome/components/ld2410/ld2410.cpp +56 -100
  284. esphome/components/ld2410/ld2410.h +17 -15
  285. esphome/components/ld2410/sensor.py +24 -10
  286. esphome/components/ld2412/__init__.py +46 -0
  287. esphome/components/ld2412/binary_sensor.py +70 -0
  288. esphome/components/ld2412/button/__init__.py +74 -0
  289. esphome/components/ld2412/button/factory_reset_button.cpp +9 -0
  290. esphome/components/ld2412/button/factory_reset_button.h +18 -0
  291. esphome/components/ld2412/button/query_button.cpp +9 -0
  292. esphome/components/ld2412/button/query_button.h +18 -0
  293. esphome/components/ld2412/button/restart_button.cpp +9 -0
  294. esphome/components/ld2412/button/restart_button.h +18 -0
  295. esphome/components/ld2412/button/start_dynamic_background_correction_button.cpp +11 -0
  296. esphome/components/ld2412/button/start_dynamic_background_correction_button.h +18 -0
  297. esphome/components/ld2412/ld2412.cpp +861 -0
  298. esphome/components/ld2412/ld2412.h +141 -0
  299. esphome/components/ld2412/number/__init__.py +126 -0
  300. esphome/components/ld2412/number/gate_threshold_number.cpp +14 -0
  301. esphome/components/ld2412/number/gate_threshold_number.h +19 -0
  302. esphome/components/ld2412/number/light_threshold_number.cpp +12 -0
  303. esphome/components/ld2412/number/light_threshold_number.h +18 -0
  304. esphome/components/ld2412/number/max_distance_timeout_number.cpp +12 -0
  305. esphome/components/ld2412/number/max_distance_timeout_number.h +18 -0
  306. esphome/components/ld2412/select/__init__.py +82 -0
  307. esphome/components/ld2412/select/baud_rate_select.cpp +12 -0
  308. esphome/components/ld2412/select/baud_rate_select.h +18 -0
  309. esphome/components/ld2412/select/distance_resolution_select.cpp +12 -0
  310. esphome/components/ld2412/select/distance_resolution_select.h +18 -0
  311. esphome/components/ld2412/select/light_out_control_select.cpp +12 -0
  312. esphome/components/ld2412/select/light_out_control_select.h +18 -0
  313. esphome/components/ld2412/sensor.py +124 -0
  314. esphome/components/ld2412/switch/__init__.py +45 -0
  315. esphome/components/ld2412/switch/bluetooth_switch.cpp +12 -0
  316. esphome/components/ld2412/switch/bluetooth_switch.h +18 -0
  317. esphome/components/ld2412/switch/engineering_mode_switch.cpp +12 -0
  318. esphome/components/ld2412/switch/engineering_mode_switch.h +18 -0
  319. esphome/components/ld2412/text_sensor.py +34 -0
  320. esphome/components/ld2420/ld2420.cpp +0 -1
  321. esphome/components/ld2450/__init__.py +3 -4
  322. esphome/components/ld2450/binary_sensor.py +3 -0
  323. esphome/components/ld2450/ld2450.cpp +77 -165
  324. esphome/components/ld2450/ld2450.h +26 -54
  325. esphome/components/ld2450/sensor.py +120 -6
  326. esphome/components/ld2450/text_sensor.py +5 -4
  327. esphome/components/ld24xx/__init__.py +1 -0
  328. esphome/components/ld24xx/ld24xx.h +65 -0
  329. esphome/components/ledc/ledc_output.cpp +0 -1
  330. esphome/components/libretiny/__init__.py +2 -0
  331. esphome/components/light/__init__.py +0 -1
  332. esphome/components/light/effects.py +70 -45
  333. esphome/components/light/light_call.cpp +101 -66
  334. esphome/components/light/light_color_values.h +16 -11
  335. esphome/components/light/light_json_schema.cpp +46 -44
  336. esphome/components/light/light_state.cpp +8 -11
  337. esphome/components/light/light_traits.h +17 -0
  338. esphome/components/lightwaverf/lightwaverf.cpp +0 -2
  339. esphome/components/lilygo_t5_47/touchscreen/lilygo_t5_47_touchscreen.cpp +0 -1
  340. esphome/components/lock/__init__.py +0 -1
  341. esphome/components/logger/__init__.py +31 -9
  342. esphome/components/logger/logger.cpp +12 -7
  343. esphome/components/logger/logger.h +25 -14
  344. esphome/components/logger/logger_esp32.cpp +2 -7
  345. esphome/components/logger/logger_esp8266.cpp +2 -4
  346. esphome/components/logger/logger_host.cpp +2 -4
  347. esphome/components/logger/logger_libretiny.cpp +2 -4
  348. esphome/components/logger/logger_rp2040.cpp +2 -4
  349. esphome/components/logger/logger_zephyr.cpp +86 -0
  350. esphome/components/logger/select/logger_level_select.cpp +2 -4
  351. esphome/components/logger/select/logger_level_select.h +2 -4
  352. esphome/components/logger/task_log_buffer.cpp +2 -4
  353. esphome/components/logger/task_log_buffer.h +2 -4
  354. esphome/components/lps22/sensor.py +5 -5
  355. esphome/components/ltr390/ltr390.cpp +0 -2
  356. esphome/components/ltr501/ltr501.cpp +0 -1
  357. esphome/components/ltr_als_ps/ltr_als_ps.cpp +0 -1
  358. esphome/components/lvgl/__init__.py +14 -13
  359. esphome/components/lvgl/automation.py +2 -4
  360. esphome/components/lvgl/defines.py +0 -2
  361. esphome/components/lvgl/helpers.py +1 -1
  362. esphome/components/lvgl/lv_validation.py +7 -4
  363. esphome/components/lvgl/lvgl_esphome.cpp +2 -3
  364. esphome/components/lvgl/styles.py +2 -2
  365. esphome/components/lvgl/types.py +1 -1
  366. esphome/components/lvgl/widgets/__init__.py +2 -2
  367. esphome/components/lvgl/widgets/arc.py +14 -11
  368. esphome/components/lvgl/widgets/buttonmatrix.py +1 -1
  369. esphome/components/lvgl/widgets/qrcode.py +7 -7
  370. esphome/components/lvgl/widgets/spinner.py +6 -6
  371. esphome/components/lvgl/widgets/switch.py +2 -2
  372. esphome/components/lvgl/widgets/tabview.py +3 -3
  373. esphome/components/lvgl/widgets/tileview.py +15 -7
  374. esphome/components/m5stack_8angle/m5stack_8angle.cpp +0 -1
  375. esphome/components/matrix_keypad/__init__.py +4 -3
  376. esphome/components/max17043/max17043.cpp +0 -2
  377. esphome/components/max31855/max31855.cpp +1 -4
  378. esphome/components/max31856/max31856.cpp +0 -4
  379. esphome/components/max31865/max31865.cpp +0 -1
  380. esphome/components/max44009/max44009.cpp +0 -1
  381. esphome/components/max6675/max6675.cpp +1 -4
  382. esphome/components/max6956/max6956.cpp +0 -1
  383. esphome/components/max7219/max7219.cpp +0 -1
  384. esphome/components/max7219digit/display.py +1 -1
  385. esphome/components/max7219digit/max7219digit.cpp +0 -1
  386. esphome/components/max9611/max9611.cpp +0 -1
  387. esphome/components/mcp23008/__init__.py +1 -1
  388. esphome/components/mcp23008/mcp23008.cpp +0 -1
  389. esphome/components/mcp23016/mcp23016.cpp +0 -1
  390. esphome/components/mcp23017/__init__.py +1 -1
  391. esphome/components/mcp23017/mcp23017.cpp +0 -1
  392. esphome/components/mcp23s08/__init__.py +1 -1
  393. esphome/components/mcp23s08/mcp23s08.cpp +0 -1
  394. esphome/components/mcp23s17/__init__.py +1 -1
  395. esphome/components/mcp23s17/mcp23s17.cpp +0 -1
  396. esphome/components/mcp23x08_base/__init__.py +2 -0
  397. esphome/components/mcp23x08_base/mcp23x08_base.cpp +9 -7
  398. esphome/components/mcp23x08_base/mcp23x08_base.h +9 -4
  399. esphome/components/mcp23x17_base/__init__.py +2 -0
  400. esphome/components/mcp23x17_base/mcp23x17_base.cpp +20 -7
  401. esphome/components/mcp23x17_base/mcp23x17_base.h +9 -4
  402. esphome/components/mcp23xxx_base/__init__.py +11 -5
  403. esphome/components/mcp23xxx_base/mcp23xxx_base.cpp +15 -12
  404. esphome/components/mcp23xxx_base/mcp23xxx_base.h +8 -7
  405. esphome/components/mcp3008/mcp3008.cpp +1 -4
  406. esphome/components/mcp3204/mcp3204.cpp +1 -4
  407. esphome/components/mcp4461/mcp4461.cpp +0 -1
  408. esphome/components/mcp4725/mcp4725.cpp +0 -1
  409. esphome/components/mcp4728/mcp4728.cpp +0 -1
  410. esphome/components/mcp9600/mcp9600.cpp +0 -2
  411. esphome/components/mcp9808/mcp9808.cpp +0 -2
  412. esphome/components/mdns/__init__.py +3 -0
  413. esphome/components/mdns/mdns_component.cpp +2 -0
  414. esphome/components/mdns/mdns_component.h +4 -0
  415. esphome/components/media_player/__init__.py +40 -0
  416. esphome/components/media_player/automation.h +16 -0
  417. esphome/components/media_player/media_player.cpp +13 -0
  418. esphome/components/media_player/media_player.h +50 -3
  419. esphome/components/micro_wake_word/micro_wake_word.cpp +0 -3
  420. esphome/components/mics_4514/mics_4514.cpp +1 -6
  421. esphome/components/midea/ir_transmitter.h +4 -4
  422. esphome/components/mipi/__init__.py +416 -0
  423. esphome/components/mipi_dsi/__init__.py +5 -0
  424. esphome/components/mipi_dsi/display.py +233 -0
  425. esphome/components/mipi_dsi/mipi_dsi.cpp +379 -0
  426. esphome/components/mipi_dsi/mipi_dsi.h +123 -0
  427. esphome/components/mipi_dsi/models/__init__.py +0 -0
  428. esphome/components/mipi_dsi/models/guition.py +38 -0
  429. esphome/components/mipi_dsi/models/m5stack.py +57 -0
  430. esphome/components/mipi_dsi/models/waveshare.py +105 -0
  431. esphome/components/mipi_rgb/models/lilygo.py +0 -0
  432. esphome/components/mipi_spi/__init__.py +0 -9
  433. esphome/components/mipi_spi/display.py +220 -256
  434. esphome/components/mipi_spi/mipi_spi.cpp +1 -485
  435. esphome/components/mipi_spi/mipi_spi.h +556 -108
  436. esphome/components/mipi_spi/models/__init__.py +0 -65
  437. esphome/components/mipi_spi/models/adafruit.py +30 -0
  438. esphome/components/mipi_spi/models/amoled.py +41 -5
  439. esphome/components/mipi_spi/models/ili.py +5 -5
  440. esphome/components/mipi_spi/models/jc.py +1 -3
  441. esphome/components/mipi_spi/models/lilygo.py +1 -1
  442. esphome/components/mipi_spi/models/waveshare.py +16 -1
  443. esphome/components/mixer/speaker/__init__.py +4 -5
  444. esphome/components/mlx90393/sensor.py +7 -5
  445. esphome/components/mlx90393/sensor_mlx90393.cpp +0 -1
  446. esphome/components/mlx90614/mlx90614.cpp +0 -1
  447. esphome/components/mmc5603/mmc5603.cpp +0 -1
  448. esphome/components/mmc5983/mmc5983.cpp +0 -2
  449. esphome/components/mpl3115a2/mpl3115a2.cpp +0 -2
  450. esphome/components/mpr121/__init__.py +7 -6
  451. esphome/components/mpr121/mpr121.cpp +0 -1
  452. esphome/components/mpu6050/mpu6050.cpp +0 -1
  453. esphome/components/mpu6886/mpu6886.cpp +0 -1
  454. esphome/components/mqtt/__init__.py +1 -2
  455. esphome/components/mqtt/mqtt_button.cpp +1 -1
  456. esphome/components/mqtt/mqtt_client.cpp +0 -1
  457. esphome/components/mqtt/mqtt_component.cpp +8 -14
  458. esphome/components/mqtt/mqtt_component.h +0 -7
  459. esphome/components/mqtt/mqtt_sensor.cpp +0 -1
  460. esphome/components/mqtt/mqtt_sensor.h +0 -1
  461. esphome/components/mqtt/mqtt_text_sensor.cpp +0 -1
  462. esphome/components/mqtt/mqtt_text_sensor.h +0 -1
  463. esphome/components/ms5611/ms5611.cpp +0 -1
  464. esphome/components/ms8607/ms8607.cpp +0 -1
  465. esphome/components/msa3xx/msa3xx.cpp +0 -2
  466. esphome/components/my9231/my9231.cpp +0 -2
  467. esphome/components/nau7802/nau7802.cpp +0 -1
  468. esphome/components/neopixelbus/light.py +3 -0
  469. esphome/components/network/util.cpp +29 -0
  470. esphome/components/nextion/nextion.cpp +2 -2
  471. esphome/components/nfc/binary_sensor/{binary_sensor.cpp → nfc_binary_sensor.cpp} +1 -1
  472. esphome/components/npi19/npi19.cpp +0 -2
  473. esphome/components/nrf52/__init__.py +223 -0
  474. esphome/components/nrf52/boards.py +34 -0
  475. esphome/components/nrf52/const.py +18 -0
  476. esphome/components/nrf52/gpio.py +79 -0
  477. esphome/components/number/__init__.py +2 -1
  478. esphome/components/one_wire/__init__.py +1 -2
  479. esphome/components/one_wire/one_wire.cpp +0 -2
  480. esphome/components/one_wire/one_wire.h +0 -2
  481. esphome/components/opentherm/hub.cpp +0 -1
  482. esphome/components/opentherm/number/__init__.py +2 -2
  483. esphome/components/openthread/__init__.py +2 -3
  484. esphome/components/openthread/openthread.cpp +30 -13
  485. esphome/components/openthread/openthread.h +3 -0
  486. esphome/components/openthread/openthread_esp.cpp +3 -1
  487. esphome/components/opt3001/sensor.py +2 -6
  488. esphome/components/output/__init__.py +38 -0
  489. esphome/components/output/automation.h +24 -0
  490. esphome/components/output/switch/output_switch.cpp +0 -2
  491. esphome/components/packages/__init__.py +1 -2
  492. esphome/components/packet_transport/__init__.py +4 -3
  493. esphome/components/pca6416a/pca6416a.cpp +0 -1
  494. esphome/components/pca9554/pca9554.cpp +0 -1
  495. esphome/components/pca9685/pca9685_output.cpp +0 -2
  496. esphome/components/pcf85063/pcf85063.cpp +0 -1
  497. esphome/components/pcf8563/pcf8563.cpp +0 -1
  498. esphome/components/pcf8574/pcf8574.cpp +0 -1
  499. esphome/components/pi4ioe5v6408/pi4ioe5v6408.cpp +0 -1
  500. esphome/components/pipsolar/pipsolar.cpp +54 -42
  501. esphome/components/pipsolar/pipsolar.h +5 -4
  502. esphome/components/pipsolar/sensor/__init__.py +1 -1
  503. esphome/components/pm2005/pm2005.cpp +0 -1
  504. esphome/components/pmsa003i/pmsa003i.cpp +0 -2
  505. esphome/components/pmwcs3/sensor.py +1 -2
  506. esphome/components/pn532/pn532.cpp +0 -2
  507. esphome/components/pn532_spi/pn532_spi.cpp +0 -2
  508. esphome/components/power_supply/power_supply.cpp +7 -10
  509. esphome/components/power_supply/power_supply.h +1 -1
  510. esphome/components/psram/__init__.py +6 -1
  511. esphome/components/pulse_counter/pulse_counter_sensor.cpp +0 -1
  512. esphome/components/pulse_counter/sensor.py +9 -6
  513. esphome/components/pylontech/pylontech.cpp +0 -1
  514. esphome/components/qmc5883l/qmc5883l.cpp +0 -1
  515. esphome/components/qmp6988/qmp6988.cpp +0 -2
  516. esphome/components/qspi_dbi/display.py +2 -3
  517. esphome/components/qspi_dbi/qspi_dbi.cpp +0 -2
  518. esphome/components/qwiic_pir/binary_sensor.py +2 -3
  519. esphome/components/qwiic_pir/qwiic_pir.cpp +0 -2
  520. esphome/components/rc522/rc522.cpp +9 -31
  521. esphome/components/rc522_spi/rc522_spi.cpp +0 -1
  522. esphome/components/remote_base/__init__.py +5 -6
  523. esphome/components/remote_receiver/remote_receiver_esp32.cpp +0 -1
  524. esphome/components/remote_receiver/remote_receiver_esp8266.cpp +0 -1
  525. esphome/components/remote_receiver/remote_receiver_libretiny.cpp +0 -1
  526. esphome/components/remote_transmitter/__init__.py +26 -0
  527. esphome/components/remote_transmitter/automation.h +18 -0
  528. esphome/components/remote_transmitter/remote_transmitter.h +2 -1
  529. esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +0 -1
  530. esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +2 -0
  531. esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +2 -0
  532. esphome/components/resampler/speaker/__init__.py +4 -5
  533. esphome/components/rf_bridge/__init__.py +4 -8
  534. esphome/components/rotary_encoder/rotary_encoder.cpp +0 -2
  535. esphome/components/rp2040/__init__.py +3 -1
  536. esphome/components/rp2040_pio_led_strip/led_strip.cpp +0 -2
  537. esphome/components/rp2040_pio_led_strip/light.py +1 -2
  538. esphome/components/rp2040_pwm/rp2040_pwm.cpp +1 -5
  539. esphome/components/rpi_dpi_rgb/display.py +13 -15
  540. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +0 -3
  541. esphome/components/runtime_stats/__init__.py +34 -0
  542. esphome/components/runtime_stats/runtime_stats.cpp +102 -0
  543. esphome/components/runtime_stats/runtime_stats.h +132 -0
  544. esphome/components/scd30/scd30.cpp +0 -2
  545. esphome/components/scd30/sensor.py +1 -2
  546. esphome/components/scd4x/scd4x.cpp +0 -1
  547. esphome/components/scd4x/sensor.py +1 -3
  548. esphome/components/sdl/display.py +3 -1
  549. esphome/components/sdl/sdl_esphome.cpp +0 -2
  550. esphome/components/sdp3x/sdp3x.cpp +0 -2
  551. esphome/components/seeed_mr24hpc1/seeed_mr24hpc1.cpp +0 -2
  552. esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +0 -3
  553. esphome/components/select/__init__.py +2 -3
  554. esphome/components/select/select_traits.cpp +1 -1
  555. esphome/components/select/select_traits.h +1 -1
  556. esphome/components/sen0321/sen0321.cpp +0 -1
  557. esphome/components/sen5x/sen5x.cpp +0 -2
  558. esphome/components/senseair/senseair.cpp +7 -3
  559. esphome/components/senseair/senseair.h +11 -0
  560. esphome/components/sensor/__init__.py +36 -4
  561. esphome/components/sensor/filter.cpp +49 -10
  562. esphome/components/sensor/filter.h +22 -7
  563. esphome/components/sensor/sensor.cpp +0 -1
  564. esphome/components/sensor/sensor.h +0 -9
  565. esphome/components/sfa30/sfa30.cpp +0 -4
  566. esphome/components/sgp30/sgp30.cpp +0 -2
  567. esphome/components/sgp4x/sensor.py +1 -1
  568. esphome/components/sgp4x/sgp4x.cpp +0 -2
  569. esphome/components/shelly_dimmer/shelly_dimmer.cpp +0 -2
  570. esphome/components/sht3xd/sht3xd.cpp +0 -2
  571. esphome/components/sht4x/sht4x.cpp +0 -2
  572. esphome/components/shtcx/shtcx.cpp +0 -1
  573. esphome/components/sim800l/__init__.py +2 -4
  574. esphome/components/sm16716/sm16716.cpp +0 -1
  575. esphome/components/sm2135/sm2135.cpp +0 -1
  576. esphome/components/sm2235/sm2235.cpp +0 -1
  577. esphome/components/sm2335/sm2335.cpp +0 -1
  578. esphome/components/sn74hc165/sn74hc165.cpp +0 -1
  579. esphome/components/sn74hc595/sn74hc595.cpp +0 -1
  580. esphome/components/sntp/sntp_component.cpp +0 -1
  581. esphome/components/sound_level/sensor.py +1 -1
  582. esphome/components/speaker/media_player/__init__.py +21 -33
  583. esphome/components/speaker/media_player/audio_pipeline.cpp +4 -7
  584. esphome/components/spi/__init__.py +29 -13
  585. esphome/components/spi/spi.cpp +0 -2
  586. esphome/components/spi_device/spi_device.cpp +1 -4
  587. esphome/components/sprinkler/__init__.py +4 -4
  588. esphome/components/sps30/sps30.cpp +0 -1
  589. esphome/components/ssd1306_base/__init__.py +11 -11
  590. esphome/components/ssd1306_base/ssd1306_base.cpp +1 -1
  591. esphome/components/ssd1306_i2c/ssd1306_i2c.cpp +0 -1
  592. esphome/components/ssd1306_spi/ssd1306_spi.cpp +0 -1
  593. esphome/components/ssd1322_spi/ssd1322_spi.cpp +0 -1
  594. esphome/components/ssd1325_spi/ssd1325_spi.cpp +0 -1
  595. esphome/components/ssd1327_i2c/ssd1327_i2c.cpp +0 -1
  596. esphome/components/ssd1327_spi/ssd1327_spi.cpp +0 -1
  597. esphome/components/ssd1331_spi/ssd1331_spi.cpp +0 -1
  598. esphome/components/ssd1351_spi/ssd1351_spi.cpp +0 -1
  599. esphome/components/st7567_i2c/st7567_i2c.cpp +0 -1
  600. esphome/components/st7567_spi/st7567_spi.cpp +0 -1
  601. esphome/components/st7701s/display.py +10 -14
  602. esphome/components/st7701s/st7701s.cpp +0 -3
  603. esphome/components/st7735/st7735.cpp +0 -1
  604. esphome/components/st7789v/st7789v.cpp +0 -1
  605. esphome/components/st7920/st7920.cpp +0 -1
  606. esphome/components/status_led/light/status_led_light.cpp +0 -2
  607. esphome/components/status_led/status_led.cpp +0 -1
  608. esphome/components/stepper/__init__.py +2 -4
  609. esphome/components/sts3x/sts3x.cpp +0 -1
  610. esphome/components/substitutions/__init__.py +10 -16
  611. esphome/components/substitutions/jinja.py +24 -1
  612. esphome/components/sun/__init__.py +2 -3
  613. esphome/components/switch/__init__.py +31 -1
  614. esphome/components/switch/automation.h +24 -0
  615. esphome/components/switch/switch.cpp +8 -0
  616. esphome/components/switch/switch.h +8 -0
  617. esphome/components/sx126x/sx126x.cpp +0 -2
  618. esphome/components/sx127x/sx127x.cpp +0 -2
  619. esphome/components/sx1509/__init__.py +7 -5
  620. esphome/components/sx1509/output/sx1509_float_output.cpp +1 -1
  621. esphome/components/sx1509/sx1509.cpp +0 -2
  622. esphome/components/syslog/esphome_syslog.cpp +1 -1
  623. esphome/components/tc74/tc74.cpp +0 -1
  624. esphome/components/tca9548a/tca9548a.cpp +0 -1
  625. esphome/components/tca9555/tca9555.cpp +0 -1
  626. esphome/components/tcs34725/tcs34725.cpp +0 -1
  627. esphome/components/tee501/tee501.cpp +0 -1
  628. esphome/components/tem3200/tem3200.cpp +0 -2
  629. esphome/components/template/alarm_control_panel/template_alarm_control_panel.cpp +0 -1
  630. esphome/components/template/cover/template_cover.cpp +0 -1
  631. esphome/components/template/select/template_select.cpp +0 -1
  632. esphome/components/template/text/template_text.cpp +0 -2
  633. esphome/components/template/valve/template_valve.cpp +0 -1
  634. esphome/components/text/__init__.py +0 -1
  635. esphome/components/text/text_traits.h +2 -0
  636. esphome/components/text_sensor/__init__.py +2 -1
  637. esphome/components/text_sensor/text_sensor.cpp +0 -2
  638. esphome/components/text_sensor/text_sensor.h +0 -8
  639. esphome/components/thermostat/climate.py +4 -4
  640. esphome/components/time/__init__.py +7 -4
  641. esphome/components/time/real_time_clock.cpp +16 -3
  642. esphome/components/tlc59208f/tlc59208f_output.cpp +0 -2
  643. esphome/components/tlc5947/tlc5947.cpp +0 -2
  644. esphome/components/tlc5971/tlc5971.cpp +0 -2
  645. esphome/components/tm1621/tm1621.cpp +0 -2
  646. esphome/components/tm1637/tm1637.cpp +0 -2
  647. esphome/components/tm1638/tm1638.cpp +0 -2
  648. esphome/components/tm1651/__init__.py +45 -48
  649. esphome/components/tm1651/tm1651.cpp +213 -47
  650. esphome/components/tm1651/tm1651.h +37 -32
  651. esphome/components/tmp117/tmp117.cpp +0 -2
  652. esphome/components/tsl2561/tsl2561.cpp +0 -1
  653. esphome/components/tsl2591/tsl2591.cpp +0 -1
  654. esphome/components/tt21100/touchscreen/tt21100.cpp +0 -2
  655. esphome/components/ttp229_bsf/ttp229_bsf.cpp +0 -1
  656. esphome/components/ttp229_lsf/ttp229_lsf.cpp +0 -1
  657. esphome/components/tuya/climate/__init__.py +9 -10
  658. esphome/components/tuya/number/__init__.py +8 -6
  659. esphome/components/tx20/tx20.cpp +0 -1
  660. esphome/components/uart/uart_component_esp32_arduino.cpp +0 -1
  661. esphome/components/uart/uart_component_esp8266.cpp +0 -1
  662. esphome/components/uart/uart_component_esp_idf.cpp +0 -2
  663. esphome/components/uart/uart_component_libretiny.cpp +0 -2
  664. esphome/components/uart/uart_component_rp2040.cpp +0 -2
  665. esphome/components/udp/__init__.py +1 -1
  666. esphome/components/ufire_ec/sensor.py +1 -2
  667. esphome/components/ufire_ec/ufire_ec.cpp +0 -2
  668. esphome/components/ufire_ise/sensor.py +1 -2
  669. esphome/components/ufire_ise/ufire_ise.cpp +0 -2
  670. esphome/components/ultrasonic/ultrasonic_sensor.cpp +0 -1
  671. esphome/components/update/__init__.py +0 -1
  672. esphome/components/uptime/sensor/uptime_seconds_sensor.cpp +0 -1
  673. esphome/components/uptime/sensor/uptime_seconds_sensor.h +0 -2
  674. esphome/components/usb_host/usb_host_client.cpp +0 -1
  675. esphome/components/usb_host/usb_host_component.cpp +0 -1
  676. esphome/components/valve/__init__.py +0 -1
  677. esphome/components/veml3235/veml3235.cpp +0 -3
  678. esphome/components/veml7700/veml7700.cpp +0 -2
  679. esphome/components/version/version_text_sensor.cpp +0 -1
  680. esphome/components/version/version_text_sensor.h +0 -1
  681. esphome/components/vl53l0x/vl53l0x_sensor.cpp +0 -4
  682. esphome/components/voice_assistant/voice_assistant.cpp +9 -8
  683. esphome/components/web_server/__init__.py +13 -0
  684. esphome/components/web_server/web_server.cpp +188 -353
  685. esphome/components/web_server/web_server.h +61 -1
  686. esphome/components/web_server_base/__init__.py +1 -1
  687. esphome/components/web_server_base/web_server_base.cpp +2 -0
  688. esphome/components/web_server_base/web_server_base.h +6 -0
  689. esphome/components/web_server_idf/web_server_idf.cpp +10 -8
  690. esphome/components/web_server_idf/web_server_idf.h +2 -0
  691. esphome/components/weikai_i2c/weikai_i2c.cpp +1 -2
  692. esphome/components/weikai_spi/weikai_spi.cpp +1 -1
  693. esphome/components/wifi/__init__.py +17 -43
  694. esphome/components/wifi/wifi_component.cpp +100 -36
  695. esphome/components/wifi/wifi_component.h +5 -1
  696. esphome/components/wifi/wifi_component_esp32_arduino.cpp +30 -0
  697. esphome/components/wifi/wifi_component_esp_idf.cpp +30 -0
  698. esphome/components/wifi_info/wifi_info_text_sensor.h +0 -6
  699. esphome/components/wifi_signal/wifi_signal_sensor.h +0 -1
  700. esphome/components/wireguard/wireguard.cpp +0 -2
  701. esphome/components/x9c/x9c.cpp +0 -2
  702. esphome/components/xgzp68xx/xgzp68xx.cpp +0 -1
  703. esphome/components/xl9535/xl9535.cpp +0 -2
  704. esphome/components/zephyr/__init__.py +252 -0
  705. esphome/components/zephyr/const.py +16 -0
  706. esphome/components/zephyr/core.cpp +90 -0
  707. esphome/components/zephyr/gpio.cpp +120 -0
  708. esphome/components/zephyr/gpio.h +38 -0
  709. esphome/components/zephyr/pre_build.py.script +4 -0
  710. esphome/components/zephyr/preferences.cpp +156 -0
  711. esphome/components/zephyr/preferences.h +13 -0
  712. esphome/config.py +38 -16
  713. esphome/config_helpers.py +1 -2
  714. esphome/config_validation.py +12 -16
  715. esphome/const.py +26 -1
  716. esphome/core/__init__.py +92 -51
  717. esphome/core/application.cpp +75 -21
  718. esphome/core/application.h +106 -171
  719. esphome/core/color.h +10 -0
  720. esphome/core/component.cpp +41 -25
  721. esphome/core/component.h +9 -6
  722. esphome/core/component_iterator.cpp +61 -261
  723. esphome/core/component_iterator.h +15 -0
  724. esphome/core/config.py +26 -11
  725. esphome/core/defines.h +40 -2
  726. esphome/core/entity_base.h +18 -0
  727. esphome/core/entity_helpers.py +45 -10
  728. esphome/core/helpers.cpp +8 -15
  729. esphome/core/helpers.h +60 -6
  730. esphome/core/lock_free_queue.h +1 -1
  731. esphome/core/scheduler.cpp +311 -77
  732. esphome/core/scheduler.h +141 -28
  733. esphome/cpp_generator.py +2 -6
  734. esphome/cpp_helpers.py +1 -1
  735. esphome/dashboard/dashboard.py +2 -3
  736. esphome/dashboard/dns.py +2 -8
  737. esphome/dashboard/web_server.py +34 -19
  738. esphome/espota2.py +1 -4
  739. esphome/git.py +3 -1
  740. esphome/helpers.py +23 -4
  741. esphome/log.py +3 -1
  742. esphome/mqtt.py +3 -5
  743. esphome/platformio_api.py +7 -4
  744. esphome/types.py +12 -0
  745. esphome/util.py +20 -8
  746. esphome/voluptuous_schema.py +4 -3
  747. esphome/vscode.py +1 -2
  748. esphome/wizard.py +1 -4
  749. esphome/writer.py +16 -108
  750. esphome/yaml_util.py +7 -5
  751. {esphome-2025.7.4.dist-info → esphome-2025.8.0.dist-info}/METADATA +13 -14
  752. {esphome-2025.7.4.dist-info → esphome-2025.8.0.dist-info}/RECORD +757 -677
  753. esphome/components/mipi_spi/models/commands.py +0 -82
  754. /esphome/components/nfc/binary_sensor/{binary_sensor.h → nfc_binary_sensor.h} +0 -0
  755. {esphome-2025.7.4.dist-info → esphome-2025.8.0.dist-info}/WHEEL +0 -0
  756. {esphome-2025.7.4.dist-info → esphome-2025.8.0.dist-info}/entry_points.txt +0 -0
  757. {esphome-2025.7.4.dist-info → esphome-2025.8.0.dist-info}/licenses/LICENSE +0 -0
  758. {esphome-2025.7.4.dist-info → esphome-2025.8.0.dist-info}/top_level.txt +0 -0
@@ -3,488 +3,495 @@
3
3
  #include "api_pb2.h"
4
4
  #include "esphome/core/log.h"
5
5
  #include "esphome/core/helpers.h"
6
+ #include <cstring>
6
7
 
7
- namespace esphome {
8
- namespace api {
8
+ namespace esphome::api {
9
9
 
10
10
  bool HelloRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
11
11
  switch (field_id) {
12
- case 2: {
12
+ case 2:
13
13
  this->api_version_major = value.as_uint32();
14
- return true;
15
- }
16
- case 3: {
14
+ break;
15
+ case 3:
17
16
  this->api_version_minor = value.as_uint32();
18
- return true;
19
- }
17
+ break;
20
18
  default:
21
19
  return false;
22
20
  }
21
+ return true;
23
22
  }
24
23
  bool HelloRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
25
24
  switch (field_id) {
26
- case 1: {
25
+ case 1:
27
26
  this->client_info = value.as_string();
28
- return true;
29
- }
27
+ break;
30
28
  default:
31
29
  return false;
32
30
  }
31
+ return true;
33
32
  }
34
33
  void HelloResponse::encode(ProtoWriteBuffer buffer) const {
35
34
  buffer.encode_uint32(1, this->api_version_major);
36
35
  buffer.encode_uint32(2, this->api_version_minor);
37
- buffer.encode_string(3, this->server_info);
38
- buffer.encode_string(4, this->name);
36
+ buffer.encode_string(3, this->server_info_ref_);
37
+ buffer.encode_string(4, this->name_ref_);
39
38
  }
40
- void HelloResponse::calculate_size(uint32_t &total_size) const {
41
- ProtoSize::add_uint32_field(total_size, 1, this->api_version_major);
42
- ProtoSize::add_uint32_field(total_size, 1, this->api_version_minor);
43
- ProtoSize::add_string_field(total_size, 1, this->server_info);
44
- ProtoSize::add_string_field(total_size, 1, this->name);
39
+ void HelloResponse::calculate_size(ProtoSize &size) const {
40
+ size.add_uint32(1, this->api_version_major);
41
+ size.add_uint32(1, this->api_version_minor);
42
+ size.add_length(1, this->server_info_ref_.size());
43
+ size.add_length(1, this->name_ref_.size());
45
44
  }
46
45
  bool ConnectRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
47
46
  switch (field_id) {
48
- case 1: {
47
+ case 1:
49
48
  this->password = value.as_string();
50
- return true;
51
- }
49
+ break;
52
50
  default:
53
51
  return false;
54
52
  }
53
+ return true;
55
54
  }
56
55
  void ConnectResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->invalid_password); }
57
- void ConnectResponse::calculate_size(uint32_t &total_size) const {
58
- ProtoSize::add_bool_field(total_size, 1, this->invalid_password);
59
- }
60
- bool AreaInfo::decode_varint(uint32_t field_id, ProtoVarInt value) {
61
- switch (field_id) {
62
- case 1: {
63
- this->area_id = value.as_uint32();
64
- return true;
65
- }
66
- default:
67
- return false;
68
- }
69
- }
70
- bool AreaInfo::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
71
- switch (field_id) {
72
- case 2: {
73
- this->name = value.as_string();
74
- return true;
75
- }
76
- default:
77
- return false;
78
- }
79
- }
56
+ void ConnectResponse::calculate_size(ProtoSize &size) const { size.add_bool(1, this->invalid_password); }
57
+ #ifdef USE_AREAS
80
58
  void AreaInfo::encode(ProtoWriteBuffer buffer) const {
81
59
  buffer.encode_uint32(1, this->area_id);
82
- buffer.encode_string(2, this->name);
60
+ buffer.encode_string(2, this->name_ref_);
83
61
  }
84
- void AreaInfo::calculate_size(uint32_t &total_size) const {
85
- ProtoSize::add_uint32_field(total_size, 1, this->area_id);
86
- ProtoSize::add_string_field(total_size, 1, this->name);
87
- }
88
- bool DeviceInfo::decode_varint(uint32_t field_id, ProtoVarInt value) {
89
- switch (field_id) {
90
- case 1: {
91
- this->device_id = value.as_uint32();
92
- return true;
93
- }
94
- case 3: {
95
- this->area_id = value.as_uint32();
96
- return true;
97
- }
98
- default:
99
- return false;
100
- }
101
- }
102
- bool DeviceInfo::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
103
- switch (field_id) {
104
- case 2: {
105
- this->name = value.as_string();
106
- return true;
107
- }
108
- default:
109
- return false;
110
- }
62
+ void AreaInfo::calculate_size(ProtoSize &size) const {
63
+ size.add_uint32(1, this->area_id);
64
+ size.add_length(1, this->name_ref_.size());
111
65
  }
66
+ #endif
67
+ #ifdef USE_DEVICES
112
68
  void DeviceInfo::encode(ProtoWriteBuffer buffer) const {
113
69
  buffer.encode_uint32(1, this->device_id);
114
- buffer.encode_string(2, this->name);
70
+ buffer.encode_string(2, this->name_ref_);
115
71
  buffer.encode_uint32(3, this->area_id);
116
72
  }
117
- void DeviceInfo::calculate_size(uint32_t &total_size) const {
118
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
119
- ProtoSize::add_string_field(total_size, 1, this->name);
120
- ProtoSize::add_uint32_field(total_size, 1, this->area_id);
73
+ void DeviceInfo::calculate_size(ProtoSize &size) const {
74
+ size.add_uint32(1, this->device_id);
75
+ size.add_length(1, this->name_ref_.size());
76
+ size.add_uint32(1, this->area_id);
121
77
  }
78
+ #endif
122
79
  void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const {
80
+ #ifdef USE_API_PASSWORD
123
81
  buffer.encode_bool(1, this->uses_password);
124
- buffer.encode_string(2, this->name);
125
- buffer.encode_string(3, this->mac_address);
126
- buffer.encode_string(4, this->esphome_version);
127
- buffer.encode_string(5, this->compilation_time);
128
- buffer.encode_string(6, this->model);
82
+ #endif
83
+ buffer.encode_string(2, this->name_ref_);
84
+ buffer.encode_string(3, this->mac_address_ref_);
85
+ buffer.encode_string(4, this->esphome_version_ref_);
86
+ buffer.encode_string(5, this->compilation_time_ref_);
87
+ buffer.encode_string(6, this->model_ref_);
88
+ #ifdef USE_DEEP_SLEEP
129
89
  buffer.encode_bool(7, this->has_deep_sleep);
130
- buffer.encode_string(8, this->project_name);
131
- buffer.encode_string(9, this->project_version);
90
+ #endif
91
+ #ifdef ESPHOME_PROJECT_NAME
92
+ buffer.encode_string(8, this->project_name_ref_);
93
+ #endif
94
+ #ifdef ESPHOME_PROJECT_NAME
95
+ buffer.encode_string(9, this->project_version_ref_);
96
+ #endif
97
+ #ifdef USE_WEBSERVER
132
98
  buffer.encode_uint32(10, this->webserver_port);
133
- buffer.encode_uint32(11, this->legacy_bluetooth_proxy_version);
99
+ #endif
100
+ #ifdef USE_BLUETOOTH_PROXY
134
101
  buffer.encode_uint32(15, this->bluetooth_proxy_feature_flags);
135
- buffer.encode_string(12, this->manufacturer);
136
- buffer.encode_string(13, this->friendly_name);
137
- buffer.encode_uint32(14, this->legacy_voice_assistant_version);
102
+ #endif
103
+ buffer.encode_string(12, this->manufacturer_ref_);
104
+ buffer.encode_string(13, this->friendly_name_ref_);
105
+ #ifdef USE_VOICE_ASSISTANT
138
106
  buffer.encode_uint32(17, this->voice_assistant_feature_flags);
139
- buffer.encode_string(16, this->suggested_area);
140
- buffer.encode_string(18, this->bluetooth_mac_address);
107
+ #endif
108
+ #ifdef USE_AREAS
109
+ buffer.encode_string(16, this->suggested_area_ref_);
110
+ #endif
111
+ #ifdef USE_BLUETOOTH_PROXY
112
+ buffer.encode_string(18, this->bluetooth_mac_address_ref_);
113
+ #endif
114
+ #ifdef USE_API_NOISE
141
115
  buffer.encode_bool(19, this->api_encryption_supported);
142
- for (auto &it : this->devices) {
116
+ #endif
117
+ #ifdef USE_DEVICES
118
+ for (const auto &it : this->devices) {
143
119
  buffer.encode_message(20, it, true);
144
120
  }
145
- for (auto &it : this->areas) {
121
+ #endif
122
+ #ifdef USE_AREAS
123
+ for (const auto &it : this->areas) {
146
124
  buffer.encode_message(21, it, true);
147
125
  }
126
+ #endif
127
+ #ifdef USE_AREAS
148
128
  buffer.encode_message(22, this->area);
129
+ #endif
149
130
  }
150
- void DeviceInfoResponse::calculate_size(uint32_t &total_size) const {
151
- ProtoSize::add_bool_field(total_size, 1, this->uses_password);
152
- ProtoSize::add_string_field(total_size, 1, this->name);
153
- ProtoSize::add_string_field(total_size, 1, this->mac_address);
154
- ProtoSize::add_string_field(total_size, 1, this->esphome_version);
155
- ProtoSize::add_string_field(total_size, 1, this->compilation_time);
156
- ProtoSize::add_string_field(total_size, 1, this->model);
157
- ProtoSize::add_bool_field(total_size, 1, this->has_deep_sleep);
158
- ProtoSize::add_string_field(total_size, 1, this->project_name);
159
- ProtoSize::add_string_field(total_size, 1, this->project_version);
160
- ProtoSize::add_uint32_field(total_size, 1, this->webserver_port);
161
- ProtoSize::add_uint32_field(total_size, 1, this->legacy_bluetooth_proxy_version);
162
- ProtoSize::add_uint32_field(total_size, 1, this->bluetooth_proxy_feature_flags);
163
- ProtoSize::add_string_field(total_size, 1, this->manufacturer);
164
- ProtoSize::add_string_field(total_size, 1, this->friendly_name);
165
- ProtoSize::add_uint32_field(total_size, 1, this->legacy_voice_assistant_version);
166
- ProtoSize::add_uint32_field(total_size, 2, this->voice_assistant_feature_flags);
167
- ProtoSize::add_string_field(total_size, 2, this->suggested_area);
168
- ProtoSize::add_string_field(total_size, 2, this->bluetooth_mac_address);
169
- ProtoSize::add_bool_field(total_size, 2, this->api_encryption_supported);
170
- ProtoSize::add_repeated_message(total_size, 2, this->devices);
171
- ProtoSize::add_repeated_message(total_size, 2, this->areas);
172
- ProtoSize::add_message_object(total_size, 2, this->area);
131
+ void DeviceInfoResponse::calculate_size(ProtoSize &size) const {
132
+ #ifdef USE_API_PASSWORD
133
+ size.add_bool(1, this->uses_password);
134
+ #endif
135
+ size.add_length(1, this->name_ref_.size());
136
+ size.add_length(1, this->mac_address_ref_.size());
137
+ size.add_length(1, this->esphome_version_ref_.size());
138
+ size.add_length(1, this->compilation_time_ref_.size());
139
+ size.add_length(1, this->model_ref_.size());
140
+ #ifdef USE_DEEP_SLEEP
141
+ size.add_bool(1, this->has_deep_sleep);
142
+ #endif
143
+ #ifdef ESPHOME_PROJECT_NAME
144
+ size.add_length(1, this->project_name_ref_.size());
145
+ #endif
146
+ #ifdef ESPHOME_PROJECT_NAME
147
+ size.add_length(1, this->project_version_ref_.size());
148
+ #endif
149
+ #ifdef USE_WEBSERVER
150
+ size.add_uint32(1, this->webserver_port);
151
+ #endif
152
+ #ifdef USE_BLUETOOTH_PROXY
153
+ size.add_uint32(1, this->bluetooth_proxy_feature_flags);
154
+ #endif
155
+ size.add_length(1, this->manufacturer_ref_.size());
156
+ size.add_length(1, this->friendly_name_ref_.size());
157
+ #ifdef USE_VOICE_ASSISTANT
158
+ size.add_uint32(2, this->voice_assistant_feature_flags);
159
+ #endif
160
+ #ifdef USE_AREAS
161
+ size.add_length(2, this->suggested_area_ref_.size());
162
+ #endif
163
+ #ifdef USE_BLUETOOTH_PROXY
164
+ size.add_length(2, this->bluetooth_mac_address_ref_.size());
165
+ #endif
166
+ #ifdef USE_API_NOISE
167
+ size.add_bool(2, this->api_encryption_supported);
168
+ #endif
169
+ #ifdef USE_DEVICES
170
+ for (const auto &it : this->devices) {
171
+ size.add_message_object_force(2, it);
172
+ }
173
+ #endif
174
+ #ifdef USE_AREAS
175
+ for (const auto &it : this->areas) {
176
+ size.add_message_object_force(2, it);
177
+ }
178
+ #endif
179
+ #ifdef USE_AREAS
180
+ size.add_message_object(2, this->area);
181
+ #endif
173
182
  }
174
183
  #ifdef USE_BINARY_SENSOR
175
184
  void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const {
176
- buffer.encode_string(1, this->object_id);
185
+ buffer.encode_string(1, this->object_id_ref_);
177
186
  buffer.encode_fixed32(2, this->key);
178
- buffer.encode_string(3, this->name);
179
- buffer.encode_string(4, this->unique_id);
180
- buffer.encode_string(5, this->device_class);
187
+ buffer.encode_string(3, this->name_ref_);
188
+ buffer.encode_string(5, this->device_class_ref_);
181
189
  buffer.encode_bool(6, this->is_status_binary_sensor);
182
190
  buffer.encode_bool(7, this->disabled_by_default);
183
- buffer.encode_string(8, this->icon);
191
+ #ifdef USE_ENTITY_ICON
192
+ buffer.encode_string(8, this->icon_ref_);
193
+ #endif
184
194
  buffer.encode_uint32(9, static_cast<uint32_t>(this->entity_category));
195
+ #ifdef USE_DEVICES
185
196
  buffer.encode_uint32(10, this->device_id);
197
+ #endif
186
198
  }
187
- void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) const {
188
- ProtoSize::add_string_field(total_size, 1, this->object_id);
189
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
190
- ProtoSize::add_string_field(total_size, 1, this->name);
191
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
192
- ProtoSize::add_string_field(total_size, 1, this->device_class);
193
- ProtoSize::add_bool_field(total_size, 1, this->is_status_binary_sensor);
194
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
195
- ProtoSize::add_string_field(total_size, 1, this->icon);
196
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
197
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
199
+ void ListEntitiesBinarySensorResponse::calculate_size(ProtoSize &size) const {
200
+ size.add_length(1, this->object_id_ref_.size());
201
+ size.add_fixed32(1, this->key);
202
+ size.add_length(1, this->name_ref_.size());
203
+ size.add_length(1, this->device_class_ref_.size());
204
+ size.add_bool(1, this->is_status_binary_sensor);
205
+ size.add_bool(1, this->disabled_by_default);
206
+ #ifdef USE_ENTITY_ICON
207
+ size.add_length(1, this->icon_ref_.size());
208
+ #endif
209
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
210
+ #ifdef USE_DEVICES
211
+ size.add_uint32(1, this->device_id);
212
+ #endif
198
213
  }
199
214
  void BinarySensorStateResponse::encode(ProtoWriteBuffer buffer) const {
200
215
  buffer.encode_fixed32(1, this->key);
201
216
  buffer.encode_bool(2, this->state);
202
217
  buffer.encode_bool(3, this->missing_state);
218
+ #ifdef USE_DEVICES
203
219
  buffer.encode_uint32(4, this->device_id);
220
+ #endif
204
221
  }
205
- void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const {
206
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
207
- ProtoSize::add_bool_field(total_size, 1, this->state);
208
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
209
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
222
+ void BinarySensorStateResponse::calculate_size(ProtoSize &size) const {
223
+ size.add_fixed32(1, this->key);
224
+ size.add_bool(1, this->state);
225
+ size.add_bool(1, this->missing_state);
226
+ #ifdef USE_DEVICES
227
+ size.add_uint32(1, this->device_id);
228
+ #endif
210
229
  }
211
230
  #endif
212
231
  #ifdef USE_COVER
213
232
  void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const {
214
- buffer.encode_string(1, this->object_id);
233
+ buffer.encode_string(1, this->object_id_ref_);
215
234
  buffer.encode_fixed32(2, this->key);
216
- buffer.encode_string(3, this->name);
217
- buffer.encode_string(4, this->unique_id);
235
+ buffer.encode_string(3, this->name_ref_);
218
236
  buffer.encode_bool(5, this->assumed_state);
219
237
  buffer.encode_bool(6, this->supports_position);
220
238
  buffer.encode_bool(7, this->supports_tilt);
221
- buffer.encode_string(8, this->device_class);
239
+ buffer.encode_string(8, this->device_class_ref_);
222
240
  buffer.encode_bool(9, this->disabled_by_default);
223
- buffer.encode_string(10, this->icon);
241
+ #ifdef USE_ENTITY_ICON
242
+ buffer.encode_string(10, this->icon_ref_);
243
+ #endif
224
244
  buffer.encode_uint32(11, static_cast<uint32_t>(this->entity_category));
225
245
  buffer.encode_bool(12, this->supports_stop);
246
+ #ifdef USE_DEVICES
226
247
  buffer.encode_uint32(13, this->device_id);
248
+ #endif
227
249
  }
228
- void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const {
229
- ProtoSize::add_string_field(total_size, 1, this->object_id);
230
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
231
- ProtoSize::add_string_field(total_size, 1, this->name);
232
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
233
- ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
234
- ProtoSize::add_bool_field(total_size, 1, this->supports_position);
235
- ProtoSize::add_bool_field(total_size, 1, this->supports_tilt);
236
- ProtoSize::add_string_field(total_size, 1, this->device_class);
237
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
238
- ProtoSize::add_string_field(total_size, 1, this->icon);
239
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
240
- ProtoSize::add_bool_field(total_size, 1, this->supports_stop);
241
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
250
+ void ListEntitiesCoverResponse::calculate_size(ProtoSize &size) const {
251
+ size.add_length(1, this->object_id_ref_.size());
252
+ size.add_fixed32(1, this->key);
253
+ size.add_length(1, this->name_ref_.size());
254
+ size.add_bool(1, this->assumed_state);
255
+ size.add_bool(1, this->supports_position);
256
+ size.add_bool(1, this->supports_tilt);
257
+ size.add_length(1, this->device_class_ref_.size());
258
+ size.add_bool(1, this->disabled_by_default);
259
+ #ifdef USE_ENTITY_ICON
260
+ size.add_length(1, this->icon_ref_.size());
261
+ #endif
262
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
263
+ size.add_bool(1, this->supports_stop);
264
+ #ifdef USE_DEVICES
265
+ size.add_uint32(1, this->device_id);
266
+ #endif
242
267
  }
243
268
  void CoverStateResponse::encode(ProtoWriteBuffer buffer) const {
244
269
  buffer.encode_fixed32(1, this->key);
245
- buffer.encode_uint32(2, static_cast<uint32_t>(this->legacy_state));
246
270
  buffer.encode_float(3, this->position);
247
271
  buffer.encode_float(4, this->tilt);
248
272
  buffer.encode_uint32(5, static_cast<uint32_t>(this->current_operation));
273
+ #ifdef USE_DEVICES
249
274
  buffer.encode_uint32(6, this->device_id);
275
+ #endif
250
276
  }
251
- void CoverStateResponse::calculate_size(uint32_t &total_size) const {
252
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
253
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_state));
254
- ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f);
255
- ProtoSize::add_fixed_field<4>(total_size, 1, this->tilt != 0.0f);
256
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
257
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
277
+ void CoverStateResponse::calculate_size(ProtoSize &size) const {
278
+ size.add_fixed32(1, this->key);
279
+ size.add_float(1, this->position);
280
+ size.add_float(1, this->tilt);
281
+ size.add_uint32(1, static_cast<uint32_t>(this->current_operation));
282
+ #ifdef USE_DEVICES
283
+ size.add_uint32(1, this->device_id);
284
+ #endif
258
285
  }
259
286
  bool CoverCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
260
287
  switch (field_id) {
261
- case 2: {
262
- this->has_legacy_command = value.as_bool();
263
- return true;
264
- }
265
- case 3: {
266
- this->legacy_command = static_cast<enums::LegacyCoverCommand>(value.as_uint32());
267
- return true;
268
- }
269
- case 4: {
288
+ case 4:
270
289
  this->has_position = value.as_bool();
271
- return true;
272
- }
273
- case 6: {
290
+ break;
291
+ case 6:
274
292
  this->has_tilt = value.as_bool();
275
- return true;
276
- }
277
- case 8: {
293
+ break;
294
+ case 8:
278
295
  this->stop = value.as_bool();
279
- return true;
280
- }
281
- case 9: {
296
+ break;
297
+ #ifdef USE_DEVICES
298
+ case 9:
282
299
  this->device_id = value.as_uint32();
283
- return true;
284
- }
300
+ break;
301
+ #endif
285
302
  default:
286
303
  return false;
287
304
  }
305
+ return true;
288
306
  }
289
307
  bool CoverCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
290
308
  switch (field_id) {
291
- case 1: {
309
+ case 1:
292
310
  this->key = value.as_fixed32();
293
- return true;
294
- }
295
- case 5: {
311
+ break;
312
+ case 5:
296
313
  this->position = value.as_float();
297
- return true;
298
- }
299
- case 7: {
314
+ break;
315
+ case 7:
300
316
  this->tilt = value.as_float();
301
- return true;
302
- }
317
+ break;
303
318
  default:
304
319
  return false;
305
320
  }
321
+ return true;
306
322
  }
307
323
  #endif
308
324
  #ifdef USE_FAN
309
325
  void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const {
310
- buffer.encode_string(1, this->object_id);
326
+ buffer.encode_string(1, this->object_id_ref_);
311
327
  buffer.encode_fixed32(2, this->key);
312
- buffer.encode_string(3, this->name);
313
- buffer.encode_string(4, this->unique_id);
328
+ buffer.encode_string(3, this->name_ref_);
314
329
  buffer.encode_bool(5, this->supports_oscillation);
315
330
  buffer.encode_bool(6, this->supports_speed);
316
331
  buffer.encode_bool(7, this->supports_direction);
317
332
  buffer.encode_int32(8, this->supported_speed_count);
318
333
  buffer.encode_bool(9, this->disabled_by_default);
319
- buffer.encode_string(10, this->icon);
334
+ #ifdef USE_ENTITY_ICON
335
+ buffer.encode_string(10, this->icon_ref_);
336
+ #endif
320
337
  buffer.encode_uint32(11, static_cast<uint32_t>(this->entity_category));
321
- for (auto &it : this->supported_preset_modes) {
338
+ for (const auto &it : *this->supported_preset_modes) {
322
339
  buffer.encode_string(12, it, true);
323
340
  }
341
+ #ifdef USE_DEVICES
324
342
  buffer.encode_uint32(13, this->device_id);
343
+ #endif
325
344
  }
326
- void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const {
327
- ProtoSize::add_string_field(total_size, 1, this->object_id);
328
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
329
- ProtoSize::add_string_field(total_size, 1, this->name);
330
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
331
- ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation);
332
- ProtoSize::add_bool_field(total_size, 1, this->supports_speed);
333
- ProtoSize::add_bool_field(total_size, 1, this->supports_direction);
334
- ProtoSize::add_int32_field(total_size, 1, this->supported_speed_count);
335
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
336
- ProtoSize::add_string_field(total_size, 1, this->icon);
337
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
338
- if (!this->supported_preset_modes.empty()) {
339
- for (const auto &it : this->supported_preset_modes) {
340
- ProtoSize::add_string_field_repeated(total_size, 1, it);
345
+ void ListEntitiesFanResponse::calculate_size(ProtoSize &size) const {
346
+ size.add_length(1, this->object_id_ref_.size());
347
+ size.add_fixed32(1, this->key);
348
+ size.add_length(1, this->name_ref_.size());
349
+ size.add_bool(1, this->supports_oscillation);
350
+ size.add_bool(1, this->supports_speed);
351
+ size.add_bool(1, this->supports_direction);
352
+ size.add_int32(1, this->supported_speed_count);
353
+ size.add_bool(1, this->disabled_by_default);
354
+ #ifdef USE_ENTITY_ICON
355
+ size.add_length(1, this->icon_ref_.size());
356
+ #endif
357
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
358
+ if (!this->supported_preset_modes->empty()) {
359
+ for (const auto &it : *this->supported_preset_modes) {
360
+ size.add_length_force(1, it.size());
341
361
  }
342
362
  }
343
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
363
+ #ifdef USE_DEVICES
364
+ size.add_uint32(1, this->device_id);
365
+ #endif
344
366
  }
345
367
  void FanStateResponse::encode(ProtoWriteBuffer buffer) const {
346
368
  buffer.encode_fixed32(1, this->key);
347
369
  buffer.encode_bool(2, this->state);
348
370
  buffer.encode_bool(3, this->oscillating);
349
- buffer.encode_uint32(4, static_cast<uint32_t>(this->speed));
350
371
  buffer.encode_uint32(5, static_cast<uint32_t>(this->direction));
351
372
  buffer.encode_int32(6, this->speed_level);
352
- buffer.encode_string(7, this->preset_mode);
373
+ buffer.encode_string(7, this->preset_mode_ref_);
374
+ #ifdef USE_DEVICES
353
375
  buffer.encode_uint32(8, this->device_id);
376
+ #endif
354
377
  }
355
- void FanStateResponse::calculate_size(uint32_t &total_size) const {
356
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
357
- ProtoSize::add_bool_field(total_size, 1, this->state);
358
- ProtoSize::add_bool_field(total_size, 1, this->oscillating);
359
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->speed));
360
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->direction));
361
- ProtoSize::add_int32_field(total_size, 1, this->speed_level);
362
- ProtoSize::add_string_field(total_size, 1, this->preset_mode);
363
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
378
+ void FanStateResponse::calculate_size(ProtoSize &size) const {
379
+ size.add_fixed32(1, this->key);
380
+ size.add_bool(1, this->state);
381
+ size.add_bool(1, this->oscillating);
382
+ size.add_uint32(1, static_cast<uint32_t>(this->direction));
383
+ size.add_int32(1, this->speed_level);
384
+ size.add_length(1, this->preset_mode_ref_.size());
385
+ #ifdef USE_DEVICES
386
+ size.add_uint32(1, this->device_id);
387
+ #endif
364
388
  }
365
389
  bool FanCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
366
390
  switch (field_id) {
367
- case 2: {
391
+ case 2:
368
392
  this->has_state = value.as_bool();
369
- return true;
370
- }
371
- case 3: {
393
+ break;
394
+ case 3:
372
395
  this->state = value.as_bool();
373
- return true;
374
- }
375
- case 4: {
376
- this->has_speed = value.as_bool();
377
- return true;
378
- }
379
- case 5: {
380
- this->speed = static_cast<enums::FanSpeed>(value.as_uint32());
381
- return true;
382
- }
383
- case 6: {
396
+ break;
397
+ case 6:
384
398
  this->has_oscillating = value.as_bool();
385
- return true;
386
- }
387
- case 7: {
399
+ break;
400
+ case 7:
388
401
  this->oscillating = value.as_bool();
389
- return true;
390
- }
391
- case 8: {
402
+ break;
403
+ case 8:
392
404
  this->has_direction = value.as_bool();
393
- return true;
394
- }
395
- case 9: {
405
+ break;
406
+ case 9:
396
407
  this->direction = static_cast<enums::FanDirection>(value.as_uint32());
397
- return true;
398
- }
399
- case 10: {
408
+ break;
409
+ case 10:
400
410
  this->has_speed_level = value.as_bool();
401
- return true;
402
- }
403
- case 11: {
411
+ break;
412
+ case 11:
404
413
  this->speed_level = value.as_int32();
405
- return true;
406
- }
407
- case 12: {
414
+ break;
415
+ case 12:
408
416
  this->has_preset_mode = value.as_bool();
409
- return true;
410
- }
411
- case 14: {
417
+ break;
418
+ #ifdef USE_DEVICES
419
+ case 14:
412
420
  this->device_id = value.as_uint32();
413
- return true;
414
- }
421
+ break;
422
+ #endif
415
423
  default:
416
424
  return false;
417
425
  }
426
+ return true;
418
427
  }
419
428
  bool FanCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
420
429
  switch (field_id) {
421
- case 13: {
430
+ case 13:
422
431
  this->preset_mode = value.as_string();
423
- return true;
424
- }
432
+ break;
425
433
  default:
426
434
  return false;
427
435
  }
436
+ return true;
428
437
  }
429
438
  bool FanCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
430
439
  switch (field_id) {
431
- case 1: {
440
+ case 1:
432
441
  this->key = value.as_fixed32();
433
- return true;
434
- }
442
+ break;
435
443
  default:
436
444
  return false;
437
445
  }
446
+ return true;
438
447
  }
439
448
  #endif
440
449
  #ifdef USE_LIGHT
441
450
  void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const {
442
- buffer.encode_string(1, this->object_id);
451
+ buffer.encode_string(1, this->object_id_ref_);
443
452
  buffer.encode_fixed32(2, this->key);
444
- buffer.encode_string(3, this->name);
445
- buffer.encode_string(4, this->unique_id);
446
- for (auto &it : this->supported_color_modes) {
453
+ buffer.encode_string(3, this->name_ref_);
454
+ for (const auto &it : *this->supported_color_modes) {
447
455
  buffer.encode_uint32(12, static_cast<uint32_t>(it), true);
448
456
  }
449
- buffer.encode_bool(5, this->legacy_supports_brightness);
450
- buffer.encode_bool(6, this->legacy_supports_rgb);
451
- buffer.encode_bool(7, this->legacy_supports_white_value);
452
- buffer.encode_bool(8, this->legacy_supports_color_temperature);
453
457
  buffer.encode_float(9, this->min_mireds);
454
458
  buffer.encode_float(10, this->max_mireds);
455
459
  for (auto &it : this->effects) {
456
460
  buffer.encode_string(11, it, true);
457
461
  }
458
462
  buffer.encode_bool(13, this->disabled_by_default);
459
- buffer.encode_string(14, this->icon);
463
+ #ifdef USE_ENTITY_ICON
464
+ buffer.encode_string(14, this->icon_ref_);
465
+ #endif
460
466
  buffer.encode_uint32(15, static_cast<uint32_t>(this->entity_category));
467
+ #ifdef USE_DEVICES
461
468
  buffer.encode_uint32(16, this->device_id);
469
+ #endif
462
470
  }
463
- void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
464
- ProtoSize::add_string_field(total_size, 1, this->object_id);
465
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
466
- ProtoSize::add_string_field(total_size, 1, this->name);
467
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
468
- if (!this->supported_color_modes.empty()) {
469
- for (const auto &it : this->supported_color_modes) {
470
- ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
471
+ void ListEntitiesLightResponse::calculate_size(ProtoSize &size) const {
472
+ size.add_length(1, this->object_id_ref_.size());
473
+ size.add_fixed32(1, this->key);
474
+ size.add_length(1, this->name_ref_.size());
475
+ if (!this->supported_color_modes->empty()) {
476
+ for (const auto &it : *this->supported_color_modes) {
477
+ size.add_uint32_force(1, static_cast<uint32_t>(it));
471
478
  }
472
479
  }
473
- ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_brightness);
474
- ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_rgb);
475
- ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_white_value);
476
- ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_color_temperature);
477
- ProtoSize::add_fixed_field<4>(total_size, 1, this->min_mireds != 0.0f);
478
- ProtoSize::add_fixed_field<4>(total_size, 1, this->max_mireds != 0.0f);
480
+ size.add_float(1, this->min_mireds);
481
+ size.add_float(1, this->max_mireds);
479
482
  if (!this->effects.empty()) {
480
483
  for (const auto &it : this->effects) {
481
- ProtoSize::add_string_field_repeated(total_size, 1, it);
484
+ size.add_length_force(1, it.size());
482
485
  }
483
486
  }
484
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
485
- ProtoSize::add_string_field(total_size, 1, this->icon);
486
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
487
- ProtoSize::add_uint32_field(total_size, 2, this->device_id);
487
+ size.add_bool(1, this->disabled_by_default);
488
+ #ifdef USE_ENTITY_ICON
489
+ size.add_length(1, this->icon_ref_.size());
490
+ #endif
491
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
492
+ #ifdef USE_DEVICES
493
+ size.add_uint32(2, this->device_id);
494
+ #endif
488
495
  }
489
496
  void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
490
497
  buffer.encode_fixed32(1, this->key);
@@ -499,362 +506,354 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
499
506
  buffer.encode_float(8, this->color_temperature);
500
507
  buffer.encode_float(12, this->cold_white);
501
508
  buffer.encode_float(13, this->warm_white);
502
- buffer.encode_string(9, this->effect);
509
+ buffer.encode_string(9, this->effect_ref_);
510
+ #ifdef USE_DEVICES
503
511
  buffer.encode_uint32(14, this->device_id);
512
+ #endif
504
513
  }
505
- void LightStateResponse::calculate_size(uint32_t &total_size) const {
506
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
507
- ProtoSize::add_bool_field(total_size, 1, this->state);
508
- ProtoSize::add_fixed_field<4>(total_size, 1, this->brightness != 0.0f);
509
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->color_mode));
510
- ProtoSize::add_fixed_field<4>(total_size, 1, this->color_brightness != 0.0f);
511
- ProtoSize::add_fixed_field<4>(total_size, 1, this->red != 0.0f);
512
- ProtoSize::add_fixed_field<4>(total_size, 1, this->green != 0.0f);
513
- ProtoSize::add_fixed_field<4>(total_size, 1, this->blue != 0.0f);
514
- ProtoSize::add_fixed_field<4>(total_size, 1, this->white != 0.0f);
515
- ProtoSize::add_fixed_field<4>(total_size, 1, this->color_temperature != 0.0f);
516
- ProtoSize::add_fixed_field<4>(total_size, 1, this->cold_white != 0.0f);
517
- ProtoSize::add_fixed_field<4>(total_size, 1, this->warm_white != 0.0f);
518
- ProtoSize::add_string_field(total_size, 1, this->effect);
519
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
514
+ void LightStateResponse::calculate_size(ProtoSize &size) const {
515
+ size.add_fixed32(1, this->key);
516
+ size.add_bool(1, this->state);
517
+ size.add_float(1, this->brightness);
518
+ size.add_uint32(1, static_cast<uint32_t>(this->color_mode));
519
+ size.add_float(1, this->color_brightness);
520
+ size.add_float(1, this->red);
521
+ size.add_float(1, this->green);
522
+ size.add_float(1, this->blue);
523
+ size.add_float(1, this->white);
524
+ size.add_float(1, this->color_temperature);
525
+ size.add_float(1, this->cold_white);
526
+ size.add_float(1, this->warm_white);
527
+ size.add_length(1, this->effect_ref_.size());
528
+ #ifdef USE_DEVICES
529
+ size.add_uint32(1, this->device_id);
530
+ #endif
520
531
  }
521
532
  bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
522
533
  switch (field_id) {
523
- case 2: {
534
+ case 2:
524
535
  this->has_state = value.as_bool();
525
- return true;
526
- }
527
- case 3: {
536
+ break;
537
+ case 3:
528
538
  this->state = value.as_bool();
529
- return true;
530
- }
531
- case 4: {
539
+ break;
540
+ case 4:
532
541
  this->has_brightness = value.as_bool();
533
- return true;
534
- }
535
- case 22: {
542
+ break;
543
+ case 22:
536
544
  this->has_color_mode = value.as_bool();
537
- return true;
538
- }
539
- case 23: {
545
+ break;
546
+ case 23:
540
547
  this->color_mode = static_cast<enums::ColorMode>(value.as_uint32());
541
- return true;
542
- }
543
- case 20: {
548
+ break;
549
+ case 20:
544
550
  this->has_color_brightness = value.as_bool();
545
- return true;
546
- }
547
- case 6: {
551
+ break;
552
+ case 6:
548
553
  this->has_rgb = value.as_bool();
549
- return true;
550
- }
551
- case 10: {
554
+ break;
555
+ case 10:
552
556
  this->has_white = value.as_bool();
553
- return true;
554
- }
555
- case 12: {
557
+ break;
558
+ case 12:
556
559
  this->has_color_temperature = value.as_bool();
557
- return true;
558
- }
559
- case 24: {
560
+ break;
561
+ case 24:
560
562
  this->has_cold_white = value.as_bool();
561
- return true;
562
- }
563
- case 26: {
563
+ break;
564
+ case 26:
564
565
  this->has_warm_white = value.as_bool();
565
- return true;
566
- }
567
- case 14: {
566
+ break;
567
+ case 14:
568
568
  this->has_transition_length = value.as_bool();
569
- return true;
570
- }
571
- case 15: {
569
+ break;
570
+ case 15:
572
571
  this->transition_length = value.as_uint32();
573
- return true;
574
- }
575
- case 16: {
572
+ break;
573
+ case 16:
576
574
  this->has_flash_length = value.as_bool();
577
- return true;
578
- }
579
- case 17: {
575
+ break;
576
+ case 17:
580
577
  this->flash_length = value.as_uint32();
581
- return true;
582
- }
583
- case 18: {
578
+ break;
579
+ case 18:
584
580
  this->has_effect = value.as_bool();
585
- return true;
586
- }
587
- case 28: {
581
+ break;
582
+ #ifdef USE_DEVICES
583
+ case 28:
588
584
  this->device_id = value.as_uint32();
589
- return true;
590
- }
585
+ break;
586
+ #endif
591
587
  default:
592
588
  return false;
593
589
  }
590
+ return true;
594
591
  }
595
592
  bool LightCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
596
593
  switch (field_id) {
597
- case 19: {
594
+ case 19:
598
595
  this->effect = value.as_string();
599
- return true;
600
- }
596
+ break;
601
597
  default:
602
598
  return false;
603
599
  }
600
+ return true;
604
601
  }
605
602
  bool LightCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
606
603
  switch (field_id) {
607
- case 1: {
604
+ case 1:
608
605
  this->key = value.as_fixed32();
609
- return true;
610
- }
611
- case 5: {
606
+ break;
607
+ case 5:
612
608
  this->brightness = value.as_float();
613
- return true;
614
- }
615
- case 21: {
609
+ break;
610
+ case 21:
616
611
  this->color_brightness = value.as_float();
617
- return true;
618
- }
619
- case 7: {
612
+ break;
613
+ case 7:
620
614
  this->red = value.as_float();
621
- return true;
622
- }
623
- case 8: {
615
+ break;
616
+ case 8:
624
617
  this->green = value.as_float();
625
- return true;
626
- }
627
- case 9: {
618
+ break;
619
+ case 9:
628
620
  this->blue = value.as_float();
629
- return true;
630
- }
631
- case 11: {
621
+ break;
622
+ case 11:
632
623
  this->white = value.as_float();
633
- return true;
634
- }
635
- case 13: {
624
+ break;
625
+ case 13:
636
626
  this->color_temperature = value.as_float();
637
- return true;
638
- }
639
- case 25: {
627
+ break;
628
+ case 25:
640
629
  this->cold_white = value.as_float();
641
- return true;
642
- }
643
- case 27: {
630
+ break;
631
+ case 27:
644
632
  this->warm_white = value.as_float();
645
- return true;
646
- }
633
+ break;
647
634
  default:
648
635
  return false;
649
636
  }
637
+ return true;
650
638
  }
651
639
  #endif
652
640
  #ifdef USE_SENSOR
653
641
  void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const {
654
- buffer.encode_string(1, this->object_id);
642
+ buffer.encode_string(1, this->object_id_ref_);
655
643
  buffer.encode_fixed32(2, this->key);
656
- buffer.encode_string(3, this->name);
657
- buffer.encode_string(4, this->unique_id);
658
- buffer.encode_string(5, this->icon);
659
- buffer.encode_string(6, this->unit_of_measurement);
644
+ buffer.encode_string(3, this->name_ref_);
645
+ #ifdef USE_ENTITY_ICON
646
+ buffer.encode_string(5, this->icon_ref_);
647
+ #endif
648
+ buffer.encode_string(6, this->unit_of_measurement_ref_);
660
649
  buffer.encode_int32(7, this->accuracy_decimals);
661
650
  buffer.encode_bool(8, this->force_update);
662
- buffer.encode_string(9, this->device_class);
651
+ buffer.encode_string(9, this->device_class_ref_);
663
652
  buffer.encode_uint32(10, static_cast<uint32_t>(this->state_class));
664
- buffer.encode_uint32(11, static_cast<uint32_t>(this->legacy_last_reset_type));
665
653
  buffer.encode_bool(12, this->disabled_by_default);
666
654
  buffer.encode_uint32(13, static_cast<uint32_t>(this->entity_category));
655
+ #ifdef USE_DEVICES
667
656
  buffer.encode_uint32(14, this->device_id);
657
+ #endif
668
658
  }
669
- void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const {
670
- ProtoSize::add_string_field(total_size, 1, this->object_id);
671
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
672
- ProtoSize::add_string_field(total_size, 1, this->name);
673
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
674
- ProtoSize::add_string_field(total_size, 1, this->icon);
675
- ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
676
- ProtoSize::add_int32_field(total_size, 1, this->accuracy_decimals);
677
- ProtoSize::add_bool_field(total_size, 1, this->force_update);
678
- ProtoSize::add_string_field(total_size, 1, this->device_class);
679
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state_class));
680
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_last_reset_type));
681
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
682
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
683
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
659
+ void ListEntitiesSensorResponse::calculate_size(ProtoSize &size) const {
660
+ size.add_length(1, this->object_id_ref_.size());
661
+ size.add_fixed32(1, this->key);
662
+ size.add_length(1, this->name_ref_.size());
663
+ #ifdef USE_ENTITY_ICON
664
+ size.add_length(1, this->icon_ref_.size());
665
+ #endif
666
+ size.add_length(1, this->unit_of_measurement_ref_.size());
667
+ size.add_int32(1, this->accuracy_decimals);
668
+ size.add_bool(1, this->force_update);
669
+ size.add_length(1, this->device_class_ref_.size());
670
+ size.add_uint32(1, static_cast<uint32_t>(this->state_class));
671
+ size.add_bool(1, this->disabled_by_default);
672
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
673
+ #ifdef USE_DEVICES
674
+ size.add_uint32(1, this->device_id);
675
+ #endif
684
676
  }
685
677
  void SensorStateResponse::encode(ProtoWriteBuffer buffer) const {
686
678
  buffer.encode_fixed32(1, this->key);
687
679
  buffer.encode_float(2, this->state);
688
680
  buffer.encode_bool(3, this->missing_state);
681
+ #ifdef USE_DEVICES
689
682
  buffer.encode_uint32(4, this->device_id);
683
+ #endif
690
684
  }
691
- void SensorStateResponse::calculate_size(uint32_t &total_size) const {
692
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
693
- ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f);
694
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
695
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
685
+ void SensorStateResponse::calculate_size(ProtoSize &size) const {
686
+ size.add_fixed32(1, this->key);
687
+ size.add_float(1, this->state);
688
+ size.add_bool(1, this->missing_state);
689
+ #ifdef USE_DEVICES
690
+ size.add_uint32(1, this->device_id);
691
+ #endif
696
692
  }
697
693
  #endif
698
694
  #ifdef USE_SWITCH
699
695
  void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const {
700
- buffer.encode_string(1, this->object_id);
696
+ buffer.encode_string(1, this->object_id_ref_);
701
697
  buffer.encode_fixed32(2, this->key);
702
- buffer.encode_string(3, this->name);
703
- buffer.encode_string(4, this->unique_id);
704
- buffer.encode_string(5, this->icon);
698
+ buffer.encode_string(3, this->name_ref_);
699
+ #ifdef USE_ENTITY_ICON
700
+ buffer.encode_string(5, this->icon_ref_);
701
+ #endif
705
702
  buffer.encode_bool(6, this->assumed_state);
706
703
  buffer.encode_bool(7, this->disabled_by_default);
707
704
  buffer.encode_uint32(8, static_cast<uint32_t>(this->entity_category));
708
- buffer.encode_string(9, this->device_class);
705
+ buffer.encode_string(9, this->device_class_ref_);
706
+ #ifdef USE_DEVICES
709
707
  buffer.encode_uint32(10, this->device_id);
708
+ #endif
710
709
  }
711
- void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const {
712
- ProtoSize::add_string_field(total_size, 1, this->object_id);
713
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
714
- ProtoSize::add_string_field(total_size, 1, this->name);
715
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
716
- ProtoSize::add_string_field(total_size, 1, this->icon);
717
- ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
718
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
719
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
720
- ProtoSize::add_string_field(total_size, 1, this->device_class);
721
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
710
+ void ListEntitiesSwitchResponse::calculate_size(ProtoSize &size) const {
711
+ size.add_length(1, this->object_id_ref_.size());
712
+ size.add_fixed32(1, this->key);
713
+ size.add_length(1, this->name_ref_.size());
714
+ #ifdef USE_ENTITY_ICON
715
+ size.add_length(1, this->icon_ref_.size());
716
+ #endif
717
+ size.add_bool(1, this->assumed_state);
718
+ size.add_bool(1, this->disabled_by_default);
719
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
720
+ size.add_length(1, this->device_class_ref_.size());
721
+ #ifdef USE_DEVICES
722
+ size.add_uint32(1, this->device_id);
723
+ #endif
722
724
  }
723
725
  void SwitchStateResponse::encode(ProtoWriteBuffer buffer) const {
724
726
  buffer.encode_fixed32(1, this->key);
725
727
  buffer.encode_bool(2, this->state);
728
+ #ifdef USE_DEVICES
726
729
  buffer.encode_uint32(3, this->device_id);
730
+ #endif
727
731
  }
728
- void SwitchStateResponse::calculate_size(uint32_t &total_size) const {
729
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
730
- ProtoSize::add_bool_field(total_size, 1, this->state);
731
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
732
+ void SwitchStateResponse::calculate_size(ProtoSize &size) const {
733
+ size.add_fixed32(1, this->key);
734
+ size.add_bool(1, this->state);
735
+ #ifdef USE_DEVICES
736
+ size.add_uint32(1, this->device_id);
737
+ #endif
732
738
  }
733
739
  bool SwitchCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
734
740
  switch (field_id) {
735
- case 2: {
741
+ case 2:
736
742
  this->state = value.as_bool();
737
- return true;
738
- }
739
- case 3: {
743
+ break;
744
+ #ifdef USE_DEVICES
745
+ case 3:
740
746
  this->device_id = value.as_uint32();
741
- return true;
742
- }
747
+ break;
748
+ #endif
743
749
  default:
744
750
  return false;
745
751
  }
752
+ return true;
746
753
  }
747
754
  bool SwitchCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
748
755
  switch (field_id) {
749
- case 1: {
756
+ case 1:
750
757
  this->key = value.as_fixed32();
751
- return true;
752
- }
758
+ break;
753
759
  default:
754
760
  return false;
755
761
  }
762
+ return true;
756
763
  }
757
764
  #endif
758
765
  #ifdef USE_TEXT_SENSOR
759
766
  void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const {
760
- buffer.encode_string(1, this->object_id);
767
+ buffer.encode_string(1, this->object_id_ref_);
761
768
  buffer.encode_fixed32(2, this->key);
762
- buffer.encode_string(3, this->name);
763
- buffer.encode_string(4, this->unique_id);
764
- buffer.encode_string(5, this->icon);
769
+ buffer.encode_string(3, this->name_ref_);
770
+ #ifdef USE_ENTITY_ICON
771
+ buffer.encode_string(5, this->icon_ref_);
772
+ #endif
765
773
  buffer.encode_bool(6, this->disabled_by_default);
766
774
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
767
- buffer.encode_string(8, this->device_class);
775
+ buffer.encode_string(8, this->device_class_ref_);
776
+ #ifdef USE_DEVICES
768
777
  buffer.encode_uint32(9, this->device_id);
778
+ #endif
769
779
  }
770
- void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const {
771
- ProtoSize::add_string_field(total_size, 1, this->object_id);
772
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
773
- ProtoSize::add_string_field(total_size, 1, this->name);
774
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
775
- ProtoSize::add_string_field(total_size, 1, this->icon);
776
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
777
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
778
- ProtoSize::add_string_field(total_size, 1, this->device_class);
779
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
780
+ void ListEntitiesTextSensorResponse::calculate_size(ProtoSize &size) const {
781
+ size.add_length(1, this->object_id_ref_.size());
782
+ size.add_fixed32(1, this->key);
783
+ size.add_length(1, this->name_ref_.size());
784
+ #ifdef USE_ENTITY_ICON
785
+ size.add_length(1, this->icon_ref_.size());
786
+ #endif
787
+ size.add_bool(1, this->disabled_by_default);
788
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
789
+ size.add_length(1, this->device_class_ref_.size());
790
+ #ifdef USE_DEVICES
791
+ size.add_uint32(1, this->device_id);
792
+ #endif
780
793
  }
781
794
  void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const {
782
795
  buffer.encode_fixed32(1, this->key);
783
- buffer.encode_string(2, this->state);
796
+ buffer.encode_string(2, this->state_ref_);
784
797
  buffer.encode_bool(3, this->missing_state);
798
+ #ifdef USE_DEVICES
785
799
  buffer.encode_uint32(4, this->device_id);
800
+ #endif
786
801
  }
787
- void TextSensorStateResponse::calculate_size(uint32_t &total_size) const {
788
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
789
- ProtoSize::add_string_field(total_size, 1, this->state);
790
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
791
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
802
+ void TextSensorStateResponse::calculate_size(ProtoSize &size) const {
803
+ size.add_fixed32(1, this->key);
804
+ size.add_length(1, this->state_ref_.size());
805
+ size.add_bool(1, this->missing_state);
806
+ #ifdef USE_DEVICES
807
+ size.add_uint32(1, this->device_id);
808
+ #endif
792
809
  }
793
810
  #endif
794
811
  bool SubscribeLogsRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
795
812
  switch (field_id) {
796
- case 1: {
813
+ case 1:
797
814
  this->level = static_cast<enums::LogLevel>(value.as_uint32());
798
- return true;
799
- }
800
- case 2: {
815
+ break;
816
+ case 2:
801
817
  this->dump_config = value.as_bool();
802
- return true;
803
- }
818
+ break;
804
819
  default:
805
820
  return false;
806
821
  }
822
+ return true;
807
823
  }
808
824
  void SubscribeLogsResponse::encode(ProtoWriteBuffer buffer) const {
809
825
  buffer.encode_uint32(1, static_cast<uint32_t>(this->level));
810
- buffer.encode_bytes(3, reinterpret_cast<const uint8_t *>(this->message.data()), this->message.size());
811
- buffer.encode_bool(4, this->send_failed);
826
+ buffer.encode_bytes(3, this->message_ptr_, this->message_len_);
812
827
  }
813
- void SubscribeLogsResponse::calculate_size(uint32_t &total_size) const {
814
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->level));
815
- ProtoSize::add_string_field(total_size, 1, this->message);
816
- ProtoSize::add_bool_field(total_size, 1, this->send_failed);
828
+ void SubscribeLogsResponse::calculate_size(ProtoSize &size) const {
829
+ size.add_uint32(1, static_cast<uint32_t>(this->level));
830
+ size.add_length(1, this->message_len_);
817
831
  }
818
832
  #ifdef USE_API_NOISE
819
833
  bool NoiseEncryptionSetKeyRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
820
834
  switch (field_id) {
821
- case 1: {
835
+ case 1:
822
836
  this->key = value.as_string();
823
- return true;
824
- }
837
+ break;
825
838
  default:
826
839
  return false;
827
840
  }
841
+ return true;
828
842
  }
829
843
  void NoiseEncryptionSetKeyResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); }
830
- void NoiseEncryptionSetKeyResponse::calculate_size(uint32_t &total_size) const {
831
- ProtoSize::add_bool_field(total_size, 1, this->success);
832
- }
844
+ void NoiseEncryptionSetKeyResponse::calculate_size(ProtoSize &size) const { size.add_bool(1, this->success); }
833
845
  #endif
834
- bool HomeassistantServiceMap::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
835
- switch (field_id) {
836
- case 1: {
837
- this->key = value.as_string();
838
- return true;
839
- }
840
- case 2: {
841
- this->value = value.as_string();
842
- return true;
843
- }
844
- default:
845
- return false;
846
- }
847
- }
846
+ #ifdef USE_API_HOMEASSISTANT_SERVICES
848
847
  void HomeassistantServiceMap::encode(ProtoWriteBuffer buffer) const {
849
- buffer.encode_string(1, this->key);
848
+ buffer.encode_string(1, this->key_ref_);
850
849
  buffer.encode_string(2, this->value);
851
850
  }
852
- void HomeassistantServiceMap::calculate_size(uint32_t &total_size) const {
853
- ProtoSize::add_string_field(total_size, 1, this->key);
854
- ProtoSize::add_string_field(total_size, 1, this->value);
851
+ void HomeassistantServiceMap::calculate_size(ProtoSize &size) const {
852
+ size.add_length(1, this->key_ref_.size());
853
+ size.add_length(1, this->value.size());
855
854
  }
856
855
  void HomeassistantServiceResponse::encode(ProtoWriteBuffer buffer) const {
857
- buffer.encode_string(1, this->service);
856
+ buffer.encode_string(1, this->service_ref_);
858
857
  for (auto &it : this->data) {
859
858
  buffer.encode_message(2, it, true);
860
859
  }
@@ -866,356 +865,298 @@ void HomeassistantServiceResponse::encode(ProtoWriteBuffer buffer) const {
866
865
  }
867
866
  buffer.encode_bool(5, this->is_event);
868
867
  }
869
- void HomeassistantServiceResponse::calculate_size(uint32_t &total_size) const {
870
- ProtoSize::add_string_field(total_size, 1, this->service);
871
- ProtoSize::add_repeated_message(total_size, 1, this->data);
872
- ProtoSize::add_repeated_message(total_size, 1, this->data_template);
873
- ProtoSize::add_repeated_message(total_size, 1, this->variables);
874
- ProtoSize::add_bool_field(total_size, 1, this->is_event);
868
+ void HomeassistantServiceResponse::calculate_size(ProtoSize &size) const {
869
+ size.add_length(1, this->service_ref_.size());
870
+ size.add_repeated_message(1, this->data);
871
+ size.add_repeated_message(1, this->data_template);
872
+ size.add_repeated_message(1, this->variables);
873
+ size.add_bool(1, this->is_event);
875
874
  }
875
+ #endif
876
+ #ifdef USE_API_HOMEASSISTANT_STATES
876
877
  void SubscribeHomeAssistantStateResponse::encode(ProtoWriteBuffer buffer) const {
877
- buffer.encode_string(1, this->entity_id);
878
- buffer.encode_string(2, this->attribute);
878
+ buffer.encode_string(1, this->entity_id_ref_);
879
+ buffer.encode_string(2, this->attribute_ref_);
879
880
  buffer.encode_bool(3, this->once);
880
881
  }
881
- void SubscribeHomeAssistantStateResponse::calculate_size(uint32_t &total_size) const {
882
- ProtoSize::add_string_field(total_size, 1, this->entity_id);
883
- ProtoSize::add_string_field(total_size, 1, this->attribute);
884
- ProtoSize::add_bool_field(total_size, 1, this->once);
882
+ void SubscribeHomeAssistantStateResponse::calculate_size(ProtoSize &size) const {
883
+ size.add_length(1, this->entity_id_ref_.size());
884
+ size.add_length(1, this->attribute_ref_.size());
885
+ size.add_bool(1, this->once);
885
886
  }
886
887
  bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
887
888
  switch (field_id) {
888
- case 1: {
889
+ case 1:
889
890
  this->entity_id = value.as_string();
890
- return true;
891
- }
892
- case 2: {
891
+ break;
892
+ case 2:
893
893
  this->state = value.as_string();
894
- return true;
895
- }
896
- case 3: {
894
+ break;
895
+ case 3:
897
896
  this->attribute = value.as_string();
898
- return true;
899
- }
897
+ break;
900
898
  default:
901
899
  return false;
902
900
  }
901
+ return true;
903
902
  }
903
+ #endif
904
904
  bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
905
905
  switch (field_id) {
906
- case 1: {
906
+ case 1:
907
907
  this->epoch_seconds = value.as_fixed32();
908
- return true;
909
- }
908
+ break;
910
909
  default:
911
910
  return false;
912
911
  }
912
+ return true;
913
913
  }
914
914
  void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); }
915
- void GetTimeResponse::calculate_size(uint32_t &total_size) const {
916
- ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0);
917
- }
915
+ void GetTimeResponse::calculate_size(ProtoSize &size) const { size.add_fixed32(1, this->epoch_seconds); }
918
916
  #ifdef USE_API_SERVICES
919
- bool ListEntitiesServicesArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
920
- switch (field_id) {
921
- case 2: {
922
- this->type = static_cast<enums::ServiceArgType>(value.as_uint32());
923
- return true;
924
- }
925
- default:
926
- return false;
927
- }
928
- }
929
- bool ListEntitiesServicesArgument::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
930
- switch (field_id) {
931
- case 1: {
932
- this->name = value.as_string();
933
- return true;
934
- }
935
- default:
936
- return false;
937
- }
938
- }
939
917
  void ListEntitiesServicesArgument::encode(ProtoWriteBuffer buffer) const {
940
- buffer.encode_string(1, this->name);
918
+ buffer.encode_string(1, this->name_ref_);
941
919
  buffer.encode_uint32(2, static_cast<uint32_t>(this->type));
942
920
  }
943
- void ListEntitiesServicesArgument::calculate_size(uint32_t &total_size) const {
944
- ProtoSize::add_string_field(total_size, 1, this->name);
945
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->type));
921
+ void ListEntitiesServicesArgument::calculate_size(ProtoSize &size) const {
922
+ size.add_length(1, this->name_ref_.size());
923
+ size.add_uint32(1, static_cast<uint32_t>(this->type));
946
924
  }
947
925
  void ListEntitiesServicesResponse::encode(ProtoWriteBuffer buffer) const {
948
- buffer.encode_string(1, this->name);
926
+ buffer.encode_string(1, this->name_ref_);
949
927
  buffer.encode_fixed32(2, this->key);
950
928
  for (auto &it : this->args) {
951
929
  buffer.encode_message(3, it, true);
952
930
  }
953
931
  }
954
- void ListEntitiesServicesResponse::calculate_size(uint32_t &total_size) const {
955
- ProtoSize::add_string_field(total_size, 1, this->name);
956
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
957
- ProtoSize::add_repeated_message(total_size, 1, this->args);
932
+ void ListEntitiesServicesResponse::calculate_size(ProtoSize &size) const {
933
+ size.add_length(1, this->name_ref_.size());
934
+ size.add_fixed32(1, this->key);
935
+ size.add_repeated_message(1, this->args);
958
936
  }
959
937
  bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
960
938
  switch (field_id) {
961
- case 1: {
939
+ case 1:
962
940
  this->bool_ = value.as_bool();
963
- return true;
964
- }
965
- case 2: {
941
+ break;
942
+ case 2:
966
943
  this->legacy_int = value.as_int32();
967
- return true;
968
- }
969
- case 5: {
944
+ break;
945
+ case 5:
970
946
  this->int_ = value.as_sint32();
971
- return true;
972
- }
973
- case 6: {
947
+ break;
948
+ case 6:
974
949
  this->bool_array.push_back(value.as_bool());
975
- return true;
976
- }
977
- case 7: {
950
+ break;
951
+ case 7:
978
952
  this->int_array.push_back(value.as_sint32());
979
- return true;
980
- }
953
+ break;
981
954
  default:
982
955
  return false;
983
956
  }
957
+ return true;
984
958
  }
985
959
  bool ExecuteServiceArgument::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
986
960
  switch (field_id) {
987
- case 4: {
961
+ case 4:
988
962
  this->string_ = value.as_string();
989
- return true;
990
- }
991
- case 9: {
963
+ break;
964
+ case 9:
992
965
  this->string_array.push_back(value.as_string());
993
- return true;
994
- }
966
+ break;
995
967
  default:
996
968
  return false;
997
969
  }
970
+ return true;
998
971
  }
999
972
  bool ExecuteServiceArgument::decode_32bit(uint32_t field_id, Proto32Bit value) {
1000
973
  switch (field_id) {
1001
- case 3: {
974
+ case 3:
1002
975
  this->float_ = value.as_float();
1003
- return true;
1004
- }
1005
- case 8: {
976
+ break;
977
+ case 8:
1006
978
  this->float_array.push_back(value.as_float());
1007
- return true;
1008
- }
979
+ break;
1009
980
  default:
1010
981
  return false;
1011
982
  }
1012
- }
1013
- void ExecuteServiceArgument::encode(ProtoWriteBuffer buffer) const {
1014
- buffer.encode_bool(1, this->bool_);
1015
- buffer.encode_int32(2, this->legacy_int);
1016
- buffer.encode_float(3, this->float_);
1017
- buffer.encode_string(4, this->string_);
1018
- buffer.encode_sint32(5, this->int_);
1019
- for (auto it : this->bool_array) {
1020
- buffer.encode_bool(6, it, true);
1021
- }
1022
- for (auto &it : this->int_array) {
1023
- buffer.encode_sint32(7, it, true);
1024
- }
1025
- for (auto &it : this->float_array) {
1026
- buffer.encode_float(8, it, true);
1027
- }
1028
- for (auto &it : this->string_array) {
1029
- buffer.encode_string(9, it, true);
1030
- }
1031
- }
1032
- void ExecuteServiceArgument::calculate_size(uint32_t &total_size) const {
1033
- ProtoSize::add_bool_field(total_size, 1, this->bool_);
1034
- ProtoSize::add_int32_field(total_size, 1, this->legacy_int);
1035
- ProtoSize::add_fixed_field<4>(total_size, 1, this->float_ != 0.0f);
1036
- ProtoSize::add_string_field(total_size, 1, this->string_);
1037
- ProtoSize::add_sint32_field(total_size, 1, this->int_);
1038
- if (!this->bool_array.empty()) {
1039
- for (const auto it : this->bool_array) {
1040
- ProtoSize::add_bool_field_repeated(total_size, 1, it);
1041
- }
1042
- }
1043
- if (!this->int_array.empty()) {
1044
- for (const auto &it : this->int_array) {
1045
- ProtoSize::add_sint32_field_repeated(total_size, 1, it);
1046
- }
1047
- }
1048
- if (!this->float_array.empty()) {
1049
- total_size += this->float_array.size() * 5;
1050
- }
1051
- if (!this->string_array.empty()) {
1052
- for (const auto &it : this->string_array) {
1053
- ProtoSize::add_string_field_repeated(total_size, 1, it);
1054
- }
1055
- }
983
+ return true;
1056
984
  }
1057
985
  bool ExecuteServiceRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1058
986
  switch (field_id) {
1059
- case 2: {
987
+ case 2:
1060
988
  this->args.emplace_back();
1061
989
  value.decode_to_message(this->args.back());
1062
- return true;
1063
- }
990
+ break;
1064
991
  default:
1065
992
  return false;
1066
993
  }
994
+ return true;
1067
995
  }
1068
996
  bool ExecuteServiceRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1069
997
  switch (field_id) {
1070
- case 1: {
998
+ case 1:
1071
999
  this->key = value.as_fixed32();
1072
- return true;
1073
- }
1000
+ break;
1074
1001
  default:
1075
1002
  return false;
1076
1003
  }
1004
+ return true;
1077
1005
  }
1078
1006
  #endif
1079
1007
  #ifdef USE_CAMERA
1080
1008
  void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const {
1081
- buffer.encode_string(1, this->object_id);
1009
+ buffer.encode_string(1, this->object_id_ref_);
1082
1010
  buffer.encode_fixed32(2, this->key);
1083
- buffer.encode_string(3, this->name);
1084
- buffer.encode_string(4, this->unique_id);
1011
+ buffer.encode_string(3, this->name_ref_);
1085
1012
  buffer.encode_bool(5, this->disabled_by_default);
1086
- buffer.encode_string(6, this->icon);
1013
+ #ifdef USE_ENTITY_ICON
1014
+ buffer.encode_string(6, this->icon_ref_);
1015
+ #endif
1087
1016
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
1017
+ #ifdef USE_DEVICES
1088
1018
  buffer.encode_uint32(8, this->device_id);
1019
+ #endif
1089
1020
  }
1090
- void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const {
1091
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1092
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1093
- ProtoSize::add_string_field(total_size, 1, this->name);
1094
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1095
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
1096
- ProtoSize::add_string_field(total_size, 1, this->icon);
1097
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
1098
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1021
+ void ListEntitiesCameraResponse::calculate_size(ProtoSize &size) const {
1022
+ size.add_length(1, this->object_id_ref_.size());
1023
+ size.add_fixed32(1, this->key);
1024
+ size.add_length(1, this->name_ref_.size());
1025
+ size.add_bool(1, this->disabled_by_default);
1026
+ #ifdef USE_ENTITY_ICON
1027
+ size.add_length(1, this->icon_ref_.size());
1028
+ #endif
1029
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
1030
+ #ifdef USE_DEVICES
1031
+ size.add_uint32(1, this->device_id);
1032
+ #endif
1099
1033
  }
1100
1034
  void CameraImageResponse::encode(ProtoWriteBuffer buffer) const {
1101
1035
  buffer.encode_fixed32(1, this->key);
1102
- buffer.encode_bytes(2, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
1036
+ buffer.encode_bytes(2, this->data_ptr_, this->data_len_);
1103
1037
  buffer.encode_bool(3, this->done);
1038
+ #ifdef USE_DEVICES
1104
1039
  buffer.encode_uint32(4, this->device_id);
1040
+ #endif
1105
1041
  }
1106
- void CameraImageResponse::calculate_size(uint32_t &total_size) const {
1107
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1108
- ProtoSize::add_string_field(total_size, 1, this->data);
1109
- ProtoSize::add_bool_field(total_size, 1, this->done);
1110
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1042
+ void CameraImageResponse::calculate_size(ProtoSize &size) const {
1043
+ size.add_fixed32(1, this->key);
1044
+ size.add_length(1, this->data_len_);
1045
+ size.add_bool(1, this->done);
1046
+ #ifdef USE_DEVICES
1047
+ size.add_uint32(1, this->device_id);
1048
+ #endif
1111
1049
  }
1112
1050
  bool CameraImageRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1113
1051
  switch (field_id) {
1114
- case 1: {
1052
+ case 1:
1115
1053
  this->single = value.as_bool();
1116
- return true;
1117
- }
1118
- case 2: {
1054
+ break;
1055
+ case 2:
1119
1056
  this->stream = value.as_bool();
1120
- return true;
1121
- }
1057
+ break;
1122
1058
  default:
1123
1059
  return false;
1124
1060
  }
1061
+ return true;
1125
1062
  }
1126
1063
  #endif
1127
1064
  #ifdef USE_CLIMATE
1128
1065
  void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const {
1129
- buffer.encode_string(1, this->object_id);
1066
+ buffer.encode_string(1, this->object_id_ref_);
1130
1067
  buffer.encode_fixed32(2, this->key);
1131
- buffer.encode_string(3, this->name);
1132
- buffer.encode_string(4, this->unique_id);
1068
+ buffer.encode_string(3, this->name_ref_);
1133
1069
  buffer.encode_bool(5, this->supports_current_temperature);
1134
1070
  buffer.encode_bool(6, this->supports_two_point_target_temperature);
1135
- for (auto &it : this->supported_modes) {
1071
+ for (const auto &it : *this->supported_modes) {
1136
1072
  buffer.encode_uint32(7, static_cast<uint32_t>(it), true);
1137
1073
  }
1138
1074
  buffer.encode_float(8, this->visual_min_temperature);
1139
1075
  buffer.encode_float(9, this->visual_max_temperature);
1140
1076
  buffer.encode_float(10, this->visual_target_temperature_step);
1141
- buffer.encode_bool(11, this->legacy_supports_away);
1142
1077
  buffer.encode_bool(12, this->supports_action);
1143
- for (auto &it : this->supported_fan_modes) {
1078
+ for (const auto &it : *this->supported_fan_modes) {
1144
1079
  buffer.encode_uint32(13, static_cast<uint32_t>(it), true);
1145
1080
  }
1146
- for (auto &it : this->supported_swing_modes) {
1081
+ for (const auto &it : *this->supported_swing_modes) {
1147
1082
  buffer.encode_uint32(14, static_cast<uint32_t>(it), true);
1148
1083
  }
1149
- for (auto &it : this->supported_custom_fan_modes) {
1084
+ for (const auto &it : *this->supported_custom_fan_modes) {
1150
1085
  buffer.encode_string(15, it, true);
1151
1086
  }
1152
- for (auto &it : this->supported_presets) {
1087
+ for (const auto &it : *this->supported_presets) {
1153
1088
  buffer.encode_uint32(16, static_cast<uint32_t>(it), true);
1154
1089
  }
1155
- for (auto &it : this->supported_custom_presets) {
1090
+ for (const auto &it : *this->supported_custom_presets) {
1156
1091
  buffer.encode_string(17, it, true);
1157
1092
  }
1158
1093
  buffer.encode_bool(18, this->disabled_by_default);
1159
- buffer.encode_string(19, this->icon);
1094
+ #ifdef USE_ENTITY_ICON
1095
+ buffer.encode_string(19, this->icon_ref_);
1096
+ #endif
1160
1097
  buffer.encode_uint32(20, static_cast<uint32_t>(this->entity_category));
1161
1098
  buffer.encode_float(21, this->visual_current_temperature_step);
1162
1099
  buffer.encode_bool(22, this->supports_current_humidity);
1163
1100
  buffer.encode_bool(23, this->supports_target_humidity);
1164
1101
  buffer.encode_float(24, this->visual_min_humidity);
1165
1102
  buffer.encode_float(25, this->visual_max_humidity);
1103
+ #ifdef USE_DEVICES
1166
1104
  buffer.encode_uint32(26, this->device_id);
1105
+ #endif
1167
1106
  }
1168
- void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
1169
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1170
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1171
- ProtoSize::add_string_field(total_size, 1, this->name);
1172
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1173
- ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature);
1174
- ProtoSize::add_bool_field(total_size, 1, this->supports_two_point_target_temperature);
1175
- if (!this->supported_modes.empty()) {
1176
- for (const auto &it : this->supported_modes) {
1177
- ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
1107
+ void ListEntitiesClimateResponse::calculate_size(ProtoSize &size) const {
1108
+ size.add_length(1, this->object_id_ref_.size());
1109
+ size.add_fixed32(1, this->key);
1110
+ size.add_length(1, this->name_ref_.size());
1111
+ size.add_bool(1, this->supports_current_temperature);
1112
+ size.add_bool(1, this->supports_two_point_target_temperature);
1113
+ if (!this->supported_modes->empty()) {
1114
+ for (const auto &it : *this->supported_modes) {
1115
+ size.add_uint32_force(1, static_cast<uint32_t>(it));
1178
1116
  }
1179
1117
  }
1180
- ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_min_temperature != 0.0f);
1181
- ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_max_temperature != 0.0f);
1182
- ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_target_temperature_step != 0.0f);
1183
- ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_away);
1184
- ProtoSize::add_bool_field(total_size, 1, this->supports_action);
1185
- if (!this->supported_fan_modes.empty()) {
1186
- for (const auto &it : this->supported_fan_modes) {
1187
- ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
1118
+ size.add_float(1, this->visual_min_temperature);
1119
+ size.add_float(1, this->visual_max_temperature);
1120
+ size.add_float(1, this->visual_target_temperature_step);
1121
+ size.add_bool(1, this->supports_action);
1122
+ if (!this->supported_fan_modes->empty()) {
1123
+ for (const auto &it : *this->supported_fan_modes) {
1124
+ size.add_uint32_force(1, static_cast<uint32_t>(it));
1188
1125
  }
1189
1126
  }
1190
- if (!this->supported_swing_modes.empty()) {
1191
- for (const auto &it : this->supported_swing_modes) {
1192
- ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
1127
+ if (!this->supported_swing_modes->empty()) {
1128
+ for (const auto &it : *this->supported_swing_modes) {
1129
+ size.add_uint32_force(1, static_cast<uint32_t>(it));
1193
1130
  }
1194
1131
  }
1195
- if (!this->supported_custom_fan_modes.empty()) {
1196
- for (const auto &it : this->supported_custom_fan_modes) {
1197
- ProtoSize::add_string_field_repeated(total_size, 1, it);
1132
+ if (!this->supported_custom_fan_modes->empty()) {
1133
+ for (const auto &it : *this->supported_custom_fan_modes) {
1134
+ size.add_length_force(1, it.size());
1198
1135
  }
1199
1136
  }
1200
- if (!this->supported_presets.empty()) {
1201
- for (const auto &it : this->supported_presets) {
1202
- ProtoSize::add_enum_field_repeated(total_size, 2, static_cast<uint32_t>(it));
1137
+ if (!this->supported_presets->empty()) {
1138
+ for (const auto &it : *this->supported_presets) {
1139
+ size.add_uint32_force(2, static_cast<uint32_t>(it));
1203
1140
  }
1204
1141
  }
1205
- if (!this->supported_custom_presets.empty()) {
1206
- for (const auto &it : this->supported_custom_presets) {
1207
- ProtoSize::add_string_field_repeated(total_size, 2, it);
1142
+ if (!this->supported_custom_presets->empty()) {
1143
+ for (const auto &it : *this->supported_custom_presets) {
1144
+ size.add_length_force(2, it.size());
1208
1145
  }
1209
1146
  }
1210
- ProtoSize::add_bool_field(total_size, 2, this->disabled_by_default);
1211
- ProtoSize::add_string_field(total_size, 2, this->icon);
1212
- ProtoSize::add_enum_field(total_size, 2, static_cast<uint32_t>(this->entity_category));
1213
- ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_current_temperature_step != 0.0f);
1214
- ProtoSize::add_bool_field(total_size, 2, this->supports_current_humidity);
1215
- ProtoSize::add_bool_field(total_size, 2, this->supports_target_humidity);
1216
- ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_min_humidity != 0.0f);
1217
- ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_max_humidity != 0.0f);
1218
- ProtoSize::add_uint32_field(total_size, 2, this->device_id);
1147
+ size.add_bool(2, this->disabled_by_default);
1148
+ #ifdef USE_ENTITY_ICON
1149
+ size.add_length(2, this->icon_ref_.size());
1150
+ #endif
1151
+ size.add_uint32(2, static_cast<uint32_t>(this->entity_category));
1152
+ size.add_float(2, this->visual_current_temperature_step);
1153
+ size.add_bool(2, this->supports_current_humidity);
1154
+ size.add_bool(2, this->supports_target_humidity);
1155
+ size.add_float(2, this->visual_min_humidity);
1156
+ size.add_float(2, this->visual_max_humidity);
1157
+ #ifdef USE_DEVICES
1158
+ size.add_uint32(2, this->device_id);
1159
+ #endif
1219
1160
  }
1220
1161
  void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
1221
1162
  buffer.encode_fixed32(1, this->key);
@@ -1224,299 +1165,300 @@ void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
1224
1165
  buffer.encode_float(4, this->target_temperature);
1225
1166
  buffer.encode_float(5, this->target_temperature_low);
1226
1167
  buffer.encode_float(6, this->target_temperature_high);
1227
- buffer.encode_bool(7, this->unused_legacy_away);
1228
1168
  buffer.encode_uint32(8, static_cast<uint32_t>(this->action));
1229
1169
  buffer.encode_uint32(9, static_cast<uint32_t>(this->fan_mode));
1230
1170
  buffer.encode_uint32(10, static_cast<uint32_t>(this->swing_mode));
1231
- buffer.encode_string(11, this->custom_fan_mode);
1171
+ buffer.encode_string(11, this->custom_fan_mode_ref_);
1232
1172
  buffer.encode_uint32(12, static_cast<uint32_t>(this->preset));
1233
- buffer.encode_string(13, this->custom_preset);
1173
+ buffer.encode_string(13, this->custom_preset_ref_);
1234
1174
  buffer.encode_float(14, this->current_humidity);
1235
1175
  buffer.encode_float(15, this->target_humidity);
1176
+ #ifdef USE_DEVICES
1236
1177
  buffer.encode_uint32(16, this->device_id);
1178
+ #endif
1237
1179
  }
1238
- void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
1239
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1240
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
1241
- ProtoSize::add_fixed_field<4>(total_size, 1, this->current_temperature != 0.0f);
1242
- ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature != 0.0f);
1243
- ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_low != 0.0f);
1244
- ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_high != 0.0f);
1245
- ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away);
1246
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->action));
1247
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->fan_mode));
1248
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->swing_mode));
1249
- ProtoSize::add_string_field(total_size, 1, this->custom_fan_mode);
1250
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->preset));
1251
- ProtoSize::add_string_field(total_size, 1, this->custom_preset);
1252
- ProtoSize::add_fixed_field<4>(total_size, 1, this->current_humidity != 0.0f);
1253
- ProtoSize::add_fixed_field<4>(total_size, 1, this->target_humidity != 0.0f);
1254
- ProtoSize::add_uint32_field(total_size, 2, this->device_id);
1180
+ void ClimateStateResponse::calculate_size(ProtoSize &size) const {
1181
+ size.add_fixed32(1, this->key);
1182
+ size.add_uint32(1, static_cast<uint32_t>(this->mode));
1183
+ size.add_float(1, this->current_temperature);
1184
+ size.add_float(1, this->target_temperature);
1185
+ size.add_float(1, this->target_temperature_low);
1186
+ size.add_float(1, this->target_temperature_high);
1187
+ size.add_uint32(1, static_cast<uint32_t>(this->action));
1188
+ size.add_uint32(1, static_cast<uint32_t>(this->fan_mode));
1189
+ size.add_uint32(1, static_cast<uint32_t>(this->swing_mode));
1190
+ size.add_length(1, this->custom_fan_mode_ref_.size());
1191
+ size.add_uint32(1, static_cast<uint32_t>(this->preset));
1192
+ size.add_length(1, this->custom_preset_ref_.size());
1193
+ size.add_float(1, this->current_humidity);
1194
+ size.add_float(1, this->target_humidity);
1195
+ #ifdef USE_DEVICES
1196
+ size.add_uint32(2, this->device_id);
1197
+ #endif
1255
1198
  }
1256
1199
  bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1257
1200
  switch (field_id) {
1258
- case 2: {
1201
+ case 2:
1259
1202
  this->has_mode = value.as_bool();
1260
- return true;
1261
- }
1262
- case 3: {
1203
+ break;
1204
+ case 3:
1263
1205
  this->mode = static_cast<enums::ClimateMode>(value.as_uint32());
1264
- return true;
1265
- }
1266
- case 4: {
1206
+ break;
1207
+ case 4:
1267
1208
  this->has_target_temperature = value.as_bool();
1268
- return true;
1269
- }
1270
- case 6: {
1209
+ break;
1210
+ case 6:
1271
1211
  this->has_target_temperature_low = value.as_bool();
1272
- return true;
1273
- }
1274
- case 8: {
1212
+ break;
1213
+ case 8:
1275
1214
  this->has_target_temperature_high = value.as_bool();
1276
- return true;
1277
- }
1278
- case 10: {
1279
- this->unused_has_legacy_away = value.as_bool();
1280
- return true;
1281
- }
1282
- case 11: {
1283
- this->unused_legacy_away = value.as_bool();
1284
- return true;
1285
- }
1286
- case 12: {
1215
+ break;
1216
+ case 12:
1287
1217
  this->has_fan_mode = value.as_bool();
1288
- return true;
1289
- }
1290
- case 13: {
1218
+ break;
1219
+ case 13:
1291
1220
  this->fan_mode = static_cast<enums::ClimateFanMode>(value.as_uint32());
1292
- return true;
1293
- }
1294
- case 14: {
1221
+ break;
1222
+ case 14:
1295
1223
  this->has_swing_mode = value.as_bool();
1296
- return true;
1297
- }
1298
- case 15: {
1224
+ break;
1225
+ case 15:
1299
1226
  this->swing_mode = static_cast<enums::ClimateSwingMode>(value.as_uint32());
1300
- return true;
1301
- }
1302
- case 16: {
1227
+ break;
1228
+ case 16:
1303
1229
  this->has_custom_fan_mode = value.as_bool();
1304
- return true;
1305
- }
1306
- case 18: {
1230
+ break;
1231
+ case 18:
1307
1232
  this->has_preset = value.as_bool();
1308
- return true;
1309
- }
1310
- case 19: {
1233
+ break;
1234
+ case 19:
1311
1235
  this->preset = static_cast<enums::ClimatePreset>(value.as_uint32());
1312
- return true;
1313
- }
1314
- case 20: {
1236
+ break;
1237
+ case 20:
1315
1238
  this->has_custom_preset = value.as_bool();
1316
- return true;
1317
- }
1318
- case 22: {
1239
+ break;
1240
+ case 22:
1319
1241
  this->has_target_humidity = value.as_bool();
1320
- return true;
1321
- }
1322
- case 24: {
1242
+ break;
1243
+ #ifdef USE_DEVICES
1244
+ case 24:
1323
1245
  this->device_id = value.as_uint32();
1324
- return true;
1325
- }
1246
+ break;
1247
+ #endif
1326
1248
  default:
1327
1249
  return false;
1328
1250
  }
1251
+ return true;
1329
1252
  }
1330
1253
  bool ClimateCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1331
1254
  switch (field_id) {
1332
- case 17: {
1255
+ case 17:
1333
1256
  this->custom_fan_mode = value.as_string();
1334
- return true;
1335
- }
1336
- case 21: {
1257
+ break;
1258
+ case 21:
1337
1259
  this->custom_preset = value.as_string();
1338
- return true;
1339
- }
1260
+ break;
1340
1261
  default:
1341
1262
  return false;
1342
1263
  }
1264
+ return true;
1343
1265
  }
1344
1266
  bool ClimateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1345
1267
  switch (field_id) {
1346
- case 1: {
1268
+ case 1:
1347
1269
  this->key = value.as_fixed32();
1348
- return true;
1349
- }
1350
- case 5: {
1270
+ break;
1271
+ case 5:
1351
1272
  this->target_temperature = value.as_float();
1352
- return true;
1353
- }
1354
- case 7: {
1273
+ break;
1274
+ case 7:
1355
1275
  this->target_temperature_low = value.as_float();
1356
- return true;
1357
- }
1358
- case 9: {
1276
+ break;
1277
+ case 9:
1359
1278
  this->target_temperature_high = value.as_float();
1360
- return true;
1361
- }
1362
- case 23: {
1279
+ break;
1280
+ case 23:
1363
1281
  this->target_humidity = value.as_float();
1364
- return true;
1365
- }
1282
+ break;
1366
1283
  default:
1367
1284
  return false;
1368
1285
  }
1286
+ return true;
1369
1287
  }
1370
1288
  #endif
1371
1289
  #ifdef USE_NUMBER
1372
1290
  void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const {
1373
- buffer.encode_string(1, this->object_id);
1291
+ buffer.encode_string(1, this->object_id_ref_);
1374
1292
  buffer.encode_fixed32(2, this->key);
1375
- buffer.encode_string(3, this->name);
1376
- buffer.encode_string(4, this->unique_id);
1377
- buffer.encode_string(5, this->icon);
1293
+ buffer.encode_string(3, this->name_ref_);
1294
+ #ifdef USE_ENTITY_ICON
1295
+ buffer.encode_string(5, this->icon_ref_);
1296
+ #endif
1378
1297
  buffer.encode_float(6, this->min_value);
1379
1298
  buffer.encode_float(7, this->max_value);
1380
1299
  buffer.encode_float(8, this->step);
1381
1300
  buffer.encode_bool(9, this->disabled_by_default);
1382
1301
  buffer.encode_uint32(10, static_cast<uint32_t>(this->entity_category));
1383
- buffer.encode_string(11, this->unit_of_measurement);
1302
+ buffer.encode_string(11, this->unit_of_measurement_ref_);
1384
1303
  buffer.encode_uint32(12, static_cast<uint32_t>(this->mode));
1385
- buffer.encode_string(13, this->device_class);
1304
+ buffer.encode_string(13, this->device_class_ref_);
1305
+ #ifdef USE_DEVICES
1386
1306
  buffer.encode_uint32(14, this->device_id);
1307
+ #endif
1387
1308
  }
1388
- void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const {
1389
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1390
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1391
- ProtoSize::add_string_field(total_size, 1, this->name);
1392
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1393
- ProtoSize::add_string_field(total_size, 1, this->icon);
1394
- ProtoSize::add_fixed_field<4>(total_size, 1, this->min_value != 0.0f);
1395
- ProtoSize::add_fixed_field<4>(total_size, 1, this->max_value != 0.0f);
1396
- ProtoSize::add_fixed_field<4>(total_size, 1, this->step != 0.0f);
1397
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
1398
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
1399
- ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
1400
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
1401
- ProtoSize::add_string_field(total_size, 1, this->device_class);
1402
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1309
+ void ListEntitiesNumberResponse::calculate_size(ProtoSize &size) const {
1310
+ size.add_length(1, this->object_id_ref_.size());
1311
+ size.add_fixed32(1, this->key);
1312
+ size.add_length(1, this->name_ref_.size());
1313
+ #ifdef USE_ENTITY_ICON
1314
+ size.add_length(1, this->icon_ref_.size());
1315
+ #endif
1316
+ size.add_float(1, this->min_value);
1317
+ size.add_float(1, this->max_value);
1318
+ size.add_float(1, this->step);
1319
+ size.add_bool(1, this->disabled_by_default);
1320
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
1321
+ size.add_length(1, this->unit_of_measurement_ref_.size());
1322
+ size.add_uint32(1, static_cast<uint32_t>(this->mode));
1323
+ size.add_length(1, this->device_class_ref_.size());
1324
+ #ifdef USE_DEVICES
1325
+ size.add_uint32(1, this->device_id);
1326
+ #endif
1403
1327
  }
1404
1328
  void NumberStateResponse::encode(ProtoWriteBuffer buffer) const {
1405
1329
  buffer.encode_fixed32(1, this->key);
1406
1330
  buffer.encode_float(2, this->state);
1407
1331
  buffer.encode_bool(3, this->missing_state);
1332
+ #ifdef USE_DEVICES
1408
1333
  buffer.encode_uint32(4, this->device_id);
1334
+ #endif
1409
1335
  }
1410
- void NumberStateResponse::calculate_size(uint32_t &total_size) const {
1411
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1412
- ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f);
1413
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
1414
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1336
+ void NumberStateResponse::calculate_size(ProtoSize &size) const {
1337
+ size.add_fixed32(1, this->key);
1338
+ size.add_float(1, this->state);
1339
+ size.add_bool(1, this->missing_state);
1340
+ #ifdef USE_DEVICES
1341
+ size.add_uint32(1, this->device_id);
1342
+ #endif
1415
1343
  }
1416
1344
  bool NumberCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1417
1345
  switch (field_id) {
1418
- case 3: {
1346
+ #ifdef USE_DEVICES
1347
+ case 3:
1419
1348
  this->device_id = value.as_uint32();
1420
- return true;
1421
- }
1349
+ break;
1350
+ #endif
1422
1351
  default:
1423
1352
  return false;
1424
1353
  }
1354
+ return true;
1425
1355
  }
1426
1356
  bool NumberCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1427
1357
  switch (field_id) {
1428
- case 1: {
1358
+ case 1:
1429
1359
  this->key = value.as_fixed32();
1430
- return true;
1431
- }
1432
- case 2: {
1360
+ break;
1361
+ case 2:
1433
1362
  this->state = value.as_float();
1434
- return true;
1435
- }
1363
+ break;
1436
1364
  default:
1437
1365
  return false;
1438
1366
  }
1367
+ return true;
1439
1368
  }
1440
1369
  #endif
1441
1370
  #ifdef USE_SELECT
1442
1371
  void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const {
1443
- buffer.encode_string(1, this->object_id);
1372
+ buffer.encode_string(1, this->object_id_ref_);
1444
1373
  buffer.encode_fixed32(2, this->key);
1445
- buffer.encode_string(3, this->name);
1446
- buffer.encode_string(4, this->unique_id);
1447
- buffer.encode_string(5, this->icon);
1448
- for (auto &it : this->options) {
1374
+ buffer.encode_string(3, this->name_ref_);
1375
+ #ifdef USE_ENTITY_ICON
1376
+ buffer.encode_string(5, this->icon_ref_);
1377
+ #endif
1378
+ for (const auto &it : *this->options) {
1449
1379
  buffer.encode_string(6, it, true);
1450
1380
  }
1451
1381
  buffer.encode_bool(7, this->disabled_by_default);
1452
1382
  buffer.encode_uint32(8, static_cast<uint32_t>(this->entity_category));
1383
+ #ifdef USE_DEVICES
1453
1384
  buffer.encode_uint32(9, this->device_id);
1385
+ #endif
1454
1386
  }
1455
- void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const {
1456
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1457
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1458
- ProtoSize::add_string_field(total_size, 1, this->name);
1459
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1460
- ProtoSize::add_string_field(total_size, 1, this->icon);
1461
- if (!this->options.empty()) {
1462
- for (const auto &it : this->options) {
1463
- ProtoSize::add_string_field_repeated(total_size, 1, it);
1387
+ void ListEntitiesSelectResponse::calculate_size(ProtoSize &size) const {
1388
+ size.add_length(1, this->object_id_ref_.size());
1389
+ size.add_fixed32(1, this->key);
1390
+ size.add_length(1, this->name_ref_.size());
1391
+ #ifdef USE_ENTITY_ICON
1392
+ size.add_length(1, this->icon_ref_.size());
1393
+ #endif
1394
+ if (!this->options->empty()) {
1395
+ for (const auto &it : *this->options) {
1396
+ size.add_length_force(1, it.size());
1464
1397
  }
1465
1398
  }
1466
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
1467
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
1468
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1399
+ size.add_bool(1, this->disabled_by_default);
1400
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
1401
+ #ifdef USE_DEVICES
1402
+ size.add_uint32(1, this->device_id);
1403
+ #endif
1469
1404
  }
1470
1405
  void SelectStateResponse::encode(ProtoWriteBuffer buffer) const {
1471
1406
  buffer.encode_fixed32(1, this->key);
1472
- buffer.encode_string(2, this->state);
1407
+ buffer.encode_string(2, this->state_ref_);
1473
1408
  buffer.encode_bool(3, this->missing_state);
1409
+ #ifdef USE_DEVICES
1474
1410
  buffer.encode_uint32(4, this->device_id);
1411
+ #endif
1475
1412
  }
1476
- void SelectStateResponse::calculate_size(uint32_t &total_size) const {
1477
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1478
- ProtoSize::add_string_field(total_size, 1, this->state);
1479
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
1480
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1413
+ void SelectStateResponse::calculate_size(ProtoSize &size) const {
1414
+ size.add_fixed32(1, this->key);
1415
+ size.add_length(1, this->state_ref_.size());
1416
+ size.add_bool(1, this->missing_state);
1417
+ #ifdef USE_DEVICES
1418
+ size.add_uint32(1, this->device_id);
1419
+ #endif
1481
1420
  }
1482
1421
  bool SelectCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1483
1422
  switch (field_id) {
1484
- case 3: {
1423
+ #ifdef USE_DEVICES
1424
+ case 3:
1485
1425
  this->device_id = value.as_uint32();
1486
- return true;
1487
- }
1426
+ break;
1427
+ #endif
1488
1428
  default:
1489
1429
  return false;
1490
1430
  }
1431
+ return true;
1491
1432
  }
1492
1433
  bool SelectCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1493
1434
  switch (field_id) {
1494
- case 2: {
1435
+ case 2:
1495
1436
  this->state = value.as_string();
1496
- return true;
1497
- }
1437
+ break;
1498
1438
  default:
1499
1439
  return false;
1500
1440
  }
1441
+ return true;
1501
1442
  }
1502
1443
  bool SelectCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1503
1444
  switch (field_id) {
1504
- case 1: {
1445
+ case 1:
1505
1446
  this->key = value.as_fixed32();
1506
- return true;
1507
- }
1447
+ break;
1508
1448
  default:
1509
1449
  return false;
1510
1450
  }
1451
+ return true;
1511
1452
  }
1512
1453
  #endif
1513
1454
  #ifdef USE_SIREN
1514
1455
  void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const {
1515
- buffer.encode_string(1, this->object_id);
1456
+ buffer.encode_string(1, this->object_id_ref_);
1516
1457
  buffer.encode_fixed32(2, this->key);
1517
- buffer.encode_string(3, this->name);
1518
- buffer.encode_string(4, this->unique_id);
1519
- buffer.encode_string(5, this->icon);
1458
+ buffer.encode_string(3, this->name_ref_);
1459
+ #ifdef USE_ENTITY_ICON
1460
+ buffer.encode_string(5, this->icon_ref_);
1461
+ #endif
1520
1462
  buffer.encode_bool(6, this->disabled_by_default);
1521
1463
  for (auto &it : this->tones) {
1522
1464
  buffer.encode_string(7, it, true);
@@ -1524,510 +1466,410 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const {
1524
1466
  buffer.encode_bool(8, this->supports_duration);
1525
1467
  buffer.encode_bool(9, this->supports_volume);
1526
1468
  buffer.encode_uint32(10, static_cast<uint32_t>(this->entity_category));
1469
+ #ifdef USE_DEVICES
1527
1470
  buffer.encode_uint32(11, this->device_id);
1471
+ #endif
1528
1472
  }
1529
- void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const {
1530
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1531
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1532
- ProtoSize::add_string_field(total_size, 1, this->name);
1533
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1534
- ProtoSize::add_string_field(total_size, 1, this->icon);
1535
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
1473
+ void ListEntitiesSirenResponse::calculate_size(ProtoSize &size) const {
1474
+ size.add_length(1, this->object_id_ref_.size());
1475
+ size.add_fixed32(1, this->key);
1476
+ size.add_length(1, this->name_ref_.size());
1477
+ #ifdef USE_ENTITY_ICON
1478
+ size.add_length(1, this->icon_ref_.size());
1479
+ #endif
1480
+ size.add_bool(1, this->disabled_by_default);
1536
1481
  if (!this->tones.empty()) {
1537
1482
  for (const auto &it : this->tones) {
1538
- ProtoSize::add_string_field_repeated(total_size, 1, it);
1483
+ size.add_length_force(1, it.size());
1539
1484
  }
1540
1485
  }
1541
- ProtoSize::add_bool_field(total_size, 1, this->supports_duration);
1542
- ProtoSize::add_bool_field(total_size, 1, this->supports_volume);
1543
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
1544
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1486
+ size.add_bool(1, this->supports_duration);
1487
+ size.add_bool(1, this->supports_volume);
1488
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
1489
+ #ifdef USE_DEVICES
1490
+ size.add_uint32(1, this->device_id);
1491
+ #endif
1545
1492
  }
1546
1493
  void SirenStateResponse::encode(ProtoWriteBuffer buffer) const {
1547
1494
  buffer.encode_fixed32(1, this->key);
1548
1495
  buffer.encode_bool(2, this->state);
1496
+ #ifdef USE_DEVICES
1549
1497
  buffer.encode_uint32(3, this->device_id);
1498
+ #endif
1550
1499
  }
1551
- void SirenStateResponse::calculate_size(uint32_t &total_size) const {
1552
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1553
- ProtoSize::add_bool_field(total_size, 1, this->state);
1554
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1500
+ void SirenStateResponse::calculate_size(ProtoSize &size) const {
1501
+ size.add_fixed32(1, this->key);
1502
+ size.add_bool(1, this->state);
1503
+ #ifdef USE_DEVICES
1504
+ size.add_uint32(1, this->device_id);
1505
+ #endif
1555
1506
  }
1556
1507
  bool SirenCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1557
1508
  switch (field_id) {
1558
- case 2: {
1509
+ case 2:
1559
1510
  this->has_state = value.as_bool();
1560
- return true;
1561
- }
1562
- case 3: {
1511
+ break;
1512
+ case 3:
1563
1513
  this->state = value.as_bool();
1564
- return true;
1565
- }
1566
- case 4: {
1514
+ break;
1515
+ case 4:
1567
1516
  this->has_tone = value.as_bool();
1568
- return true;
1569
- }
1570
- case 6: {
1517
+ break;
1518
+ case 6:
1571
1519
  this->has_duration = value.as_bool();
1572
- return true;
1573
- }
1574
- case 7: {
1520
+ break;
1521
+ case 7:
1575
1522
  this->duration = value.as_uint32();
1576
- return true;
1577
- }
1578
- case 8: {
1523
+ break;
1524
+ case 8:
1579
1525
  this->has_volume = value.as_bool();
1580
- return true;
1581
- }
1582
- case 10: {
1526
+ break;
1527
+ #ifdef USE_DEVICES
1528
+ case 10:
1583
1529
  this->device_id = value.as_uint32();
1584
- return true;
1585
- }
1530
+ break;
1531
+ #endif
1586
1532
  default:
1587
1533
  return false;
1588
1534
  }
1535
+ return true;
1589
1536
  }
1590
1537
  bool SirenCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1591
1538
  switch (field_id) {
1592
- case 5: {
1539
+ case 5:
1593
1540
  this->tone = value.as_string();
1594
- return true;
1595
- }
1541
+ break;
1596
1542
  default:
1597
1543
  return false;
1598
1544
  }
1545
+ return true;
1599
1546
  }
1600
1547
  bool SirenCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1601
1548
  switch (field_id) {
1602
- case 1: {
1549
+ case 1:
1603
1550
  this->key = value.as_fixed32();
1604
- return true;
1605
- }
1606
- case 9: {
1551
+ break;
1552
+ case 9:
1607
1553
  this->volume = value.as_float();
1608
- return true;
1609
- }
1554
+ break;
1610
1555
  default:
1611
1556
  return false;
1612
1557
  }
1558
+ return true;
1613
1559
  }
1614
1560
  #endif
1615
1561
  #ifdef USE_LOCK
1616
1562
  void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const {
1617
- buffer.encode_string(1, this->object_id);
1563
+ buffer.encode_string(1, this->object_id_ref_);
1618
1564
  buffer.encode_fixed32(2, this->key);
1619
- buffer.encode_string(3, this->name);
1620
- buffer.encode_string(4, this->unique_id);
1621
- buffer.encode_string(5, this->icon);
1565
+ buffer.encode_string(3, this->name_ref_);
1566
+ #ifdef USE_ENTITY_ICON
1567
+ buffer.encode_string(5, this->icon_ref_);
1568
+ #endif
1622
1569
  buffer.encode_bool(6, this->disabled_by_default);
1623
1570
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
1624
1571
  buffer.encode_bool(8, this->assumed_state);
1625
1572
  buffer.encode_bool(9, this->supports_open);
1626
1573
  buffer.encode_bool(10, this->requires_code);
1627
- buffer.encode_string(11, this->code_format);
1574
+ buffer.encode_string(11, this->code_format_ref_);
1575
+ #ifdef USE_DEVICES
1628
1576
  buffer.encode_uint32(12, this->device_id);
1577
+ #endif
1629
1578
  }
1630
- void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const {
1631
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1632
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1633
- ProtoSize::add_string_field(total_size, 1, this->name);
1634
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1635
- ProtoSize::add_string_field(total_size, 1, this->icon);
1636
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
1637
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
1638
- ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
1639
- ProtoSize::add_bool_field(total_size, 1, this->supports_open);
1640
- ProtoSize::add_bool_field(total_size, 1, this->requires_code);
1641
- ProtoSize::add_string_field(total_size, 1, this->code_format);
1642
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1579
+ void ListEntitiesLockResponse::calculate_size(ProtoSize &size) const {
1580
+ size.add_length(1, this->object_id_ref_.size());
1581
+ size.add_fixed32(1, this->key);
1582
+ size.add_length(1, this->name_ref_.size());
1583
+ #ifdef USE_ENTITY_ICON
1584
+ size.add_length(1, this->icon_ref_.size());
1585
+ #endif
1586
+ size.add_bool(1, this->disabled_by_default);
1587
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
1588
+ size.add_bool(1, this->assumed_state);
1589
+ size.add_bool(1, this->supports_open);
1590
+ size.add_bool(1, this->requires_code);
1591
+ size.add_length(1, this->code_format_ref_.size());
1592
+ #ifdef USE_DEVICES
1593
+ size.add_uint32(1, this->device_id);
1594
+ #endif
1643
1595
  }
1644
1596
  void LockStateResponse::encode(ProtoWriteBuffer buffer) const {
1645
1597
  buffer.encode_fixed32(1, this->key);
1646
1598
  buffer.encode_uint32(2, static_cast<uint32_t>(this->state));
1599
+ #ifdef USE_DEVICES
1647
1600
  buffer.encode_uint32(3, this->device_id);
1601
+ #endif
1648
1602
  }
1649
- void LockStateResponse::calculate_size(uint32_t &total_size) const {
1650
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1651
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
1652
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1603
+ void LockStateResponse::calculate_size(ProtoSize &size) const {
1604
+ size.add_fixed32(1, this->key);
1605
+ size.add_uint32(1, static_cast<uint32_t>(this->state));
1606
+ #ifdef USE_DEVICES
1607
+ size.add_uint32(1, this->device_id);
1608
+ #endif
1653
1609
  }
1654
1610
  bool LockCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1655
1611
  switch (field_id) {
1656
- case 2: {
1612
+ case 2:
1657
1613
  this->command = static_cast<enums::LockCommand>(value.as_uint32());
1658
- return true;
1659
- }
1660
- case 3: {
1614
+ break;
1615
+ case 3:
1661
1616
  this->has_code = value.as_bool();
1662
- return true;
1663
- }
1664
- case 5: {
1617
+ break;
1618
+ #ifdef USE_DEVICES
1619
+ case 5:
1665
1620
  this->device_id = value.as_uint32();
1666
- return true;
1667
- }
1621
+ break;
1622
+ #endif
1668
1623
  default:
1669
1624
  return false;
1670
1625
  }
1626
+ return true;
1671
1627
  }
1672
1628
  bool LockCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1673
1629
  switch (field_id) {
1674
- case 4: {
1630
+ case 4:
1675
1631
  this->code = value.as_string();
1676
- return true;
1677
- }
1632
+ break;
1678
1633
  default:
1679
1634
  return false;
1680
1635
  }
1636
+ return true;
1681
1637
  }
1682
1638
  bool LockCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1683
1639
  switch (field_id) {
1684
- case 1: {
1640
+ case 1:
1685
1641
  this->key = value.as_fixed32();
1686
- return true;
1687
- }
1642
+ break;
1688
1643
  default:
1689
1644
  return false;
1690
1645
  }
1646
+ return true;
1691
1647
  }
1692
1648
  #endif
1693
1649
  #ifdef USE_BUTTON
1694
1650
  void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const {
1695
- buffer.encode_string(1, this->object_id);
1651
+ buffer.encode_string(1, this->object_id_ref_);
1696
1652
  buffer.encode_fixed32(2, this->key);
1697
- buffer.encode_string(3, this->name);
1698
- buffer.encode_string(4, this->unique_id);
1699
- buffer.encode_string(5, this->icon);
1653
+ buffer.encode_string(3, this->name_ref_);
1654
+ #ifdef USE_ENTITY_ICON
1655
+ buffer.encode_string(5, this->icon_ref_);
1656
+ #endif
1700
1657
  buffer.encode_bool(6, this->disabled_by_default);
1701
1658
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
1702
- buffer.encode_string(8, this->device_class);
1659
+ buffer.encode_string(8, this->device_class_ref_);
1660
+ #ifdef USE_DEVICES
1703
1661
  buffer.encode_uint32(9, this->device_id);
1662
+ #endif
1704
1663
  }
1705
- void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const {
1706
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1707
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1708
- ProtoSize::add_string_field(total_size, 1, this->name);
1709
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1710
- ProtoSize::add_string_field(total_size, 1, this->icon);
1711
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
1712
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
1713
- ProtoSize::add_string_field(total_size, 1, this->device_class);
1714
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1664
+ void ListEntitiesButtonResponse::calculate_size(ProtoSize &size) const {
1665
+ size.add_length(1, this->object_id_ref_.size());
1666
+ size.add_fixed32(1, this->key);
1667
+ size.add_length(1, this->name_ref_.size());
1668
+ #ifdef USE_ENTITY_ICON
1669
+ size.add_length(1, this->icon_ref_.size());
1670
+ #endif
1671
+ size.add_bool(1, this->disabled_by_default);
1672
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
1673
+ size.add_length(1, this->device_class_ref_.size());
1674
+ #ifdef USE_DEVICES
1675
+ size.add_uint32(1, this->device_id);
1676
+ #endif
1715
1677
  }
1716
1678
  bool ButtonCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1717
1679
  switch (field_id) {
1718
- case 2: {
1680
+ #ifdef USE_DEVICES
1681
+ case 2:
1719
1682
  this->device_id = value.as_uint32();
1720
- return true;
1721
- }
1722
- default:
1723
- return false;
1724
- }
1725
- }
1726
- bool ButtonCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1727
- switch (field_id) {
1728
- case 1: {
1729
- this->key = value.as_fixed32();
1730
- return true;
1731
- }
1732
- default:
1733
- return false;
1734
- }
1735
- }
1683
+ break;
1736
1684
  #endif
1737
- #ifdef USE_MEDIA_PLAYER
1738
- bool MediaPlayerSupportedFormat::decode_varint(uint32_t field_id, ProtoVarInt value) {
1739
- switch (field_id) {
1740
- case 2: {
1741
- this->sample_rate = value.as_uint32();
1742
- return true;
1743
- }
1744
- case 3: {
1745
- this->num_channels = value.as_uint32();
1746
- return true;
1747
- }
1748
- case 4: {
1749
- this->purpose = static_cast<enums::MediaPlayerFormatPurpose>(value.as_uint32());
1750
- return true;
1751
- }
1752
- case 5: {
1753
- this->sample_bytes = value.as_uint32();
1754
- return true;
1755
- }
1756
1685
  default:
1757
1686
  return false;
1758
1687
  }
1688
+ return true;
1759
1689
  }
1760
- bool MediaPlayerSupportedFormat::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1690
+ bool ButtonCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1761
1691
  switch (field_id) {
1762
- case 1: {
1763
- this->format = value.as_string();
1764
- return true;
1765
- }
1692
+ case 1:
1693
+ this->key = value.as_fixed32();
1694
+ break;
1766
1695
  default:
1767
1696
  return false;
1768
1697
  }
1698
+ return true;
1769
1699
  }
1700
+ #endif
1701
+ #ifdef USE_MEDIA_PLAYER
1770
1702
  void MediaPlayerSupportedFormat::encode(ProtoWriteBuffer buffer) const {
1771
- buffer.encode_string(1, this->format);
1703
+ buffer.encode_string(1, this->format_ref_);
1772
1704
  buffer.encode_uint32(2, this->sample_rate);
1773
1705
  buffer.encode_uint32(3, this->num_channels);
1774
1706
  buffer.encode_uint32(4, static_cast<uint32_t>(this->purpose));
1775
1707
  buffer.encode_uint32(5, this->sample_bytes);
1776
1708
  }
1777
- void MediaPlayerSupportedFormat::calculate_size(uint32_t &total_size) const {
1778
- ProtoSize::add_string_field(total_size, 1, this->format);
1779
- ProtoSize::add_uint32_field(total_size, 1, this->sample_rate);
1780
- ProtoSize::add_uint32_field(total_size, 1, this->num_channels);
1781
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->purpose));
1782
- ProtoSize::add_uint32_field(total_size, 1, this->sample_bytes);
1709
+ void MediaPlayerSupportedFormat::calculate_size(ProtoSize &size) const {
1710
+ size.add_length(1, this->format_ref_.size());
1711
+ size.add_uint32(1, this->sample_rate);
1712
+ size.add_uint32(1, this->num_channels);
1713
+ size.add_uint32(1, static_cast<uint32_t>(this->purpose));
1714
+ size.add_uint32(1, this->sample_bytes);
1783
1715
  }
1784
1716
  void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const {
1785
- buffer.encode_string(1, this->object_id);
1717
+ buffer.encode_string(1, this->object_id_ref_);
1786
1718
  buffer.encode_fixed32(2, this->key);
1787
- buffer.encode_string(3, this->name);
1788
- buffer.encode_string(4, this->unique_id);
1789
- buffer.encode_string(5, this->icon);
1719
+ buffer.encode_string(3, this->name_ref_);
1720
+ #ifdef USE_ENTITY_ICON
1721
+ buffer.encode_string(5, this->icon_ref_);
1722
+ #endif
1790
1723
  buffer.encode_bool(6, this->disabled_by_default);
1791
1724
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
1792
1725
  buffer.encode_bool(8, this->supports_pause);
1793
1726
  for (auto &it : this->supported_formats) {
1794
1727
  buffer.encode_message(9, it, true);
1795
1728
  }
1729
+ #ifdef USE_DEVICES
1796
1730
  buffer.encode_uint32(10, this->device_id);
1797
- }
1798
- void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const {
1799
- ProtoSize::add_string_field(total_size, 1, this->object_id);
1800
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1801
- ProtoSize::add_string_field(total_size, 1, this->name);
1802
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
1803
- ProtoSize::add_string_field(total_size, 1, this->icon);
1804
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
1805
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
1806
- ProtoSize::add_bool_field(total_size, 1, this->supports_pause);
1807
- ProtoSize::add_repeated_message(total_size, 1, this->supported_formats);
1808
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1731
+ #endif
1732
+ buffer.encode_uint32(11, this->feature_flags);
1733
+ }
1734
+ void ListEntitiesMediaPlayerResponse::calculate_size(ProtoSize &size) const {
1735
+ size.add_length(1, this->object_id_ref_.size());
1736
+ size.add_fixed32(1, this->key);
1737
+ size.add_length(1, this->name_ref_.size());
1738
+ #ifdef USE_ENTITY_ICON
1739
+ size.add_length(1, this->icon_ref_.size());
1740
+ #endif
1741
+ size.add_bool(1, this->disabled_by_default);
1742
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
1743
+ size.add_bool(1, this->supports_pause);
1744
+ size.add_repeated_message(1, this->supported_formats);
1745
+ #ifdef USE_DEVICES
1746
+ size.add_uint32(1, this->device_id);
1747
+ #endif
1748
+ size.add_uint32(1, this->feature_flags);
1809
1749
  }
1810
1750
  void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const {
1811
1751
  buffer.encode_fixed32(1, this->key);
1812
1752
  buffer.encode_uint32(2, static_cast<uint32_t>(this->state));
1813
1753
  buffer.encode_float(3, this->volume);
1814
1754
  buffer.encode_bool(4, this->muted);
1755
+ #ifdef USE_DEVICES
1815
1756
  buffer.encode_uint32(5, this->device_id);
1757
+ #endif
1816
1758
  }
1817
- void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const {
1818
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
1819
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
1820
- ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f);
1821
- ProtoSize::add_bool_field(total_size, 1, this->muted);
1822
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
1759
+ void MediaPlayerStateResponse::calculate_size(ProtoSize &size) const {
1760
+ size.add_fixed32(1, this->key);
1761
+ size.add_uint32(1, static_cast<uint32_t>(this->state));
1762
+ size.add_float(1, this->volume);
1763
+ size.add_bool(1, this->muted);
1764
+ #ifdef USE_DEVICES
1765
+ size.add_uint32(1, this->device_id);
1766
+ #endif
1823
1767
  }
1824
1768
  bool MediaPlayerCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1825
1769
  switch (field_id) {
1826
- case 2: {
1770
+ case 2:
1827
1771
  this->has_command = value.as_bool();
1828
- return true;
1829
- }
1830
- case 3: {
1772
+ break;
1773
+ case 3:
1831
1774
  this->command = static_cast<enums::MediaPlayerCommand>(value.as_uint32());
1832
- return true;
1833
- }
1834
- case 4: {
1775
+ break;
1776
+ case 4:
1835
1777
  this->has_volume = value.as_bool();
1836
- return true;
1837
- }
1838
- case 6: {
1778
+ break;
1779
+ case 6:
1839
1780
  this->has_media_url = value.as_bool();
1840
- return true;
1841
- }
1842
- case 8: {
1781
+ break;
1782
+ case 8:
1843
1783
  this->has_announcement = value.as_bool();
1844
- return true;
1845
- }
1846
- case 9: {
1784
+ break;
1785
+ case 9:
1847
1786
  this->announcement = value.as_bool();
1848
- return true;
1849
- }
1850
- case 10: {
1787
+ break;
1788
+ #ifdef USE_DEVICES
1789
+ case 10:
1851
1790
  this->device_id = value.as_uint32();
1852
- return true;
1853
- }
1791
+ break;
1792
+ #endif
1854
1793
  default:
1855
1794
  return false;
1856
1795
  }
1796
+ return true;
1857
1797
  }
1858
1798
  bool MediaPlayerCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1859
1799
  switch (field_id) {
1860
- case 7: {
1800
+ case 7:
1861
1801
  this->media_url = value.as_string();
1862
- return true;
1863
- }
1802
+ break;
1864
1803
  default:
1865
1804
  return false;
1866
1805
  }
1806
+ return true;
1867
1807
  }
1868
1808
  bool MediaPlayerCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
1869
1809
  switch (field_id) {
1870
- case 1: {
1810
+ case 1:
1871
1811
  this->key = value.as_fixed32();
1872
- return true;
1873
- }
1874
- case 5: {
1812
+ break;
1813
+ case 5:
1875
1814
  this->volume = value.as_float();
1876
- return true;
1877
- }
1815
+ break;
1878
1816
  default:
1879
1817
  return false;
1880
1818
  }
1819
+ return true;
1881
1820
  }
1882
1821
  #endif
1883
1822
  #ifdef USE_BLUETOOTH_PROXY
1884
1823
  bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
1885
1824
  switch (field_id) {
1886
- case 1: {
1825
+ case 1:
1887
1826
  this->flags = value.as_uint32();
1888
- return true;
1889
- }
1890
- default:
1891
- return false;
1892
- }
1893
- }
1894
- bool BluetoothServiceData::decode_varint(uint32_t field_id, ProtoVarInt value) {
1895
- switch (field_id) {
1896
- case 2: {
1897
- this->legacy_data.push_back(value.as_uint32());
1898
- return true;
1899
- }
1900
- default:
1901
- return false;
1902
- }
1903
- }
1904
- bool BluetoothServiceData::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1905
- switch (field_id) {
1906
- case 1: {
1907
- this->uuid = value.as_string();
1908
- return true;
1909
- }
1910
- case 3: {
1911
- this->data = value.as_string();
1912
- return true;
1913
- }
1914
- default:
1915
- return false;
1916
- }
1917
- }
1918
- void BluetoothServiceData::encode(ProtoWriteBuffer buffer) const {
1919
- buffer.encode_string(1, this->uuid);
1920
- for (auto &it : this->legacy_data) {
1921
- buffer.encode_uint32(2, it, true);
1922
- }
1923
- buffer.encode_bytes(3, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
1924
- }
1925
- void BluetoothServiceData::calculate_size(uint32_t &total_size) const {
1926
- ProtoSize::add_string_field(total_size, 1, this->uuid);
1927
- if (!this->legacy_data.empty()) {
1928
- for (const auto &it : this->legacy_data) {
1929
- ProtoSize::add_uint32_field_repeated(total_size, 1, it);
1930
- }
1931
- }
1932
- ProtoSize::add_string_field(total_size, 1, this->data);
1933
- }
1934
- void BluetoothLEAdvertisementResponse::encode(ProtoWriteBuffer buffer) const {
1935
- buffer.encode_uint64(1, this->address);
1936
- buffer.encode_bytes(2, reinterpret_cast<const uint8_t *>(this->name.data()), this->name.size());
1937
- buffer.encode_sint32(3, this->rssi);
1938
- for (auto &it : this->service_uuids) {
1939
- buffer.encode_string(4, it, true);
1940
- }
1941
- for (auto &it : this->service_data) {
1942
- buffer.encode_message(5, it, true);
1943
- }
1944
- for (auto &it : this->manufacturer_data) {
1945
- buffer.encode_message(6, it, true);
1946
- }
1947
- buffer.encode_uint32(7, this->address_type);
1948
- }
1949
- void BluetoothLEAdvertisementResponse::calculate_size(uint32_t &total_size) const {
1950
- ProtoSize::add_uint64_field(total_size, 1, this->address);
1951
- ProtoSize::add_string_field(total_size, 1, this->name);
1952
- ProtoSize::add_sint32_field(total_size, 1, this->rssi);
1953
- if (!this->service_uuids.empty()) {
1954
- for (const auto &it : this->service_uuids) {
1955
- ProtoSize::add_string_field_repeated(total_size, 1, it);
1956
- }
1957
- }
1958
- ProtoSize::add_repeated_message(total_size, 1, this->service_data);
1959
- ProtoSize::add_repeated_message(total_size, 1, this->manufacturer_data);
1960
- ProtoSize::add_uint32_field(total_size, 1, this->address_type);
1961
- }
1962
- bool BluetoothLERawAdvertisement::decode_varint(uint32_t field_id, ProtoVarInt value) {
1963
- switch (field_id) {
1964
- case 1: {
1965
- this->address = value.as_uint64();
1966
- return true;
1967
- }
1968
- case 2: {
1969
- this->rssi = value.as_sint32();
1970
- return true;
1971
- }
1972
- case 3: {
1973
- this->address_type = value.as_uint32();
1974
- return true;
1975
- }
1976
- default:
1977
- return false;
1978
- }
1979
- }
1980
- bool BluetoothLERawAdvertisement::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
1981
- switch (field_id) {
1982
- case 4: {
1983
- this->data = value.as_string();
1984
- return true;
1985
- }
1827
+ break;
1986
1828
  default:
1987
1829
  return false;
1988
1830
  }
1831
+ return true;
1989
1832
  }
1990
1833
  void BluetoothLERawAdvertisement::encode(ProtoWriteBuffer buffer) const {
1991
1834
  buffer.encode_uint64(1, this->address);
1992
1835
  buffer.encode_sint32(2, this->rssi);
1993
1836
  buffer.encode_uint32(3, this->address_type);
1994
- buffer.encode_bytes(4, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
1837
+ buffer.encode_bytes(4, this->data, this->data_len);
1995
1838
  }
1996
- void BluetoothLERawAdvertisement::calculate_size(uint32_t &total_size) const {
1997
- ProtoSize::add_uint64_field(total_size, 1, this->address);
1998
- ProtoSize::add_sint32_field(total_size, 1, this->rssi);
1999
- ProtoSize::add_uint32_field(total_size, 1, this->address_type);
2000
- ProtoSize::add_string_field(total_size, 1, this->data);
1839
+ void BluetoothLERawAdvertisement::calculate_size(ProtoSize &size) const {
1840
+ size.add_uint64(1, this->address);
1841
+ size.add_sint32(1, this->rssi);
1842
+ size.add_uint32(1, this->address_type);
1843
+ size.add_length(1, this->data_len);
2001
1844
  }
2002
1845
  void BluetoothLERawAdvertisementsResponse::encode(ProtoWriteBuffer buffer) const {
2003
- for (auto &it : this->advertisements) {
2004
- buffer.encode_message(1, it, true);
1846
+ for (uint16_t i = 0; i < this->advertisements_len; i++) {
1847
+ buffer.encode_message(1, this->advertisements[i], true);
2005
1848
  }
2006
1849
  }
2007
- void BluetoothLERawAdvertisementsResponse::calculate_size(uint32_t &total_size) const {
2008
- ProtoSize::add_repeated_message(total_size, 1, this->advertisements);
1850
+ void BluetoothLERawAdvertisementsResponse::calculate_size(ProtoSize &size) const {
1851
+ for (uint16_t i = 0; i < this->advertisements_len; i++) {
1852
+ size.add_message_object_force(1, this->advertisements[i]);
1853
+ }
2009
1854
  }
2010
1855
  bool BluetoothDeviceRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2011
1856
  switch (field_id) {
2012
- case 1: {
1857
+ case 1:
2013
1858
  this->address = value.as_uint64();
2014
- return true;
2015
- }
2016
- case 2: {
1859
+ break;
1860
+ case 2:
2017
1861
  this->request_type = static_cast<enums::BluetoothDeviceRequestType>(value.as_uint32());
2018
- return true;
2019
- }
2020
- case 3: {
1862
+ break;
1863
+ case 3:
2021
1864
  this->has_address_type = value.as_bool();
2022
- return true;
2023
- }
2024
- case 4: {
1865
+ break;
1866
+ case 4:
2025
1867
  this->address_type = value.as_uint32();
2026
- return true;
2027
- }
1868
+ break;
2028
1869
  default:
2029
1870
  return false;
2030
1871
  }
1872
+ return true;
2031
1873
  }
2032
1874
  void BluetoothDeviceConnectionResponse::encode(ProtoWriteBuffer buffer) const {
2033
1875
  buffer.encode_uint64(1, this->address);
@@ -2035,141 +1877,79 @@ void BluetoothDeviceConnectionResponse::encode(ProtoWriteBuffer buffer) const {
2035
1877
  buffer.encode_uint32(3, this->mtu);
2036
1878
  buffer.encode_int32(4, this->error);
2037
1879
  }
2038
- void BluetoothDeviceConnectionResponse::calculate_size(uint32_t &total_size) const {
2039
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2040
- ProtoSize::add_bool_field(total_size, 1, this->connected);
2041
- ProtoSize::add_uint32_field(total_size, 1, this->mtu);
2042
- ProtoSize::add_int32_field(total_size, 1, this->error);
1880
+ void BluetoothDeviceConnectionResponse::calculate_size(ProtoSize &size) const {
1881
+ size.add_uint64(1, this->address);
1882
+ size.add_bool(1, this->connected);
1883
+ size.add_uint32(1, this->mtu);
1884
+ size.add_int32(1, this->error);
2043
1885
  }
2044
1886
  bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2045
1887
  switch (field_id) {
2046
- case 1: {
1888
+ case 1:
2047
1889
  this->address = value.as_uint64();
2048
- return true;
2049
- }
2050
- default:
2051
- return false;
2052
- }
2053
- }
2054
- bool BluetoothGATTDescriptor::decode_varint(uint32_t field_id, ProtoVarInt value) {
2055
- switch (field_id) {
2056
- case 1: {
2057
- this->uuid.push_back(value.as_uint64());
2058
- return true;
2059
- }
2060
- case 2: {
2061
- this->handle = value.as_uint32();
2062
- return true;
2063
- }
1890
+ break;
2064
1891
  default:
2065
1892
  return false;
2066
1893
  }
1894
+ return true;
2067
1895
  }
2068
1896
  void BluetoothGATTDescriptor::encode(ProtoWriteBuffer buffer) const {
2069
- for (auto &it : this->uuid) {
2070
- buffer.encode_uint64(1, it, true);
1897
+ if (this->uuid[0] != 0 || this->uuid[1] != 0) {
1898
+ buffer.encode_uint64(1, this->uuid[0], true);
1899
+ buffer.encode_uint64(1, this->uuid[1], true);
2071
1900
  }
2072
1901
  buffer.encode_uint32(2, this->handle);
1902
+ buffer.encode_uint32(3, this->short_uuid);
2073
1903
  }
2074
- void BluetoothGATTDescriptor::calculate_size(uint32_t &total_size) const {
2075
- if (!this->uuid.empty()) {
2076
- for (const auto &it : this->uuid) {
2077
- ProtoSize::add_uint64_field_repeated(total_size, 1, it);
2078
- }
2079
- }
2080
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2081
- }
2082
- bool BluetoothGATTCharacteristic::decode_varint(uint32_t field_id, ProtoVarInt value) {
2083
- switch (field_id) {
2084
- case 1: {
2085
- this->uuid.push_back(value.as_uint64());
2086
- return true;
2087
- }
2088
- case 2: {
2089
- this->handle = value.as_uint32();
2090
- return true;
2091
- }
2092
- case 3: {
2093
- this->properties = value.as_uint32();
2094
- return true;
2095
- }
2096
- default:
2097
- return false;
2098
- }
2099
- }
2100
- bool BluetoothGATTCharacteristic::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2101
- switch (field_id) {
2102
- case 4: {
2103
- this->descriptors.emplace_back();
2104
- value.decode_to_message(this->descriptors.back());
2105
- return true;
2106
- }
2107
- default:
2108
- return false;
1904
+ void BluetoothGATTDescriptor::calculate_size(ProtoSize &size) const {
1905
+ if (this->uuid[0] != 0 || this->uuid[1] != 0) {
1906
+ size.add_uint64_force(1, this->uuid[0]);
1907
+ size.add_uint64_force(1, this->uuid[1]);
2109
1908
  }
1909
+ size.add_uint32(1, this->handle);
1910
+ size.add_uint32(1, this->short_uuid);
2110
1911
  }
2111
1912
  void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer buffer) const {
2112
- for (auto &it : this->uuid) {
2113
- buffer.encode_uint64(1, it, true);
1913
+ if (this->uuid[0] != 0 || this->uuid[1] != 0) {
1914
+ buffer.encode_uint64(1, this->uuid[0], true);
1915
+ buffer.encode_uint64(1, this->uuid[1], true);
2114
1916
  }
2115
1917
  buffer.encode_uint32(2, this->handle);
2116
1918
  buffer.encode_uint32(3, this->properties);
2117
1919
  for (auto &it : this->descriptors) {
2118
1920
  buffer.encode_message(4, it, true);
2119
1921
  }
1922
+ buffer.encode_uint32(5, this->short_uuid);
2120
1923
  }
2121
- void BluetoothGATTCharacteristic::calculate_size(uint32_t &total_size) const {
2122
- if (!this->uuid.empty()) {
2123
- for (const auto &it : this->uuid) {
2124
- ProtoSize::add_uint64_field_repeated(total_size, 1, it);
2125
- }
2126
- }
2127
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2128
- ProtoSize::add_uint32_field(total_size, 1, this->properties);
2129
- ProtoSize::add_repeated_message(total_size, 1, this->descriptors);
2130
- }
2131
- bool BluetoothGATTService::decode_varint(uint32_t field_id, ProtoVarInt value) {
2132
- switch (field_id) {
2133
- case 1: {
2134
- this->uuid.push_back(value.as_uint64());
2135
- return true;
2136
- }
2137
- case 2: {
2138
- this->handle = value.as_uint32();
2139
- return true;
2140
- }
2141
- default:
2142
- return false;
2143
- }
2144
- }
2145
- bool BluetoothGATTService::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2146
- switch (field_id) {
2147
- case 3: {
2148
- this->characteristics.emplace_back();
2149
- value.decode_to_message(this->characteristics.back());
2150
- return true;
2151
- }
2152
- default:
2153
- return false;
1924
+ void BluetoothGATTCharacteristic::calculate_size(ProtoSize &size) const {
1925
+ if (this->uuid[0] != 0 || this->uuid[1] != 0) {
1926
+ size.add_uint64_force(1, this->uuid[0]);
1927
+ size.add_uint64_force(1, this->uuid[1]);
2154
1928
  }
1929
+ size.add_uint32(1, this->handle);
1930
+ size.add_uint32(1, this->properties);
1931
+ size.add_repeated_message(1, this->descriptors);
1932
+ size.add_uint32(1, this->short_uuid);
2155
1933
  }
2156
1934
  void BluetoothGATTService::encode(ProtoWriteBuffer buffer) const {
2157
- for (auto &it : this->uuid) {
2158
- buffer.encode_uint64(1, it, true);
1935
+ if (this->uuid[0] != 0 || this->uuid[1] != 0) {
1936
+ buffer.encode_uint64(1, this->uuid[0], true);
1937
+ buffer.encode_uint64(1, this->uuid[1], true);
2159
1938
  }
2160
1939
  buffer.encode_uint32(2, this->handle);
2161
1940
  for (auto &it : this->characteristics) {
2162
1941
  buffer.encode_message(3, it, true);
2163
1942
  }
1943
+ buffer.encode_uint32(4, this->short_uuid);
2164
1944
  }
2165
- void BluetoothGATTService::calculate_size(uint32_t &total_size) const {
2166
- if (!this->uuid.empty()) {
2167
- for (const auto &it : this->uuid) {
2168
- ProtoSize::add_uint64_field_repeated(total_size, 1, it);
2169
- }
1945
+ void BluetoothGATTService::calculate_size(ProtoSize &size) const {
1946
+ if (this->uuid[0] != 0 || this->uuid[1] != 0) {
1947
+ size.add_uint64_force(1, this->uuid[0]);
1948
+ size.add_uint64_force(1, this->uuid[1]);
2170
1949
  }
2171
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2172
- ProtoSize::add_repeated_message(total_size, 1, this->characteristics);
1950
+ size.add_uint32(1, this->handle);
1951
+ size.add_repeated_message(1, this->characteristics);
1952
+ size.add_uint32(1, this->short_uuid);
2173
1953
  }
2174
1954
  void BluetoothGATTGetServicesResponse::encode(ProtoWriteBuffer buffer) const {
2175
1955
  buffer.encode_uint64(1, this->address);
@@ -2177,147 +1957,140 @@ void BluetoothGATTGetServicesResponse::encode(ProtoWriteBuffer buffer) const {
2177
1957
  buffer.encode_message(2, it, true);
2178
1958
  }
2179
1959
  }
2180
- void BluetoothGATTGetServicesResponse::calculate_size(uint32_t &total_size) const {
2181
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2182
- ProtoSize::add_repeated_message(total_size, 1, this->services);
1960
+ void BluetoothGATTGetServicesResponse::calculate_size(ProtoSize &size) const {
1961
+ size.add_uint64(1, this->address);
1962
+ size.add_repeated_message(1, this->services);
2183
1963
  }
2184
1964
  void BluetoothGATTGetServicesDoneResponse::encode(ProtoWriteBuffer buffer) const {
2185
1965
  buffer.encode_uint64(1, this->address);
2186
1966
  }
2187
- void BluetoothGATTGetServicesDoneResponse::calculate_size(uint32_t &total_size) const {
2188
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2189
- }
1967
+ void BluetoothGATTGetServicesDoneResponse::calculate_size(ProtoSize &size) const { size.add_uint64(1, this->address); }
2190
1968
  bool BluetoothGATTReadRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2191
1969
  switch (field_id) {
2192
- case 1: {
1970
+ case 1:
2193
1971
  this->address = value.as_uint64();
2194
- return true;
2195
- }
2196
- case 2: {
1972
+ break;
1973
+ case 2:
2197
1974
  this->handle = value.as_uint32();
2198
- return true;
2199
- }
1975
+ break;
2200
1976
  default:
2201
1977
  return false;
2202
1978
  }
1979
+ return true;
2203
1980
  }
2204
1981
  void BluetoothGATTReadResponse::encode(ProtoWriteBuffer buffer) const {
2205
1982
  buffer.encode_uint64(1, this->address);
2206
1983
  buffer.encode_uint32(2, this->handle);
2207
- buffer.encode_bytes(3, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
1984
+ buffer.encode_bytes(3, this->data_ptr_, this->data_len_);
2208
1985
  }
2209
- void BluetoothGATTReadResponse::calculate_size(uint32_t &total_size) const {
2210
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2211
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2212
- ProtoSize::add_string_field(total_size, 1, this->data);
1986
+ void BluetoothGATTReadResponse::calculate_size(ProtoSize &size) const {
1987
+ size.add_uint64(1, this->address);
1988
+ size.add_uint32(1, this->handle);
1989
+ size.add_length(1, this->data_len_);
2213
1990
  }
2214
1991
  bool BluetoothGATTWriteRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2215
1992
  switch (field_id) {
2216
- case 1: {
1993
+ case 1:
2217
1994
  this->address = value.as_uint64();
2218
- return true;
2219
- }
2220
- case 2: {
1995
+ break;
1996
+ case 2:
2221
1997
  this->handle = value.as_uint32();
2222
- return true;
2223
- }
2224
- case 3: {
1998
+ break;
1999
+ case 3:
2225
2000
  this->response = value.as_bool();
2226
- return true;
2227
- }
2001
+ break;
2228
2002
  default:
2229
2003
  return false;
2230
2004
  }
2005
+ return true;
2231
2006
  }
2232
2007
  bool BluetoothGATTWriteRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2233
2008
  switch (field_id) {
2234
- case 4: {
2009
+ case 4:
2235
2010
  this->data = value.as_string();
2236
- return true;
2237
- }
2011
+ break;
2238
2012
  default:
2239
2013
  return false;
2240
2014
  }
2015
+ return true;
2241
2016
  }
2242
2017
  bool BluetoothGATTReadDescriptorRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2243
2018
  switch (field_id) {
2244
- case 1: {
2019
+ case 1:
2245
2020
  this->address = value.as_uint64();
2246
- return true;
2247
- }
2248
- case 2: {
2021
+ break;
2022
+ case 2:
2249
2023
  this->handle = value.as_uint32();
2250
- return true;
2251
- }
2024
+ break;
2252
2025
  default:
2253
2026
  return false;
2254
2027
  }
2028
+ return true;
2255
2029
  }
2256
2030
  bool BluetoothGATTWriteDescriptorRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2257
2031
  switch (field_id) {
2258
- case 1: {
2032
+ case 1:
2259
2033
  this->address = value.as_uint64();
2260
- return true;
2261
- }
2262
- case 2: {
2034
+ break;
2035
+ case 2:
2263
2036
  this->handle = value.as_uint32();
2264
- return true;
2265
- }
2037
+ break;
2266
2038
  default:
2267
2039
  return false;
2268
2040
  }
2041
+ return true;
2269
2042
  }
2270
2043
  bool BluetoothGATTWriteDescriptorRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2271
2044
  switch (field_id) {
2272
- case 3: {
2045
+ case 3:
2273
2046
  this->data = value.as_string();
2274
- return true;
2275
- }
2047
+ break;
2276
2048
  default:
2277
2049
  return false;
2278
2050
  }
2051
+ return true;
2279
2052
  }
2280
2053
  bool BluetoothGATTNotifyRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2281
2054
  switch (field_id) {
2282
- case 1: {
2055
+ case 1:
2283
2056
  this->address = value.as_uint64();
2284
- return true;
2285
- }
2286
- case 2: {
2057
+ break;
2058
+ case 2:
2287
2059
  this->handle = value.as_uint32();
2288
- return true;
2289
- }
2290
- case 3: {
2060
+ break;
2061
+ case 3:
2291
2062
  this->enable = value.as_bool();
2292
- return true;
2293
- }
2063
+ break;
2294
2064
  default:
2295
2065
  return false;
2296
2066
  }
2067
+ return true;
2297
2068
  }
2298
2069
  void BluetoothGATTNotifyDataResponse::encode(ProtoWriteBuffer buffer) const {
2299
2070
  buffer.encode_uint64(1, this->address);
2300
2071
  buffer.encode_uint32(2, this->handle);
2301
- buffer.encode_bytes(3, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
2072
+ buffer.encode_bytes(3, this->data_ptr_, this->data_len_);
2302
2073
  }
2303
- void BluetoothGATTNotifyDataResponse::calculate_size(uint32_t &total_size) const {
2304
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2305
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2306
- ProtoSize::add_string_field(total_size, 1, this->data);
2074
+ void BluetoothGATTNotifyDataResponse::calculate_size(ProtoSize &size) const {
2075
+ size.add_uint64(1, this->address);
2076
+ size.add_uint32(1, this->handle);
2077
+ size.add_length(1, this->data_len_);
2307
2078
  }
2308
2079
  void BluetoothConnectionsFreeResponse::encode(ProtoWriteBuffer buffer) const {
2309
2080
  buffer.encode_uint32(1, this->free);
2310
2081
  buffer.encode_uint32(2, this->limit);
2311
- for (auto &it : this->allocated) {
2312
- buffer.encode_uint64(3, it, true);
2082
+ for (const auto &it : this->allocated) {
2083
+ if (it != 0) {
2084
+ buffer.encode_uint64(3, it, true);
2085
+ }
2313
2086
  }
2314
2087
  }
2315
- void BluetoothConnectionsFreeResponse::calculate_size(uint32_t &total_size) const {
2316
- ProtoSize::add_uint32_field(total_size, 1, this->free);
2317
- ProtoSize::add_uint32_field(total_size, 1, this->limit);
2318
- if (!this->allocated.empty()) {
2319
- for (const auto &it : this->allocated) {
2320
- ProtoSize::add_uint64_field_repeated(total_size, 1, it);
2088
+ void BluetoothConnectionsFreeResponse::calculate_size(ProtoSize &size) const {
2089
+ size.add_uint32(1, this->free);
2090
+ size.add_uint32(1, this->limit);
2091
+ for (const auto &it : this->allocated) {
2092
+ if (it != 0) {
2093
+ size.add_uint64_force(1, it);
2321
2094
  }
2322
2095
  }
2323
2096
  }
@@ -2326,323 +2099,262 @@ void BluetoothGATTErrorResponse::encode(ProtoWriteBuffer buffer) const {
2326
2099
  buffer.encode_uint32(2, this->handle);
2327
2100
  buffer.encode_int32(3, this->error);
2328
2101
  }
2329
- void BluetoothGATTErrorResponse::calculate_size(uint32_t &total_size) const {
2330
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2331
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2332
- ProtoSize::add_int32_field(total_size, 1, this->error);
2102
+ void BluetoothGATTErrorResponse::calculate_size(ProtoSize &size) const {
2103
+ size.add_uint64(1, this->address);
2104
+ size.add_uint32(1, this->handle);
2105
+ size.add_int32(1, this->error);
2333
2106
  }
2334
2107
  void BluetoothGATTWriteResponse::encode(ProtoWriteBuffer buffer) const {
2335
2108
  buffer.encode_uint64(1, this->address);
2336
2109
  buffer.encode_uint32(2, this->handle);
2337
2110
  }
2338
- void BluetoothGATTWriteResponse::calculate_size(uint32_t &total_size) const {
2339
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2340
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2111
+ void BluetoothGATTWriteResponse::calculate_size(ProtoSize &size) const {
2112
+ size.add_uint64(1, this->address);
2113
+ size.add_uint32(1, this->handle);
2341
2114
  }
2342
2115
  void BluetoothGATTNotifyResponse::encode(ProtoWriteBuffer buffer) const {
2343
2116
  buffer.encode_uint64(1, this->address);
2344
2117
  buffer.encode_uint32(2, this->handle);
2345
2118
  }
2346
- void BluetoothGATTNotifyResponse::calculate_size(uint32_t &total_size) const {
2347
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2348
- ProtoSize::add_uint32_field(total_size, 1, this->handle);
2119
+ void BluetoothGATTNotifyResponse::calculate_size(ProtoSize &size) const {
2120
+ size.add_uint64(1, this->address);
2121
+ size.add_uint32(1, this->handle);
2349
2122
  }
2350
2123
  void BluetoothDevicePairingResponse::encode(ProtoWriteBuffer buffer) const {
2351
2124
  buffer.encode_uint64(1, this->address);
2352
2125
  buffer.encode_bool(2, this->paired);
2353
2126
  buffer.encode_int32(3, this->error);
2354
2127
  }
2355
- void BluetoothDevicePairingResponse::calculate_size(uint32_t &total_size) const {
2356
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2357
- ProtoSize::add_bool_field(total_size, 1, this->paired);
2358
- ProtoSize::add_int32_field(total_size, 1, this->error);
2128
+ void BluetoothDevicePairingResponse::calculate_size(ProtoSize &size) const {
2129
+ size.add_uint64(1, this->address);
2130
+ size.add_bool(1, this->paired);
2131
+ size.add_int32(1, this->error);
2359
2132
  }
2360
2133
  void BluetoothDeviceUnpairingResponse::encode(ProtoWriteBuffer buffer) const {
2361
2134
  buffer.encode_uint64(1, this->address);
2362
2135
  buffer.encode_bool(2, this->success);
2363
2136
  buffer.encode_int32(3, this->error);
2364
2137
  }
2365
- void BluetoothDeviceUnpairingResponse::calculate_size(uint32_t &total_size) const {
2366
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2367
- ProtoSize::add_bool_field(total_size, 1, this->success);
2368
- ProtoSize::add_int32_field(total_size, 1, this->error);
2138
+ void BluetoothDeviceUnpairingResponse::calculate_size(ProtoSize &size) const {
2139
+ size.add_uint64(1, this->address);
2140
+ size.add_bool(1, this->success);
2141
+ size.add_int32(1, this->error);
2369
2142
  }
2370
2143
  void BluetoothDeviceClearCacheResponse::encode(ProtoWriteBuffer buffer) const {
2371
2144
  buffer.encode_uint64(1, this->address);
2372
2145
  buffer.encode_bool(2, this->success);
2373
2146
  buffer.encode_int32(3, this->error);
2374
2147
  }
2375
- void BluetoothDeviceClearCacheResponse::calculate_size(uint32_t &total_size) const {
2376
- ProtoSize::add_uint64_field(total_size, 1, this->address);
2377
- ProtoSize::add_bool_field(total_size, 1, this->success);
2378
- ProtoSize::add_int32_field(total_size, 1, this->error);
2148
+ void BluetoothDeviceClearCacheResponse::calculate_size(ProtoSize &size) const {
2149
+ size.add_uint64(1, this->address);
2150
+ size.add_bool(1, this->success);
2151
+ size.add_int32(1, this->error);
2379
2152
  }
2380
2153
  void BluetoothScannerStateResponse::encode(ProtoWriteBuffer buffer) const {
2381
2154
  buffer.encode_uint32(1, static_cast<uint32_t>(this->state));
2382
2155
  buffer.encode_uint32(2, static_cast<uint32_t>(this->mode));
2383
2156
  }
2384
- void BluetoothScannerStateResponse::calculate_size(uint32_t &total_size) const {
2385
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
2386
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
2157
+ void BluetoothScannerStateResponse::calculate_size(ProtoSize &size) const {
2158
+ size.add_uint32(1, static_cast<uint32_t>(this->state));
2159
+ size.add_uint32(1, static_cast<uint32_t>(this->mode));
2387
2160
  }
2388
2161
  bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2389
2162
  switch (field_id) {
2390
- case 1: {
2163
+ case 1:
2391
2164
  this->mode = static_cast<enums::BluetoothScannerMode>(value.as_uint32());
2392
- return true;
2393
- }
2165
+ break;
2394
2166
  default:
2395
2167
  return false;
2396
2168
  }
2169
+ return true;
2397
2170
  }
2398
2171
  #endif
2399
2172
  #ifdef USE_VOICE_ASSISTANT
2400
2173
  bool SubscribeVoiceAssistantRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2401
2174
  switch (field_id) {
2402
- case 1: {
2175
+ case 1:
2403
2176
  this->subscribe = value.as_bool();
2404
- return true;
2405
- }
2406
- case 2: {
2177
+ break;
2178
+ case 2:
2407
2179
  this->flags = value.as_uint32();
2408
- return true;
2409
- }
2410
- default:
2411
- return false;
2412
- }
2413
- }
2414
- bool VoiceAssistantAudioSettings::decode_varint(uint32_t field_id, ProtoVarInt value) {
2415
- switch (field_id) {
2416
- case 1: {
2417
- this->noise_suppression_level = value.as_uint32();
2418
- return true;
2419
- }
2420
- case 2: {
2421
- this->auto_gain = value.as_uint32();
2422
- return true;
2423
- }
2424
- default:
2425
- return false;
2426
- }
2427
- }
2428
- bool VoiceAssistantAudioSettings::decode_32bit(uint32_t field_id, Proto32Bit value) {
2429
- switch (field_id) {
2430
- case 3: {
2431
- this->volume_multiplier = value.as_float();
2432
- return true;
2433
- }
2180
+ break;
2434
2181
  default:
2435
2182
  return false;
2436
2183
  }
2184
+ return true;
2437
2185
  }
2438
2186
  void VoiceAssistantAudioSettings::encode(ProtoWriteBuffer buffer) const {
2439
2187
  buffer.encode_uint32(1, this->noise_suppression_level);
2440
2188
  buffer.encode_uint32(2, this->auto_gain);
2441
2189
  buffer.encode_float(3, this->volume_multiplier);
2442
2190
  }
2443
- void VoiceAssistantAudioSettings::calculate_size(uint32_t &total_size) const {
2444
- ProtoSize::add_uint32_field(total_size, 1, this->noise_suppression_level);
2445
- ProtoSize::add_uint32_field(total_size, 1, this->auto_gain);
2446
- ProtoSize::add_fixed_field<4>(total_size, 1, this->volume_multiplier != 0.0f);
2191
+ void VoiceAssistantAudioSettings::calculate_size(ProtoSize &size) const {
2192
+ size.add_uint32(1, this->noise_suppression_level);
2193
+ size.add_uint32(1, this->auto_gain);
2194
+ size.add_float(1, this->volume_multiplier);
2447
2195
  }
2448
2196
  void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const {
2449
2197
  buffer.encode_bool(1, this->start);
2450
- buffer.encode_string(2, this->conversation_id);
2198
+ buffer.encode_string(2, this->conversation_id_ref_);
2451
2199
  buffer.encode_uint32(3, this->flags);
2452
2200
  buffer.encode_message(4, this->audio_settings);
2453
- buffer.encode_string(5, this->wake_word_phrase);
2201
+ buffer.encode_string(5, this->wake_word_phrase_ref_);
2454
2202
  }
2455
- void VoiceAssistantRequest::calculate_size(uint32_t &total_size) const {
2456
- ProtoSize::add_bool_field(total_size, 1, this->start);
2457
- ProtoSize::add_string_field(total_size, 1, this->conversation_id);
2458
- ProtoSize::add_uint32_field(total_size, 1, this->flags);
2459
- ProtoSize::add_message_object(total_size, 1, this->audio_settings);
2460
- ProtoSize::add_string_field(total_size, 1, this->wake_word_phrase);
2203
+ void VoiceAssistantRequest::calculate_size(ProtoSize &size) const {
2204
+ size.add_bool(1, this->start);
2205
+ size.add_length(1, this->conversation_id_ref_.size());
2206
+ size.add_uint32(1, this->flags);
2207
+ size.add_message_object(1, this->audio_settings);
2208
+ size.add_length(1, this->wake_word_phrase_ref_.size());
2461
2209
  }
2462
2210
  bool VoiceAssistantResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
2463
2211
  switch (field_id) {
2464
- case 1: {
2212
+ case 1:
2465
2213
  this->port = value.as_uint32();
2466
- return true;
2467
- }
2468
- case 2: {
2214
+ break;
2215
+ case 2:
2469
2216
  this->error = value.as_bool();
2470
- return true;
2471
- }
2217
+ break;
2472
2218
  default:
2473
2219
  return false;
2474
2220
  }
2221
+ return true;
2475
2222
  }
2476
2223
  bool VoiceAssistantEventData::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2477
2224
  switch (field_id) {
2478
- case 1: {
2225
+ case 1:
2479
2226
  this->name = value.as_string();
2480
- return true;
2481
- }
2482
- case 2: {
2227
+ break;
2228
+ case 2:
2483
2229
  this->value = value.as_string();
2484
- return true;
2485
- }
2230
+ break;
2486
2231
  default:
2487
2232
  return false;
2488
2233
  }
2489
- }
2490
- void VoiceAssistantEventData::encode(ProtoWriteBuffer buffer) const {
2491
- buffer.encode_string(1, this->name);
2492
- buffer.encode_string(2, this->value);
2493
- }
2494
- void VoiceAssistantEventData::calculate_size(uint32_t &total_size) const {
2495
- ProtoSize::add_string_field(total_size, 1, this->name);
2496
- ProtoSize::add_string_field(total_size, 1, this->value);
2234
+ return true;
2497
2235
  }
2498
2236
  bool VoiceAssistantEventResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
2499
2237
  switch (field_id) {
2500
- case 1: {
2238
+ case 1:
2501
2239
  this->event_type = static_cast<enums::VoiceAssistantEvent>(value.as_uint32());
2502
- return true;
2503
- }
2240
+ break;
2504
2241
  default:
2505
2242
  return false;
2506
2243
  }
2244
+ return true;
2507
2245
  }
2508
2246
  bool VoiceAssistantEventResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2509
2247
  switch (field_id) {
2510
- case 2: {
2248
+ case 2:
2511
2249
  this->data.emplace_back();
2512
2250
  value.decode_to_message(this->data.back());
2513
- return true;
2514
- }
2251
+ break;
2515
2252
  default:
2516
2253
  return false;
2517
2254
  }
2255
+ return true;
2518
2256
  }
2519
2257
  bool VoiceAssistantAudio::decode_varint(uint32_t field_id, ProtoVarInt value) {
2520
2258
  switch (field_id) {
2521
- case 2: {
2259
+ case 2:
2522
2260
  this->end = value.as_bool();
2523
- return true;
2524
- }
2261
+ break;
2525
2262
  default:
2526
2263
  return false;
2527
2264
  }
2265
+ return true;
2528
2266
  }
2529
2267
  bool VoiceAssistantAudio::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2530
2268
  switch (field_id) {
2531
- case 1: {
2269
+ case 1:
2532
2270
  this->data = value.as_string();
2533
- return true;
2534
- }
2271
+ break;
2535
2272
  default:
2536
2273
  return false;
2537
2274
  }
2275
+ return true;
2538
2276
  }
2539
2277
  void VoiceAssistantAudio::encode(ProtoWriteBuffer buffer) const {
2540
- buffer.encode_bytes(1, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
2278
+ buffer.encode_bytes(1, this->data_ptr_, this->data_len_);
2541
2279
  buffer.encode_bool(2, this->end);
2542
2280
  }
2543
- void VoiceAssistantAudio::calculate_size(uint32_t &total_size) const {
2544
- ProtoSize::add_string_field(total_size, 1, this->data);
2545
- ProtoSize::add_bool_field(total_size, 1, this->end);
2281
+ void VoiceAssistantAudio::calculate_size(ProtoSize &size) const {
2282
+ size.add_length(1, this->data_len_);
2283
+ size.add_bool(1, this->end);
2546
2284
  }
2547
2285
  bool VoiceAssistantTimerEventResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
2548
2286
  switch (field_id) {
2549
- case 1: {
2287
+ case 1:
2550
2288
  this->event_type = static_cast<enums::VoiceAssistantTimerEvent>(value.as_uint32());
2551
- return true;
2552
- }
2553
- case 4: {
2289
+ break;
2290
+ case 4:
2554
2291
  this->total_seconds = value.as_uint32();
2555
- return true;
2556
- }
2557
- case 5: {
2292
+ break;
2293
+ case 5:
2558
2294
  this->seconds_left = value.as_uint32();
2559
- return true;
2560
- }
2561
- case 6: {
2295
+ break;
2296
+ case 6:
2562
2297
  this->is_active = value.as_bool();
2563
- return true;
2564
- }
2298
+ break;
2565
2299
  default:
2566
2300
  return false;
2567
2301
  }
2302
+ return true;
2568
2303
  }
2569
2304
  bool VoiceAssistantTimerEventResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2570
2305
  switch (field_id) {
2571
- case 2: {
2306
+ case 2:
2572
2307
  this->timer_id = value.as_string();
2573
- return true;
2574
- }
2575
- case 3: {
2308
+ break;
2309
+ case 3:
2576
2310
  this->name = value.as_string();
2577
- return true;
2578
- }
2311
+ break;
2579
2312
  default:
2580
2313
  return false;
2581
2314
  }
2315
+ return true;
2582
2316
  }
2583
2317
  bool VoiceAssistantAnnounceRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2584
2318
  switch (field_id) {
2585
- case 4: {
2319
+ case 4:
2586
2320
  this->start_conversation = value.as_bool();
2587
- return true;
2588
- }
2321
+ break;
2589
2322
  default:
2590
2323
  return false;
2591
2324
  }
2325
+ return true;
2592
2326
  }
2593
2327
  bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2594
2328
  switch (field_id) {
2595
- case 1: {
2329
+ case 1:
2596
2330
  this->media_id = value.as_string();
2597
- return true;
2598
- }
2599
- case 2: {
2331
+ break;
2332
+ case 2:
2600
2333
  this->text = value.as_string();
2601
- return true;
2602
- }
2603
- case 3: {
2334
+ break;
2335
+ case 3:
2604
2336
  this->preannounce_media_id = value.as_string();
2605
- return true;
2606
- }
2337
+ break;
2607
2338
  default:
2608
2339
  return false;
2609
2340
  }
2341
+ return true;
2610
2342
  }
2611
2343
  void VoiceAssistantAnnounceFinished::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); }
2612
- void VoiceAssistantAnnounceFinished::calculate_size(uint32_t &total_size) const {
2613
- ProtoSize::add_bool_field(total_size, 1, this->success);
2614
- }
2615
- bool VoiceAssistantWakeWord::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2616
- switch (field_id) {
2617
- case 1: {
2618
- this->id = value.as_string();
2619
- return true;
2620
- }
2621
- case 2: {
2622
- this->wake_word = value.as_string();
2623
- return true;
2624
- }
2625
- case 3: {
2626
- this->trained_languages.push_back(value.as_string());
2627
- return true;
2628
- }
2629
- default:
2630
- return false;
2631
- }
2632
- }
2344
+ void VoiceAssistantAnnounceFinished::calculate_size(ProtoSize &size) const { size.add_bool(1, this->success); }
2633
2345
  void VoiceAssistantWakeWord::encode(ProtoWriteBuffer buffer) const {
2634
- buffer.encode_string(1, this->id);
2635
- buffer.encode_string(2, this->wake_word);
2346
+ buffer.encode_string(1, this->id_ref_);
2347
+ buffer.encode_string(2, this->wake_word_ref_);
2636
2348
  for (auto &it : this->trained_languages) {
2637
2349
  buffer.encode_string(3, it, true);
2638
2350
  }
2639
2351
  }
2640
- void VoiceAssistantWakeWord::calculate_size(uint32_t &total_size) const {
2641
- ProtoSize::add_string_field(total_size, 1, this->id);
2642
- ProtoSize::add_string_field(total_size, 1, this->wake_word);
2352
+ void VoiceAssistantWakeWord::calculate_size(ProtoSize &size) const {
2353
+ size.add_length(1, this->id_ref_.size());
2354
+ size.add_length(1, this->wake_word_ref_.size());
2643
2355
  if (!this->trained_languages.empty()) {
2644
2356
  for (const auto &it : this->trained_languages) {
2645
- ProtoSize::add_string_field_repeated(total_size, 1, it);
2357
+ size.add_length_force(1, it.size());
2646
2358
  }
2647
2359
  }
2648
2360
  }
@@ -2650,195 +2362,224 @@ void VoiceAssistantConfigurationResponse::encode(ProtoWriteBuffer buffer) const
2650
2362
  for (auto &it : this->available_wake_words) {
2651
2363
  buffer.encode_message(1, it, true);
2652
2364
  }
2653
- for (auto &it : this->active_wake_words) {
2365
+ for (const auto &it : *this->active_wake_words) {
2654
2366
  buffer.encode_string(2, it, true);
2655
2367
  }
2656
2368
  buffer.encode_uint32(3, this->max_active_wake_words);
2657
2369
  }
2658
- void VoiceAssistantConfigurationResponse::calculate_size(uint32_t &total_size) const {
2659
- ProtoSize::add_repeated_message(total_size, 1, this->available_wake_words);
2660
- if (!this->active_wake_words.empty()) {
2661
- for (const auto &it : this->active_wake_words) {
2662
- ProtoSize::add_string_field_repeated(total_size, 1, it);
2370
+ void VoiceAssistantConfigurationResponse::calculate_size(ProtoSize &size) const {
2371
+ size.add_repeated_message(1, this->available_wake_words);
2372
+ if (!this->active_wake_words->empty()) {
2373
+ for (const auto &it : *this->active_wake_words) {
2374
+ size.add_length_force(1, it.size());
2663
2375
  }
2664
2376
  }
2665
- ProtoSize::add_uint32_field(total_size, 1, this->max_active_wake_words);
2377
+ size.add_uint32(1, this->max_active_wake_words);
2666
2378
  }
2667
2379
  bool VoiceAssistantSetConfiguration::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2668
2380
  switch (field_id) {
2669
- case 1: {
2381
+ case 1:
2670
2382
  this->active_wake_words.push_back(value.as_string());
2671
- return true;
2672
- }
2383
+ break;
2673
2384
  default:
2674
2385
  return false;
2675
2386
  }
2387
+ return true;
2676
2388
  }
2677
2389
  #endif
2678
2390
  #ifdef USE_ALARM_CONTROL_PANEL
2679
2391
  void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) const {
2680
- buffer.encode_string(1, this->object_id);
2392
+ buffer.encode_string(1, this->object_id_ref_);
2681
2393
  buffer.encode_fixed32(2, this->key);
2682
- buffer.encode_string(3, this->name);
2683
- buffer.encode_string(4, this->unique_id);
2684
- buffer.encode_string(5, this->icon);
2394
+ buffer.encode_string(3, this->name_ref_);
2395
+ #ifdef USE_ENTITY_ICON
2396
+ buffer.encode_string(5, this->icon_ref_);
2397
+ #endif
2685
2398
  buffer.encode_bool(6, this->disabled_by_default);
2686
2399
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
2687
2400
  buffer.encode_uint32(8, this->supported_features);
2688
2401
  buffer.encode_bool(9, this->requires_code);
2689
2402
  buffer.encode_bool(10, this->requires_code_to_arm);
2403
+ #ifdef USE_DEVICES
2690
2404
  buffer.encode_uint32(11, this->device_id);
2405
+ #endif
2691
2406
  }
2692
- void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) const {
2693
- ProtoSize::add_string_field(total_size, 1, this->object_id);
2694
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2695
- ProtoSize::add_string_field(total_size, 1, this->name);
2696
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
2697
- ProtoSize::add_string_field(total_size, 1, this->icon);
2698
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
2699
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
2700
- ProtoSize::add_uint32_field(total_size, 1, this->supported_features);
2701
- ProtoSize::add_bool_field(total_size, 1, this->requires_code);
2702
- ProtoSize::add_bool_field(total_size, 1, this->requires_code_to_arm);
2703
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2407
+ void ListEntitiesAlarmControlPanelResponse::calculate_size(ProtoSize &size) const {
2408
+ size.add_length(1, this->object_id_ref_.size());
2409
+ size.add_fixed32(1, this->key);
2410
+ size.add_length(1, this->name_ref_.size());
2411
+ #ifdef USE_ENTITY_ICON
2412
+ size.add_length(1, this->icon_ref_.size());
2413
+ #endif
2414
+ size.add_bool(1, this->disabled_by_default);
2415
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2416
+ size.add_uint32(1, this->supported_features);
2417
+ size.add_bool(1, this->requires_code);
2418
+ size.add_bool(1, this->requires_code_to_arm);
2419
+ #ifdef USE_DEVICES
2420
+ size.add_uint32(1, this->device_id);
2421
+ #endif
2704
2422
  }
2705
2423
  void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer buffer) const {
2706
2424
  buffer.encode_fixed32(1, this->key);
2707
2425
  buffer.encode_uint32(2, static_cast<uint32_t>(this->state));
2426
+ #ifdef USE_DEVICES
2708
2427
  buffer.encode_uint32(3, this->device_id);
2428
+ #endif
2709
2429
  }
2710
- void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const {
2711
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2712
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
2713
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2430
+ void AlarmControlPanelStateResponse::calculate_size(ProtoSize &size) const {
2431
+ size.add_fixed32(1, this->key);
2432
+ size.add_uint32(1, static_cast<uint32_t>(this->state));
2433
+ #ifdef USE_DEVICES
2434
+ size.add_uint32(1, this->device_id);
2435
+ #endif
2714
2436
  }
2715
2437
  bool AlarmControlPanelCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2716
2438
  switch (field_id) {
2717
- case 2: {
2439
+ case 2:
2718
2440
  this->command = static_cast<enums::AlarmControlPanelStateCommand>(value.as_uint32());
2719
- return true;
2720
- }
2721
- case 4: {
2441
+ break;
2442
+ #ifdef USE_DEVICES
2443
+ case 4:
2722
2444
  this->device_id = value.as_uint32();
2723
- return true;
2724
- }
2445
+ break;
2446
+ #endif
2725
2447
  default:
2726
2448
  return false;
2727
2449
  }
2450
+ return true;
2728
2451
  }
2729
2452
  bool AlarmControlPanelCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2730
2453
  switch (field_id) {
2731
- case 3: {
2454
+ case 3:
2732
2455
  this->code = value.as_string();
2733
- return true;
2734
- }
2456
+ break;
2735
2457
  default:
2736
2458
  return false;
2737
2459
  }
2460
+ return true;
2738
2461
  }
2739
2462
  bool AlarmControlPanelCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
2740
2463
  switch (field_id) {
2741
- case 1: {
2464
+ case 1:
2742
2465
  this->key = value.as_fixed32();
2743
- return true;
2744
- }
2466
+ break;
2745
2467
  default:
2746
2468
  return false;
2747
2469
  }
2470
+ return true;
2748
2471
  }
2749
2472
  #endif
2750
2473
  #ifdef USE_TEXT
2751
2474
  void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const {
2752
- buffer.encode_string(1, this->object_id);
2475
+ buffer.encode_string(1, this->object_id_ref_);
2753
2476
  buffer.encode_fixed32(2, this->key);
2754
- buffer.encode_string(3, this->name);
2755
- buffer.encode_string(4, this->unique_id);
2756
- buffer.encode_string(5, this->icon);
2477
+ buffer.encode_string(3, this->name_ref_);
2478
+ #ifdef USE_ENTITY_ICON
2479
+ buffer.encode_string(5, this->icon_ref_);
2480
+ #endif
2757
2481
  buffer.encode_bool(6, this->disabled_by_default);
2758
2482
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
2759
2483
  buffer.encode_uint32(8, this->min_length);
2760
2484
  buffer.encode_uint32(9, this->max_length);
2761
- buffer.encode_string(10, this->pattern);
2485
+ buffer.encode_string(10, this->pattern_ref_);
2762
2486
  buffer.encode_uint32(11, static_cast<uint32_t>(this->mode));
2487
+ #ifdef USE_DEVICES
2763
2488
  buffer.encode_uint32(12, this->device_id);
2489
+ #endif
2764
2490
  }
2765
- void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const {
2766
- ProtoSize::add_string_field(total_size, 1, this->object_id);
2767
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2768
- ProtoSize::add_string_field(total_size, 1, this->name);
2769
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
2770
- ProtoSize::add_string_field(total_size, 1, this->icon);
2771
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
2772
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
2773
- ProtoSize::add_uint32_field(total_size, 1, this->min_length);
2774
- ProtoSize::add_uint32_field(total_size, 1, this->max_length);
2775
- ProtoSize::add_string_field(total_size, 1, this->pattern);
2776
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
2777
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2491
+ void ListEntitiesTextResponse::calculate_size(ProtoSize &size) const {
2492
+ size.add_length(1, this->object_id_ref_.size());
2493
+ size.add_fixed32(1, this->key);
2494
+ size.add_length(1, this->name_ref_.size());
2495
+ #ifdef USE_ENTITY_ICON
2496
+ size.add_length(1, this->icon_ref_.size());
2497
+ #endif
2498
+ size.add_bool(1, this->disabled_by_default);
2499
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2500
+ size.add_uint32(1, this->min_length);
2501
+ size.add_uint32(1, this->max_length);
2502
+ size.add_length(1, this->pattern_ref_.size());
2503
+ size.add_uint32(1, static_cast<uint32_t>(this->mode));
2504
+ #ifdef USE_DEVICES
2505
+ size.add_uint32(1, this->device_id);
2506
+ #endif
2778
2507
  }
2779
2508
  void TextStateResponse::encode(ProtoWriteBuffer buffer) const {
2780
2509
  buffer.encode_fixed32(1, this->key);
2781
- buffer.encode_string(2, this->state);
2510
+ buffer.encode_string(2, this->state_ref_);
2782
2511
  buffer.encode_bool(3, this->missing_state);
2512
+ #ifdef USE_DEVICES
2783
2513
  buffer.encode_uint32(4, this->device_id);
2514
+ #endif
2784
2515
  }
2785
- void TextStateResponse::calculate_size(uint32_t &total_size) const {
2786
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2787
- ProtoSize::add_string_field(total_size, 1, this->state);
2788
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
2789
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2516
+ void TextStateResponse::calculate_size(ProtoSize &size) const {
2517
+ size.add_fixed32(1, this->key);
2518
+ size.add_length(1, this->state_ref_.size());
2519
+ size.add_bool(1, this->missing_state);
2520
+ #ifdef USE_DEVICES
2521
+ size.add_uint32(1, this->device_id);
2522
+ #endif
2790
2523
  }
2791
2524
  bool TextCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2792
2525
  switch (field_id) {
2793
- case 3: {
2526
+ #ifdef USE_DEVICES
2527
+ case 3:
2794
2528
  this->device_id = value.as_uint32();
2795
- return true;
2796
- }
2529
+ break;
2530
+ #endif
2797
2531
  default:
2798
2532
  return false;
2799
2533
  }
2534
+ return true;
2800
2535
  }
2801
2536
  bool TextCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
2802
2537
  switch (field_id) {
2803
- case 2: {
2538
+ case 2:
2804
2539
  this->state = value.as_string();
2805
- return true;
2806
- }
2540
+ break;
2807
2541
  default:
2808
2542
  return false;
2809
2543
  }
2544
+ return true;
2810
2545
  }
2811
2546
  bool TextCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
2812
2547
  switch (field_id) {
2813
- case 1: {
2548
+ case 1:
2814
2549
  this->key = value.as_fixed32();
2815
- return true;
2816
- }
2550
+ break;
2817
2551
  default:
2818
2552
  return false;
2819
2553
  }
2554
+ return true;
2820
2555
  }
2821
2556
  #endif
2822
2557
  #ifdef USE_DATETIME_DATE
2823
2558
  void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const {
2824
- buffer.encode_string(1, this->object_id);
2559
+ buffer.encode_string(1, this->object_id_ref_);
2825
2560
  buffer.encode_fixed32(2, this->key);
2826
- buffer.encode_string(3, this->name);
2827
- buffer.encode_string(4, this->unique_id);
2828
- buffer.encode_string(5, this->icon);
2561
+ buffer.encode_string(3, this->name_ref_);
2562
+ #ifdef USE_ENTITY_ICON
2563
+ buffer.encode_string(5, this->icon_ref_);
2564
+ #endif
2829
2565
  buffer.encode_bool(6, this->disabled_by_default);
2830
2566
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
2567
+ #ifdef USE_DEVICES
2831
2568
  buffer.encode_uint32(8, this->device_id);
2569
+ #endif
2832
2570
  }
2833
- void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const {
2834
- ProtoSize::add_string_field(total_size, 1, this->object_id);
2835
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2836
- ProtoSize::add_string_field(total_size, 1, this->name);
2837
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
2838
- ProtoSize::add_string_field(total_size, 1, this->icon);
2839
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
2840
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
2841
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2571
+ void ListEntitiesDateResponse::calculate_size(ProtoSize &size) const {
2572
+ size.add_length(1, this->object_id_ref_.size());
2573
+ size.add_fixed32(1, this->key);
2574
+ size.add_length(1, this->name_ref_.size());
2575
+ #ifdef USE_ENTITY_ICON
2576
+ size.add_length(1, this->icon_ref_.size());
2577
+ #endif
2578
+ size.add_bool(1, this->disabled_by_default);
2579
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2580
+ #ifdef USE_DEVICES
2581
+ size.add_uint32(1, this->device_id);
2582
+ #endif
2842
2583
  }
2843
2584
  void DateStateResponse::encode(ProtoWriteBuffer buffer) const {
2844
2585
  buffer.encode_fixed32(1, this->key);
@@ -2846,69 +2587,78 @@ void DateStateResponse::encode(ProtoWriteBuffer buffer) const {
2846
2587
  buffer.encode_uint32(3, this->year);
2847
2588
  buffer.encode_uint32(4, this->month);
2848
2589
  buffer.encode_uint32(5, this->day);
2590
+ #ifdef USE_DEVICES
2849
2591
  buffer.encode_uint32(6, this->device_id);
2592
+ #endif
2850
2593
  }
2851
- void DateStateResponse::calculate_size(uint32_t &total_size) const {
2852
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2853
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
2854
- ProtoSize::add_uint32_field(total_size, 1, this->year);
2855
- ProtoSize::add_uint32_field(total_size, 1, this->month);
2856
- ProtoSize::add_uint32_field(total_size, 1, this->day);
2857
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2594
+ void DateStateResponse::calculate_size(ProtoSize &size) const {
2595
+ size.add_fixed32(1, this->key);
2596
+ size.add_bool(1, this->missing_state);
2597
+ size.add_uint32(1, this->year);
2598
+ size.add_uint32(1, this->month);
2599
+ size.add_uint32(1, this->day);
2600
+ #ifdef USE_DEVICES
2601
+ size.add_uint32(1, this->device_id);
2602
+ #endif
2858
2603
  }
2859
2604
  bool DateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2860
2605
  switch (field_id) {
2861
- case 2: {
2606
+ case 2:
2862
2607
  this->year = value.as_uint32();
2863
- return true;
2864
- }
2865
- case 3: {
2608
+ break;
2609
+ case 3:
2866
2610
  this->month = value.as_uint32();
2867
- return true;
2868
- }
2869
- case 4: {
2611
+ break;
2612
+ case 4:
2870
2613
  this->day = value.as_uint32();
2871
- return true;
2872
- }
2873
- case 5: {
2614
+ break;
2615
+ #ifdef USE_DEVICES
2616
+ case 5:
2874
2617
  this->device_id = value.as_uint32();
2875
- return true;
2876
- }
2618
+ break;
2619
+ #endif
2877
2620
  default:
2878
2621
  return false;
2879
2622
  }
2623
+ return true;
2880
2624
  }
2881
2625
  bool DateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
2882
2626
  switch (field_id) {
2883
- case 1: {
2627
+ case 1:
2884
2628
  this->key = value.as_fixed32();
2885
- return true;
2886
- }
2629
+ break;
2887
2630
  default:
2888
2631
  return false;
2889
2632
  }
2633
+ return true;
2890
2634
  }
2891
2635
  #endif
2892
2636
  #ifdef USE_DATETIME_TIME
2893
2637
  void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const {
2894
- buffer.encode_string(1, this->object_id);
2638
+ buffer.encode_string(1, this->object_id_ref_);
2895
2639
  buffer.encode_fixed32(2, this->key);
2896
- buffer.encode_string(3, this->name);
2897
- buffer.encode_string(4, this->unique_id);
2898
- buffer.encode_string(5, this->icon);
2640
+ buffer.encode_string(3, this->name_ref_);
2641
+ #ifdef USE_ENTITY_ICON
2642
+ buffer.encode_string(5, this->icon_ref_);
2643
+ #endif
2899
2644
  buffer.encode_bool(6, this->disabled_by_default);
2900
2645
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
2646
+ #ifdef USE_DEVICES
2901
2647
  buffer.encode_uint32(8, this->device_id);
2648
+ #endif
2902
2649
  }
2903
- void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const {
2904
- ProtoSize::add_string_field(total_size, 1, this->object_id);
2905
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2906
- ProtoSize::add_string_field(total_size, 1, this->name);
2907
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
2908
- ProtoSize::add_string_field(total_size, 1, this->icon);
2909
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
2910
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
2911
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2650
+ void ListEntitiesTimeResponse::calculate_size(ProtoSize &size) const {
2651
+ size.add_length(1, this->object_id_ref_.size());
2652
+ size.add_fixed32(1, this->key);
2653
+ size.add_length(1, this->name_ref_.size());
2654
+ #ifdef USE_ENTITY_ICON
2655
+ size.add_length(1, this->icon_ref_.size());
2656
+ #endif
2657
+ size.add_bool(1, this->disabled_by_default);
2658
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2659
+ #ifdef USE_DEVICES
2660
+ size.add_uint32(1, this->device_id);
2661
+ #endif
2912
2662
  }
2913
2663
  void TimeStateResponse::encode(ProtoWriteBuffer buffer) const {
2914
2664
  buffer.encode_fixed32(1, this->key);
@@ -2916,245 +2666,284 @@ void TimeStateResponse::encode(ProtoWriteBuffer buffer) const {
2916
2666
  buffer.encode_uint32(3, this->hour);
2917
2667
  buffer.encode_uint32(4, this->minute);
2918
2668
  buffer.encode_uint32(5, this->second);
2669
+ #ifdef USE_DEVICES
2919
2670
  buffer.encode_uint32(6, this->device_id);
2671
+ #endif
2920
2672
  }
2921
- void TimeStateResponse::calculate_size(uint32_t &total_size) const {
2922
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2923
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
2924
- ProtoSize::add_uint32_field(total_size, 1, this->hour);
2925
- ProtoSize::add_uint32_field(total_size, 1, this->minute);
2926
- ProtoSize::add_uint32_field(total_size, 1, this->second);
2927
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2673
+ void TimeStateResponse::calculate_size(ProtoSize &size) const {
2674
+ size.add_fixed32(1, this->key);
2675
+ size.add_bool(1, this->missing_state);
2676
+ size.add_uint32(1, this->hour);
2677
+ size.add_uint32(1, this->minute);
2678
+ size.add_uint32(1, this->second);
2679
+ #ifdef USE_DEVICES
2680
+ size.add_uint32(1, this->device_id);
2681
+ #endif
2928
2682
  }
2929
2683
  bool TimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
2930
2684
  switch (field_id) {
2931
- case 2: {
2685
+ case 2:
2932
2686
  this->hour = value.as_uint32();
2933
- return true;
2934
- }
2935
- case 3: {
2687
+ break;
2688
+ case 3:
2936
2689
  this->minute = value.as_uint32();
2937
- return true;
2938
- }
2939
- case 4: {
2690
+ break;
2691
+ case 4:
2940
2692
  this->second = value.as_uint32();
2941
- return true;
2942
- }
2943
- case 5: {
2693
+ break;
2694
+ #ifdef USE_DEVICES
2695
+ case 5:
2944
2696
  this->device_id = value.as_uint32();
2945
- return true;
2946
- }
2697
+ break;
2698
+ #endif
2947
2699
  default:
2948
2700
  return false;
2949
2701
  }
2702
+ return true;
2950
2703
  }
2951
2704
  bool TimeCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
2952
2705
  switch (field_id) {
2953
- case 1: {
2706
+ case 1:
2954
2707
  this->key = value.as_fixed32();
2955
- return true;
2956
- }
2708
+ break;
2957
2709
  default:
2958
2710
  return false;
2959
2711
  }
2712
+ return true;
2960
2713
  }
2961
2714
  #endif
2962
2715
  #ifdef USE_EVENT
2963
2716
  void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const {
2964
- buffer.encode_string(1, this->object_id);
2717
+ buffer.encode_string(1, this->object_id_ref_);
2965
2718
  buffer.encode_fixed32(2, this->key);
2966
- buffer.encode_string(3, this->name);
2967
- buffer.encode_string(4, this->unique_id);
2968
- buffer.encode_string(5, this->icon);
2719
+ buffer.encode_string(3, this->name_ref_);
2720
+ #ifdef USE_ENTITY_ICON
2721
+ buffer.encode_string(5, this->icon_ref_);
2722
+ #endif
2969
2723
  buffer.encode_bool(6, this->disabled_by_default);
2970
2724
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
2971
- buffer.encode_string(8, this->device_class);
2725
+ buffer.encode_string(8, this->device_class_ref_);
2972
2726
  for (auto &it : this->event_types) {
2973
2727
  buffer.encode_string(9, it, true);
2974
2728
  }
2729
+ #ifdef USE_DEVICES
2975
2730
  buffer.encode_uint32(10, this->device_id);
2731
+ #endif
2976
2732
  }
2977
- void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const {
2978
- ProtoSize::add_string_field(total_size, 1, this->object_id);
2979
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
2980
- ProtoSize::add_string_field(total_size, 1, this->name);
2981
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
2982
- ProtoSize::add_string_field(total_size, 1, this->icon);
2983
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
2984
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
2985
- ProtoSize::add_string_field(total_size, 1, this->device_class);
2733
+ void ListEntitiesEventResponse::calculate_size(ProtoSize &size) const {
2734
+ size.add_length(1, this->object_id_ref_.size());
2735
+ size.add_fixed32(1, this->key);
2736
+ size.add_length(1, this->name_ref_.size());
2737
+ #ifdef USE_ENTITY_ICON
2738
+ size.add_length(1, this->icon_ref_.size());
2739
+ #endif
2740
+ size.add_bool(1, this->disabled_by_default);
2741
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2742
+ size.add_length(1, this->device_class_ref_.size());
2986
2743
  if (!this->event_types.empty()) {
2987
2744
  for (const auto &it : this->event_types) {
2988
- ProtoSize::add_string_field_repeated(total_size, 1, it);
2745
+ size.add_length_force(1, it.size());
2989
2746
  }
2990
2747
  }
2991
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2748
+ #ifdef USE_DEVICES
2749
+ size.add_uint32(1, this->device_id);
2750
+ #endif
2992
2751
  }
2993
2752
  void EventResponse::encode(ProtoWriteBuffer buffer) const {
2994
2753
  buffer.encode_fixed32(1, this->key);
2995
- buffer.encode_string(2, this->event_type);
2754
+ buffer.encode_string(2, this->event_type_ref_);
2755
+ #ifdef USE_DEVICES
2996
2756
  buffer.encode_uint32(3, this->device_id);
2757
+ #endif
2997
2758
  }
2998
- void EventResponse::calculate_size(uint32_t &total_size) const {
2999
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
3000
- ProtoSize::add_string_field(total_size, 1, this->event_type);
3001
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2759
+ void EventResponse::calculate_size(ProtoSize &size) const {
2760
+ size.add_fixed32(1, this->key);
2761
+ size.add_length(1, this->event_type_ref_.size());
2762
+ #ifdef USE_DEVICES
2763
+ size.add_uint32(1, this->device_id);
2764
+ #endif
3002
2765
  }
3003
2766
  #endif
3004
2767
  #ifdef USE_VALVE
3005
2768
  void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const {
3006
- buffer.encode_string(1, this->object_id);
2769
+ buffer.encode_string(1, this->object_id_ref_);
3007
2770
  buffer.encode_fixed32(2, this->key);
3008
- buffer.encode_string(3, this->name);
3009
- buffer.encode_string(4, this->unique_id);
3010
- buffer.encode_string(5, this->icon);
2771
+ buffer.encode_string(3, this->name_ref_);
2772
+ #ifdef USE_ENTITY_ICON
2773
+ buffer.encode_string(5, this->icon_ref_);
2774
+ #endif
3011
2775
  buffer.encode_bool(6, this->disabled_by_default);
3012
2776
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
3013
- buffer.encode_string(8, this->device_class);
2777
+ buffer.encode_string(8, this->device_class_ref_);
3014
2778
  buffer.encode_bool(9, this->assumed_state);
3015
2779
  buffer.encode_bool(10, this->supports_position);
3016
2780
  buffer.encode_bool(11, this->supports_stop);
2781
+ #ifdef USE_DEVICES
3017
2782
  buffer.encode_uint32(12, this->device_id);
2783
+ #endif
3018
2784
  }
3019
- void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const {
3020
- ProtoSize::add_string_field(total_size, 1, this->object_id);
3021
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
3022
- ProtoSize::add_string_field(total_size, 1, this->name);
3023
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
3024
- ProtoSize::add_string_field(total_size, 1, this->icon);
3025
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
3026
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
3027
- ProtoSize::add_string_field(total_size, 1, this->device_class);
3028
- ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
3029
- ProtoSize::add_bool_field(total_size, 1, this->supports_position);
3030
- ProtoSize::add_bool_field(total_size, 1, this->supports_stop);
3031
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2785
+ void ListEntitiesValveResponse::calculate_size(ProtoSize &size) const {
2786
+ size.add_length(1, this->object_id_ref_.size());
2787
+ size.add_fixed32(1, this->key);
2788
+ size.add_length(1, this->name_ref_.size());
2789
+ #ifdef USE_ENTITY_ICON
2790
+ size.add_length(1, this->icon_ref_.size());
2791
+ #endif
2792
+ size.add_bool(1, this->disabled_by_default);
2793
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2794
+ size.add_length(1, this->device_class_ref_.size());
2795
+ size.add_bool(1, this->assumed_state);
2796
+ size.add_bool(1, this->supports_position);
2797
+ size.add_bool(1, this->supports_stop);
2798
+ #ifdef USE_DEVICES
2799
+ size.add_uint32(1, this->device_id);
2800
+ #endif
3032
2801
  }
3033
2802
  void ValveStateResponse::encode(ProtoWriteBuffer buffer) const {
3034
2803
  buffer.encode_fixed32(1, this->key);
3035
2804
  buffer.encode_float(2, this->position);
3036
2805
  buffer.encode_uint32(3, static_cast<uint32_t>(this->current_operation));
2806
+ #ifdef USE_DEVICES
3037
2807
  buffer.encode_uint32(4, this->device_id);
2808
+ #endif
3038
2809
  }
3039
- void ValveStateResponse::calculate_size(uint32_t &total_size) const {
3040
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
3041
- ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f);
3042
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
3043
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2810
+ void ValveStateResponse::calculate_size(ProtoSize &size) const {
2811
+ size.add_fixed32(1, this->key);
2812
+ size.add_float(1, this->position);
2813
+ size.add_uint32(1, static_cast<uint32_t>(this->current_operation));
2814
+ #ifdef USE_DEVICES
2815
+ size.add_uint32(1, this->device_id);
2816
+ #endif
3044
2817
  }
3045
2818
  bool ValveCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
3046
2819
  switch (field_id) {
3047
- case 2: {
2820
+ case 2:
3048
2821
  this->has_position = value.as_bool();
3049
- return true;
3050
- }
3051
- case 4: {
2822
+ break;
2823
+ case 4:
3052
2824
  this->stop = value.as_bool();
3053
- return true;
3054
- }
3055
- case 5: {
2825
+ break;
2826
+ #ifdef USE_DEVICES
2827
+ case 5:
3056
2828
  this->device_id = value.as_uint32();
3057
- return true;
3058
- }
2829
+ break;
2830
+ #endif
3059
2831
  default:
3060
2832
  return false;
3061
2833
  }
2834
+ return true;
3062
2835
  }
3063
2836
  bool ValveCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
3064
2837
  switch (field_id) {
3065
- case 1: {
2838
+ case 1:
3066
2839
  this->key = value.as_fixed32();
3067
- return true;
3068
- }
3069
- case 3: {
2840
+ break;
2841
+ case 3:
3070
2842
  this->position = value.as_float();
3071
- return true;
3072
- }
2843
+ break;
3073
2844
  default:
3074
2845
  return false;
3075
2846
  }
2847
+ return true;
3076
2848
  }
3077
2849
  #endif
3078
2850
  #ifdef USE_DATETIME_DATETIME
3079
2851
  void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const {
3080
- buffer.encode_string(1, this->object_id);
2852
+ buffer.encode_string(1, this->object_id_ref_);
3081
2853
  buffer.encode_fixed32(2, this->key);
3082
- buffer.encode_string(3, this->name);
3083
- buffer.encode_string(4, this->unique_id);
3084
- buffer.encode_string(5, this->icon);
2854
+ buffer.encode_string(3, this->name_ref_);
2855
+ #ifdef USE_ENTITY_ICON
2856
+ buffer.encode_string(5, this->icon_ref_);
2857
+ #endif
3085
2858
  buffer.encode_bool(6, this->disabled_by_default);
3086
2859
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
2860
+ #ifdef USE_DEVICES
3087
2861
  buffer.encode_uint32(8, this->device_id);
2862
+ #endif
3088
2863
  }
3089
- void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const {
3090
- ProtoSize::add_string_field(total_size, 1, this->object_id);
3091
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
3092
- ProtoSize::add_string_field(total_size, 1, this->name);
3093
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
3094
- ProtoSize::add_string_field(total_size, 1, this->icon);
3095
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
3096
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
3097
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2864
+ void ListEntitiesDateTimeResponse::calculate_size(ProtoSize &size) const {
2865
+ size.add_length(1, this->object_id_ref_.size());
2866
+ size.add_fixed32(1, this->key);
2867
+ size.add_length(1, this->name_ref_.size());
2868
+ #ifdef USE_ENTITY_ICON
2869
+ size.add_length(1, this->icon_ref_.size());
2870
+ #endif
2871
+ size.add_bool(1, this->disabled_by_default);
2872
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2873
+ #ifdef USE_DEVICES
2874
+ size.add_uint32(1, this->device_id);
2875
+ #endif
3098
2876
  }
3099
2877
  void DateTimeStateResponse::encode(ProtoWriteBuffer buffer) const {
3100
2878
  buffer.encode_fixed32(1, this->key);
3101
2879
  buffer.encode_bool(2, this->missing_state);
3102
2880
  buffer.encode_fixed32(3, this->epoch_seconds);
2881
+ #ifdef USE_DEVICES
3103
2882
  buffer.encode_uint32(4, this->device_id);
2883
+ #endif
3104
2884
  }
3105
- void DateTimeStateResponse::calculate_size(uint32_t &total_size) const {
3106
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
3107
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
3108
- ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0);
3109
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2885
+ void DateTimeStateResponse::calculate_size(ProtoSize &size) const {
2886
+ size.add_fixed32(1, this->key);
2887
+ size.add_bool(1, this->missing_state);
2888
+ size.add_fixed32(1, this->epoch_seconds);
2889
+ #ifdef USE_DEVICES
2890
+ size.add_uint32(1, this->device_id);
2891
+ #endif
3110
2892
  }
3111
2893
  bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
3112
2894
  switch (field_id) {
3113
- case 3: {
2895
+ #ifdef USE_DEVICES
2896
+ case 3:
3114
2897
  this->device_id = value.as_uint32();
3115
- return true;
3116
- }
2898
+ break;
2899
+ #endif
3117
2900
  default:
3118
2901
  return false;
3119
2902
  }
2903
+ return true;
3120
2904
  }
3121
2905
  bool DateTimeCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
3122
2906
  switch (field_id) {
3123
- case 1: {
2907
+ case 1:
3124
2908
  this->key = value.as_fixed32();
3125
- return true;
3126
- }
3127
- case 2: {
2909
+ break;
2910
+ case 2:
3128
2911
  this->epoch_seconds = value.as_fixed32();
3129
- return true;
3130
- }
2912
+ break;
3131
2913
  default:
3132
2914
  return false;
3133
2915
  }
2916
+ return true;
3134
2917
  }
3135
2918
  #endif
3136
2919
  #ifdef USE_UPDATE
3137
2920
  void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const {
3138
- buffer.encode_string(1, this->object_id);
2921
+ buffer.encode_string(1, this->object_id_ref_);
3139
2922
  buffer.encode_fixed32(2, this->key);
3140
- buffer.encode_string(3, this->name);
3141
- buffer.encode_string(4, this->unique_id);
3142
- buffer.encode_string(5, this->icon);
2923
+ buffer.encode_string(3, this->name_ref_);
2924
+ #ifdef USE_ENTITY_ICON
2925
+ buffer.encode_string(5, this->icon_ref_);
2926
+ #endif
3143
2927
  buffer.encode_bool(6, this->disabled_by_default);
3144
2928
  buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
3145
- buffer.encode_string(8, this->device_class);
2929
+ buffer.encode_string(8, this->device_class_ref_);
2930
+ #ifdef USE_DEVICES
3146
2931
  buffer.encode_uint32(9, this->device_id);
2932
+ #endif
3147
2933
  }
3148
- void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const {
3149
- ProtoSize::add_string_field(total_size, 1, this->object_id);
3150
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
3151
- ProtoSize::add_string_field(total_size, 1, this->name);
3152
- ProtoSize::add_string_field(total_size, 1, this->unique_id);
3153
- ProtoSize::add_string_field(total_size, 1, this->icon);
3154
- ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
3155
- ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
3156
- ProtoSize::add_string_field(total_size, 1, this->device_class);
3157
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2934
+ void ListEntitiesUpdateResponse::calculate_size(ProtoSize &size) const {
2935
+ size.add_length(1, this->object_id_ref_.size());
2936
+ size.add_fixed32(1, this->key);
2937
+ size.add_length(1, this->name_ref_.size());
2938
+ #ifdef USE_ENTITY_ICON
2939
+ size.add_length(1, this->icon_ref_.size());
2940
+ #endif
2941
+ size.add_bool(1, this->disabled_by_default);
2942
+ size.add_uint32(1, static_cast<uint32_t>(this->entity_category));
2943
+ size.add_length(1, this->device_class_ref_.size());
2944
+ #ifdef USE_DEVICES
2945
+ size.add_uint32(1, this->device_id);
2946
+ #endif
3158
2947
  }
3159
2948
  void UpdateStateResponse::encode(ProtoWriteBuffer buffer) const {
3160
2949
  buffer.encode_fixed32(1, this->key);
@@ -3162,51 +2951,55 @@ void UpdateStateResponse::encode(ProtoWriteBuffer buffer) const {
3162
2951
  buffer.encode_bool(3, this->in_progress);
3163
2952
  buffer.encode_bool(4, this->has_progress);
3164
2953
  buffer.encode_float(5, this->progress);
3165
- buffer.encode_string(6, this->current_version);
3166
- buffer.encode_string(7, this->latest_version);
3167
- buffer.encode_string(8, this->title);
3168
- buffer.encode_string(9, this->release_summary);
3169
- buffer.encode_string(10, this->release_url);
2954
+ buffer.encode_string(6, this->current_version_ref_);
2955
+ buffer.encode_string(7, this->latest_version_ref_);
2956
+ buffer.encode_string(8, this->title_ref_);
2957
+ buffer.encode_string(9, this->release_summary_ref_);
2958
+ buffer.encode_string(10, this->release_url_ref_);
2959
+ #ifdef USE_DEVICES
3170
2960
  buffer.encode_uint32(11, this->device_id);
2961
+ #endif
3171
2962
  }
3172
- void UpdateStateResponse::calculate_size(uint32_t &total_size) const {
3173
- ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
3174
- ProtoSize::add_bool_field(total_size, 1, this->missing_state);
3175
- ProtoSize::add_bool_field(total_size, 1, this->in_progress);
3176
- ProtoSize::add_bool_field(total_size, 1, this->has_progress);
3177
- ProtoSize::add_fixed_field<4>(total_size, 1, this->progress != 0.0f);
3178
- ProtoSize::add_string_field(total_size, 1, this->current_version);
3179
- ProtoSize::add_string_field(total_size, 1, this->latest_version);
3180
- ProtoSize::add_string_field(total_size, 1, this->title);
3181
- ProtoSize::add_string_field(total_size, 1, this->release_summary);
3182
- ProtoSize::add_string_field(total_size, 1, this->release_url);
3183
- ProtoSize::add_uint32_field(total_size, 1, this->device_id);
2963
+ void UpdateStateResponse::calculate_size(ProtoSize &size) const {
2964
+ size.add_fixed32(1, this->key);
2965
+ size.add_bool(1, this->missing_state);
2966
+ size.add_bool(1, this->in_progress);
2967
+ size.add_bool(1, this->has_progress);
2968
+ size.add_float(1, this->progress);
2969
+ size.add_length(1, this->current_version_ref_.size());
2970
+ size.add_length(1, this->latest_version_ref_.size());
2971
+ size.add_length(1, this->title_ref_.size());
2972
+ size.add_length(1, this->release_summary_ref_.size());
2973
+ size.add_length(1, this->release_url_ref_.size());
2974
+ #ifdef USE_DEVICES
2975
+ size.add_uint32(1, this->device_id);
2976
+ #endif
3184
2977
  }
3185
2978
  bool UpdateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
3186
2979
  switch (field_id) {
3187
- case 2: {
2980
+ case 2:
3188
2981
  this->command = static_cast<enums::UpdateCommand>(value.as_uint32());
3189
- return true;
3190
- }
3191
- case 3: {
2982
+ break;
2983
+ #ifdef USE_DEVICES
2984
+ case 3:
3192
2985
  this->device_id = value.as_uint32();
3193
- return true;
3194
- }
2986
+ break;
2987
+ #endif
3195
2988
  default:
3196
2989
  return false;
3197
2990
  }
2991
+ return true;
3198
2992
  }
3199
2993
  bool UpdateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
3200
2994
  switch (field_id) {
3201
- case 1: {
2995
+ case 1:
3202
2996
  this->key = value.as_fixed32();
3203
- return true;
3204
- }
2997
+ break;
3205
2998
  default:
3206
2999
  return false;
3207
3000
  }
3001
+ return true;
3208
3002
  }
3209
3003
  #endif
3210
3004
 
3211
- } // namespace api
3212
- } // namespace esphome
3005
+ } // namespace esphome::api