ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
6
7namespace esphome {
8
10enum class DeviceRelation : uint8_t {
15};
16
17class Device {
18 public:
19 void set_device_id(uint32_t device_id) { this->device_id_ = device_id; }
20 uint32_t get_device_id() { return this->device_id_; }
21 void set_name(const char *name) { this->name_ = name; }
22 const char *get_name() { return this->name_; }
23 void set_area_id(uint32_t area_id) { this->area_id_ = area_id; }
24 uint32_t get_area_id() { return this->area_id_; }
25#if defined(USE_DEVICE_RELATION)
26 // Only emitted when devices have different relations; otherwise the getter is a constant and costs no RAM.
27 void set_relation(DeviceRelation relation) { this->relation_ = relation; }
28 DeviceRelation get_relation() const { return this->relation_; }
29#elif defined(USE_DEVICE_RELATION_ALL_CHILD)
31#else
33#endif
34
35 protected:
38 const char *name_ = "";
39#ifdef USE_DEVICE_RELATION
41#endif
42};
43
44} // namespace esphome
uint32_t get_device_id()
Definition device.h:20
uint32_t area_id_
Definition device.h:37
uint32_t device_id_
Definition device.h:36
uint32_t get_area_id()
Definition device.h:24
const char * name_
Definition device.h:38
void set_relation(DeviceRelation relation)
Definition device.h:27
DeviceRelation get_relation() const
Definition device.h:28
const char * get_name()
Definition device.h:22
void set_device_id(uint32_t device_id)
Definition device.h:19
void set_name(const char *name)
Definition device.h:21
void set_area_id(uint32_t area_id)
Definition device.h:23
DeviceRelation relation_
Definition device.h:40
DeviceRelation
How a sub-device relates to the node that exposes it. Values match the API's DeviceRelation enum.
Definition device.h:10
@ DEVICE_RELATION_VIA
A separate physical device reached through this node (for example over RF, UART or ESP-NOW).
@ DEVICE_RELATION_CHILD
A logical part of this node (for example one zone of a multi-zone controller).
static void uint32_t