11#ifdef USE_API_HOMEASSISTANT_SERVICES
23 return ESPHOME_strncmp_P(
entity_id, input_service,
sizeof(
"input_") - 1) == 0;
26#ifdef USE_API_HOMEASSISTANT_SERVICES
32 static constexpr char ENTITY_ID_KEY[]
PROGMEM =
"entity_id";
33 auto &entry = resp.
data.emplace_back();
41 if (code_point == 0 || code_point > 0x10FFFF)
43 if (code_point < 0x80) {
44 on_char(
static_cast<char>(code_point));
45 }
else if (code_point < 0x800) {
46 on_char(
static_cast<char>(0xC0 | (code_point >> 6)));
47 on_char(
static_cast<char>(0x80 | (code_point & 0x3F)));
48 }
else if (code_point < 0x10000) {
49 on_char(
static_cast<char>(0xE0 | (code_point >> 12)));
50 on_char(
static_cast<char>(0x80 | ((code_point >> 6) & 0x3F)));
51 on_char(
static_cast<char>(0x80 | (code_point & 0x3F)));
53 on_char(
static_cast<char>(0xF0 | (code_point >> 18)));
54 on_char(
static_cast<char>(0x80 | ((code_point >> 12) & 0x3F)));
55 on_char(
static_cast<char>(0x80 | ((code_point >> 6) & 0x3F)));
56 on_char(
static_cast<char>(0x80 | (code_point & 0x3F)));
69 const char *
pos =
src.c_str();
71 auto skip_spaces = [&]() {
87 const bool enum_member =
pos <
end && *
pos ==
'<';
90 while (
pos <
end && (std::isalnum(
static_cast<unsigned char>(*
pos)) || *
pos ==
'_' || *
pos ==
'.'))
99 const char quote = *
pos++;
103 const char c = *
pos++;
112 const char escape = *
pos++;
131 const size_t digits = escape ==
'x' ? 2 : (escape ==
'u' ? 4 : 8);
132 if (
static_cast<size_t>(
end -
pos) < digits)
135 if (!code_point.has_value() || !
emit_utf8(*code_point, on_char))
154 const char separator = *
pos++;
155 if (separator ==
']')
157 if (separator !=
',')
A string that may live in flash (on ESP8266): pointer and length, with no byte-reading operations.
static constexpr ProgmemStringRef from_lit(const char(&s)[N])
A PROGMEM char array, with its length known at compile time.
StringRef is a reference to a string owned by something else.
FixedVector< HomeassistantServiceMap > data
bool parse_python_list(StringRef src, C &&on_char, O &&on_item)
Walk a list attribute as Home Assistant sends it: the Python repr of a list of strings,...
bool is_unset(StringRef value)
True for what Home Assistant reports when there is no value: "None" for an attribute that is not set,...
void add_entity_id(api::HomeassistantActionRequest &resp, const char *entity_id)
Adds the entity_id entry to an action's data.
static void const char * entity_id
bool can_send_action(const char *tag, const char *entity_id, EntityBase *entity)
Logs and returns false when no API client is connected or no entity is linked yet.
bool is_input_helper(const char *entity_id, const char *input_service)
True if entity_id is an input helper; input_service must start with "input_".
bool emit_utf8(uint32_t code_point, C &on_char)
Emit the UTF-8 encoding of a code point. Rejects NUL, which would end the item early.
constexpr ColorMode COLOR_MODE_LOOKUP[] PROGMEM
size_t parse_hex(const char *str, size_t length, uint8_t *data, size_t count)
Parse bytes from a hex-encoded string into a byte array.