2#ifdef LD2450_POLYGON_ZONE_COUNT
18 ESP_LOGW(TAG,
"'%s': saved polygon is invalid; zone disabled", LOG_STR_ARG(this->
get_log_name()));
26 char polygon_s[POLYGON_STR_SIZE];
28 LOG_TEXT(
" ",
"PolygonZone",
this);
29 ESP_LOGCONFIG(TAG,
" Polygon: '%s'", polygon_s);
30 LOG_BINARY_SENSOR(
" ",
"Presence", this->presence_binary_sensor_);
36 ESP_LOGW(TAG,
"'%s': invalid polygon '%s'; expected 'x,y;x,y;...' with %u to %u points",
37 LOG_STR_ARG(this->
get_log_name()), value.c_str(), MIN_POLYGON_POINTS, MAX_POLYGON_POINTS);
40 ESP_LOGW(TAG,
"'%s': could not save the polygon; keeping the previous one", LOG_STR_ARG(this->
get_log_name()));
48 this->presence_binary_sensor_->invalidate_state();
55 char polygon_s[POLYGON_STR_SIZE];
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
ESPPreferenceObject pref_
void control(const std::string &value) override
void publish_state(const std::string &state)
ESPHOME_LOG_TAG(TAG, "ld2450")
ESPPreferences * global_preferences
bool sync()
Commit pending writes to flash.
A polygon in radar coordinates. Trivially copyable so it can be saved to preferences as-is.
void format(char *buf) const
Write the polygon as "x,y;x,y;..." into buf, which must hold at least POLYGON_STR_SIZE bytes.
bool parse(const char *str, size_t len)
Parse "x,y;x,y;..." (mm) into this polygon.
bool is_valid() const
True when the polygon is empty, or has a valid number of points that are all inside the radar area.
bool empty() const
True when the polygon has no points, which disables the zone.