Sends the states of local sensors and binary sensors over a packet interface, and publishes the states received from other devices to remote entities.
More...
|
| | EntityTransport (packet_interface::PacketInterface *interface, uint8_t *buffer, size_t buffer_size) |
| |
| void | setup () override |
| |
| void | loop () override |
| |
| void | dump_config () override |
| |
| void | set_update_interval (uint32_t interval_ms) |
| | 0 chooses the default for the interface's layers; SCHEDULER_DONT_RUN never resends.
|
| |
| void | set_remote_timeout (uint32_t timeout_ms) |
| | Remote entities lose their state when none arrives for this long; 0 keeps the last state.
|
| |
| void | set_entity_count (size_t count) |
| |
| void | add_sensor (const char *id, sensor::Sensor *sensor) |
| |
| void | add_binary_sensor (const char *id, binary_sensor::BinarySensor *sensor) |
| |
| void | add_remote_sensor (const char *provider, const char *remote_id, sensor::Sensor *sensor) |
| |
| void | add_remote_binary_sensor (const char *provider, const char *remote_id, binary_sensor::BinarySensor *sensor) |
| |
| virtual float | get_setup_priority () const |
| | priority of setup().
|
| |
| float | get_actual_setup_priority () const |
| |
| void | set_setup_priority (float priority) |
| |
| void | call () |
| |
| virtual void | on_shutdown () |
| |
| virtual void | on_safe_shutdown () |
| |
| virtual bool | teardown () |
| | Called during teardown to allow component to gracefully finish operations.
|
| |
| virtual void | on_powerdown () |
| | Called last before a reboot or deep sleep to power down hardware.
|
| |
| uint8_t | get_component_state () const |
| |
| void | reset_to_construction_state () |
| | Reset this component back to the construction state to allow setup to run again.
|
| |
| bool | is_in_loop_state () const |
| | Check if this component has completed setup and is in the loop state.
|
| |
| bool | is_idle () const |
| | Check if this component is idle.
|
| |
| void | mark_failed () |
| | Mark this component as failed.
|
| |
| void | mark_failed (const LogString *message) |
| |
| bool ESPHOME_ALWAYS_INLINE | setup_check (bool ok) |
| | Marks the component failed with message (default "Communication failed") unless ok; returns ok.
|
| |
| bool ESPHOME_ALWAYS_INLINE | setup_check (bool ok, const LogString *message) |
| |
| void | disable_loop () |
| | Disable this component's loop.
|
| |
| void | enable_loop () |
| | Enable this component's loop.
|
| |
| void | enable_loop_soon_any_context () |
| | Thread and ISR-safe version of enable_loop() that can be called from any context.
|
| |
| bool | is_failed () const |
| |
| bool | is_ready () const |
| |
| virtual bool | can_proceed () |
| |
| bool | status_has_warning () const |
| |
| bool | status_has_error () const |
| |
| void | status_set_warning () |
| |
| void | status_set_warning (const char *message) |
| |
| void | status_set_warning (const LogString *message) |
| |
| bool | status_comm_result (bool ok) |
| | Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
|
| |
| bool | status_comm_result (bool ok, const LogString *message) |
| |
| bool | status_comm_check (bool ok) |
| | Sets the warning ("Communication failed") when not ok but never clears it; returns ok.
|
| |
| void | status_set_error () |
| |
| void | status_set_error (const LogString *message) |
| |
| void | status_clear_warning () |
| |
| void | status_clear_error () |
| |
| | ESPDEPRECATED ("Use status_momentary_warning() without a name. Removed in 2027.5.0", "2026.11.0") void status_momentary_warning(const char *name |
| |
| void | status_momentary_warning (uint32_t length=5000) |
| | Set warning status flag and clear it after length ms.
|
| |
| void | status_momentary_warning (const LogString *message, uint32_t length=5000) |
| |
| | ESPDEPRECATED ("Use status_momentary_error() without a name. Removed in 2027.5.0", "2026.11.0") void status_momentary_error(const char *name |
| |
| void | status_momentary_error (uint32_t length=5000) |
| | Set error status flag and clear it after length ms.
|
| |
| void | status_momentary_error (const LogString *message, uint32_t length=5000) |
| |
| bool | has_overridden_loop () const |
| |
| const LogString * | get_component_log_str () const ESPHOME_ALWAYS_INLINE |
| | Get the integration where this component was declared as a LogString for logging.
|
| |
| bool | should_warn_of_blocking (uint32_t blocking_time, uint32_t &threshold_ms_out) |
| |
|
| void | send_all_ () |
| |
| void | mark_updated_ (LocalEntity &entity) |
| |
| bool | send_dictionary_ () |
| |
| bool | send_updated_ () |
| |
| size_t | write_record_ (const LocalEntity &entity, uint8_t *record) const |
| |
| bool | flush_ (size_t length, size_t first, size_t last) |
| |
| size_t | write_header_ (uint8_t type) const |
| |
| void | receive_ (const packet_interface::PacketBuffer &data) |
| |
| void | receive_dictionary_ (std::span< const uint8_t > packet, uint32_t dictionary_id) |
| |
| void | receive_data_ (std::span< const uint8_t > packet, uint32_t dictionary_id) |
| |
| void | learn_ (const char *provider, size_t provider_length, uint8_t type, uint8_t number, const char *id, size_t id_length, uint32_t dictionary_id) |
| |
| void | request_dictionary_ (uint32_t dictionary_id) |
| |
| bool | dictionary_seen_ (uint32_t dictionary_id) const |
| |
| void | forget_unnamed_ (const char *provider, size_t provider_length, uint32_t dictionary_id, bool first_time) |
| | Clears each remote entity of provider that its complete dictionary does not name, warning if the entity was known or the dictionary is first_time seen, so a resent dictionary does not repeat the warning.
|
| |
| bool | warning_due_ (DropReason reason) |
| |
| void | sending_refused_ () |
| |
| void | on_session_ (bool connected) |
| |
| void | clear_remote_states_ (bool timed_out_only) |
| |
| friend | void::setup () |
| |
| friend | void::original_setup () |
| |
| void | set_component_source_ (uint8_t index) |
| | Set where this component was loaded from for some debug messages.
|
| |
| virtual void | call_setup () |
| |
| void | call_dump_config_ () |
| |
| void | enable_loop_slow_path_ () |
| |
| void | set_component_state_ (uint8_t state) |
| | Helper to set component state (clears state bits and sets new state)
|
| |
| bool | set_status_flag_ (uint8_t flag) |
| | Helper to set a status LED flag on both this component and the app.
|
| |
| bool | set_error_flag_ (const LogString *message) |
| | Set the error flag and log it; true when it was not set before.
|
| |
| void | set_interval (const char *name, uint32_t interval, std::function< void()> &&f) |
| | Set an interval function with a const char* name.
|
| |
| void | set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f) |
| | Set an interval function with a numeric ID (zero heap allocation).
|
| |
| void | set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f) |
| |
| void | set_interval (uint32_t interval, std::function< void()> &&f) |
| |
| bool | cancel_interval (const char *name) |
| | Cancel an interval function.
|
| |
| bool | cancel_interval (uint32_t id) |
| |
| bool | cancel_interval (InternalSchedulerID id) |
| |
| void | set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f) |
| | Set a timeout function with a const char* name.
|
| |
| void | set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f) |
| | Set a timeout function with a numeric ID (zero heap allocation).
|
| |
| void | set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f) |
| |
| void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
| |
| bool | cancel_timeout (const char *name) |
| | Cancel a timeout function.
|
| |
| bool | cancel_timeout (uint32_t id) |
| |
| bool | cancel_timeout (InternalSchedulerID id) |
| |
| void | defer (const char *name, std::function< void()> &&f) |
| | Defer a callback to the next loop() call with a const char* name.
|
| |
| void | defer (std::function< void()> &&f) |
| | Defer a callback to the next loop() call.
|
| |
| void | defer (uint32_t id, std::function< void()> &&f) |
| | Defer a callback with a numeric ID (zero heap allocation)
|
| |
| bool | cancel_defer (const char *name) |
| | Cancel a defer callback using the specified name, name must not be empty.
|
| |
| bool | cancel_defer (uint32_t id) |
| |
| void | status_clear_warning_slow_path_ () |
| |
| void | status_comm_check_slow_path_ () |
| |
| void | status_clear_error_slow_path_ () |
| |
Sends the states of local sensors and binary sensors over a packet interface, and publishes the states received from other devices to remote entities.
Each device numbers its sensors and its binary sensors from 0, and sends a dictionary that gives the id for each number. Data packets then refer to an entity by its number. Every packet carries the sender's dictionary id, a hash of its device name and dictionary, so that a receiver knows which device sent it and which dictionary applies. All values are little endian.
Dictionary packet:
- type: 1 byte, PACKET_DICTIONARY;
- dictionary id: 4 bytes;
- part: 1 byte, the packet's index in the dictionary in bits 0-6, counting from 0 and wrapping, and bit 7 set on the last packet;
- sender's device name: length (1 byte), then the name;
- one or more sections, each: entity type (1 byte), first number (1 byte), count (1 byte), then for each entity its id: length (1 byte), then the id.
Data packet:
- type: 1 byte, PACKET_DATA;
- dictionary id: 4 bytes;
- records, to the end, each a 16-bit tag, then its payload. The tag holds the entity's number in bits 0-7, its type in bits 8-12, and the payload form in bits 13-14: none, with the state in bit 15 (binary sensors); 4 bytes (a sensor's float); a length byte, then that many bytes; or no state, with no payload. The form gives the record's size, so a receiver skips records of types it does not know.
Every packet is checked in full before anything in it is used, so a damaged or forged packet changes no state.
Dictionary request packet, sent by a device that receives data with a dictionary id it has not received in full, with every part in order:
- type: 1 byte, PACKET_REQUEST;
- the dictionary id wanted: 4 bytes.
Changed states are sent from loop(). The dictionary and all states are sent at boot, when a session layer reports the peer connected, when the dictionary is requested, and every update interval. Unless the interface has both a session and a reliability layer, the update interval defaults to DEFAULT_UPDATE_INTERVAL_MS. When the interface refuses a packet, sending is tried again after a delay, and a warning is set once it has refused every packet for a minute. With a remote timeout, a remote entity loses its state when none arrives for it within the timeout.
Definition at line 60 of file entity_transport.h.