mirror of
https://github.com/esphome/esphome.git
synced 2025-08-06 18:37:47 +00:00
Merge branch 'icon_opt_pay_as_you_go' into integration
This commit is contained in:
commit
0eecc29039
@ -33,6 +33,7 @@
|
|||||||
#define USE_DEEP_SLEEP
|
#define USE_DEEP_SLEEP
|
||||||
#define USE_DEVICES
|
#define USE_DEVICES
|
||||||
#define USE_DISPLAY
|
#define USE_DISPLAY
|
||||||
|
#define USE_ENTITY_ICON
|
||||||
#define USE_ESP32_IMPROV_STATE_CALLBACK
|
#define USE_ESP32_IMPROV_STATE_CALLBACK
|
||||||
#define USE_EVENT
|
#define USE_EVENT
|
||||||
#define USE_FAN
|
#define USE_FAN
|
||||||
|
@ -27,12 +27,22 @@ void EntityBase::set_name(const char *name) {
|
|||||||
|
|
||||||
// Entity Icon
|
// Entity Icon
|
||||||
std::string EntityBase::get_icon() const {
|
std::string EntityBase::get_icon() const {
|
||||||
|
#ifdef USE_ENTITY_ICON
|
||||||
if (this->icon_c_str_ == nullptr) {
|
if (this->icon_c_str_ == nullptr) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return this->icon_c_str_;
|
return this->icon_c_str_;
|
||||||
|
#else
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void EntityBase::set_icon(const char *icon) {
|
||||||
|
#ifdef USE_ENTITY_ICON
|
||||||
|
this->icon_c_str_ = icon;
|
||||||
|
#else
|
||||||
|
// No-op when USE_ENTITY_ICON is not defined
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void EntityBase::set_icon(const char *icon) { this->icon_c_str_ = icon; }
|
|
||||||
|
|
||||||
// Entity Object ID
|
// Entity Object ID
|
||||||
std::string EntityBase::get_object_id() const {
|
std::string EntityBase::get_object_id() const {
|
||||||
|
@ -80,7 +80,9 @@ class EntityBase {
|
|||||||
|
|
||||||
StringRef name_;
|
StringRef name_;
|
||||||
const char *object_id_c_str_{nullptr};
|
const char *object_id_c_str_{nullptr};
|
||||||
|
#ifdef USE_ENTITY_ICON
|
||||||
const char *icon_c_str_{nullptr};
|
const char *icon_c_str_{nullptr};
|
||||||
|
#endif
|
||||||
uint32_t object_id_hash_{};
|
uint32_t object_id_hash_{};
|
||||||
#ifdef USE_DEVICES
|
#ifdef USE_DEVICES
|
||||||
Device *device_{};
|
Device *device_{};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_DEVICE_ID,
|
CONF_DEVICE_ID,
|
||||||
@ -108,6 +109,8 @@ async def setup_entity(var: MockObj, config: ConfigType, platform: str) -> None:
|
|||||||
if CONF_INTERNAL in config:
|
if CONF_INTERNAL in config:
|
||||||
add(var.set_internal(config[CONF_INTERNAL]))
|
add(var.set_internal(config[CONF_INTERNAL]))
|
||||||
if CONF_ICON in config:
|
if CONF_ICON in config:
|
||||||
|
# Add USE_ENTITY_ICON define when icons are used
|
||||||
|
cg.add_define("USE_ENTITY_ICON")
|
||||||
add(var.set_icon(config[CONF_ICON]))
|
add(var.set_icon(config[CONF_ICON]))
|
||||||
if CONF_ENTITY_CATEGORY in config:
|
if CONF_ENTITY_CATEGORY in config:
|
||||||
add(var.set_entity_category(config[CONF_ENTITY_CATEGORY]))
|
add(var.set_entity_category(config[CONF_ENTITY_CATEGORY]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user