Added "cam":1 in the discovery message, so that we can create a home assistant camera (#22818)

* Added "cam":1 in the discovery message, so that we can create a home assistant camera.

* Update tasmota/tasmota_xdrv_driver/xdrv_12_discovery.ino

Co-authored-by: Erik Kunze <eku@users.noreply.github.com>

* Rearrange the newly added field by size, for better packing.

---------

Co-authored-by: Erik Kunze <eku@users.noreply.github.com>
This commit is contained in:
anishsane 2025-01-16 21:10:37 +05:30 committed by GitHub
parent 866ffc8967
commit 5ac1fdb8fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 2 deletions

View File

@ -314,8 +314,9 @@ struct TasmotaGlobal_t {
bool pwm_present; // Any PWM channel configured with SetOption15 0
bool i2c_enabled[2]; // I2C configured for all possible buses (1 or 2)
#ifdef ESP32
bool camera_initialized; // For esp32-webcam, to be used in discovery
bool ota_factory; // Select safeboot binary
#endif
#endif // ESP32
bool ntp_force_sync; // Force NTP sync
bool skip_light_fade; // Temporarily skip light fading
bool restart_halt; // Do not restart but stay in wait loop

View File

@ -69,6 +69,7 @@ void TasDiscoverMessage(void) {
"\"mac\":\"%s\"," // Full MAC as Device id
"\"md\":\"%s\"," // Module or Template Name
"\"ty\":%d,\"if\":%d," // Flag for TuyaMCU and Ifan devices
"\"cam\":%d," // Flag for ESP32-cam
"\"ofln\":\"" MQTT_LWT_OFFLINE "\"," // Payload Offline
"\"onln\":\"" MQTT_LWT_ONLINE "\"," // Payload Online
"\"state\":[\"%s\",\"%s\",\"%s\",\"%s\"]," // State text for "OFF","ON","TOGGLE","HOLD"
@ -81,6 +82,11 @@ void TasDiscoverMessage(void) {
NetworkUniqueId().c_str(),
ModuleName().c_str(),
TuyaMod, iFanMod,
#ifdef ESP32
TasmotaGlobal.camera_initialized,
#else
false,
#endif
GetStateText(0), GetStateText(1), GetStateText(2), GetStateText(3),
TasmotaGlobal.version,
TasmotaGlobal.mqtt_topic,

View File

@ -488,7 +488,7 @@ uint32_t WcSetup(int32_t fsiz) {
camera_sensor_info_t *info = esp_camera_sensor_get_info(&wc_s->id);
AddLog(LOG_LEVEL_INFO, PSTR("CAM: %s Initialized"), info->name);
TasmotaGlobal.camera_initialized = true;
Wc.up = 1;
if (psram) { Wc.up = 2; }

View File

@ -1151,6 +1151,7 @@ uint32_t WcSetup(int32_t fsiz) {
camera_sensor_info_t *info = esp_camera_sensor_get_info(&wc_s->id);
AddLog(LOG_LEVEL_INFO, PSTR("CAM: %s Initialized"), info->name);
TasmotaGlobal.camera_initialized = true;
Wc.up = 1;
if (Wc.psram) { Wc.up = 2; }