Skip to content

Commit

Permalink
bresser multiple sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed Jul 4, 2024
1 parent 8789407 commit d19eaca
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
// ------------------------------------------------------------------------------------------------
// --- Weather Sensors ---
// ------------------------------------------------------------------------------------------------
#define NUM_SENSORS 1 // Number of sensors to be received
#define NUM_SENSORS 3 // Number of sensors to be received

// List of sensor IDs to be excluded - can be empty
#define SENSOR_IDS_EXC { 0x792882A2 }
Expand Down
68 changes: 38 additions & 30 deletions tasmota/tasmota_xsns_sensor/xsns_125_bresser.ino
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,30 @@ void CC1101_Bresser_task(void) {


const char HTTP_Bresser1[] PROGMEM =
"{s}Bresser ID" "{m}%8x" "{e}"
"{s}Bresser Type" "{m}%x" "{e}"
"{s}Bresser Chan" "{m}%d" "{e}"
"{s}Bresser Stat" "{m}%d" "{e}"
"{s}Bresser Batt" "{m}%-3s" "{e}"
"{s}Bresser RSSI" "{m}%1_f dBm" "{e}"
"{s}Bresser %1d ID" "{m}%8x" "{e}"
"{s}Bresser %1d Type" "{m}%x" "{e}"
"{s}Bresser %1d Chan" "{m}%d" "{e}"
"{s}Bresser %1d Stat" "{m}%d" "{e}"
"{s}Bresser %1d Batt" "{m}%-3s" "{e}"
"{s}Bresser %1d RSSI" "{m}%1_f dBm" "{e}"
;

const char HTTP_Bresser2[] PROGMEM =
"{s}Bresser WMAX" "{m}%1_f" "{e}"
"{s}Bresser WAVG" "{m}%1_f" "{e}"
"{s}Bresser CWDIR" "{m}%1_f" "{e}"
"{s}Bresser %1d WMAX" "{m}%1_f" "{e}"
"{s}Bresser %1d WAVG" "{m}%1_f" "{e}"
"{s}Bresser %1d CWDIR" "{m}%1_f" "{e}"
;

const char HTTP_Bresser3[] PROGMEM =
"{s}Bresser RAIN" "{m}%1_f" "{e}"
"{s}Bresser %1d RAIN" "{m}%1_f" "{e}"
;

const char HTTP_Bresser4[] PROGMEM =
"{s}Bresser UVidx" "{m}%1_f" "{e}"
"{s}Bresser %1d UVidx" "{m}%1_f" "{e}"
;

const char HTTP_Bresser5[] PROGMEM =
"{s}Bresser Light" "{m}%1_f" "{e}"
"{s}Bresser %1d Light" "{m}%1_f" "{e}"
;

void C1101_Bresser_Show(boolean json) {
Expand All @@ -119,34 +119,42 @@ void C1101_Bresser_Show(boolean json) {
// This example uses only a single slot in the sensor data array
int const i = 0;

if (!json) {
if (!json) {

WSContentSend_PD(HTTP_Bresser1, static_cast<int> (ws.sensor_copy[i].sensor_id), ws.sensor_copy[i].s_type, ws.sensor_copy[i].chan, ws.sensor_copy[i].startup, ws.sensor_copy[i].battery_ok ? "OK " : "Low", &ws.sensor_copy[i].rssi);
for (int i = 0; i < NUM_SENSORS; i++) {

if ((ws.sensor_copy[i].w.temp_ok) && (ws.sensor_copy[i].w.humidity_ok)) {
TempHumDewShow(json, (0 == TasmotaGlobal.tele_period), "Bresser", ws.sensor_copy[i].w.temp_c, ws.sensor_copy[i].w.humidity);
}
if (ws.sensor_copy[i].rssi == 0) {
continue;
}

if (ws.sensor_copy[i].w.wind_ok) {
WSContentSend_PD(HTTP_Bresser2, &ws.sensor_copy[i].w.wind_gust_meter_sec, &ws.sensor_copy[i].w.wind_avg_meter_sec, &ws.sensor_copy[i].w.wind_direction_deg);
}
WSContentSend_PD(HTTP_Bresser1, i + 1, static_cast<int> (ws.sensor_copy[i].sensor_id), i + 1, ws.sensor_copy[i].s_type, i + 1, ws.sensor_copy[i].chan, i + 1, ws.sensor_copy[i].startup, i + 1, ws.sensor_copy[i].battery_ok ? "OK " : "Low", i + 1, &ws.sensor_copy[i].rssi);

if (ws.sensor_copy[i].w.rain_ok) {
WSContentSend_PD(HTTP_Bresser3, &ws.sensor_copy[i].w.rain_mm);
}
if ((ws.sensor_copy[i].w.temp_ok) && (ws.sensor_copy[i].w.humidity_ok)) {
char label[16];
sprintf_P(label,PSTR("Bresser %1d"), i + 1);
TempHumDewShow(json, (0 == TasmotaGlobal.tele_period), label, ws.sensor_copy[i].w.temp_c, ws.sensor_copy[i].w.humidity);
}

if (ws.sensor_copy[i].w.wind_ok) {
WSContentSend_PD(HTTP_Bresser2, i + 1, &ws.sensor_copy[i].w.wind_gust_meter_sec, i + 1, &ws.sensor_copy[i].w.wind_avg_meter_sec, i + 1, &ws.sensor_copy[i].w.wind_direction_deg);
}

if (ws.sensor_copy[i].w.rain_ok) {
WSContentSend_PD(HTTP_Bresser3, i + 1, &ws.sensor_copy[i].w.rain_mm);
}

#if defined BRESSER_6_IN_1 || defined BRESSER_7_IN_1
if (ws.sensor_copy[i].w.uv_ok) {
WSContentSend_PD(HTTP_Bresser4, &ws.sensor_copy[i].w.uv);
}
if (ws.sensor_copy[i].w.uv_ok) {
WSContentSend_PD(HTTP_Bresser4, i + 1, &ws.sensor_copy[i].w.uv);
}
#endif

#ifdef BRESSER_7_IN_1
if (ws.sensor_copy[i].w.light_ok) {
WSContentSend_PD(HTTP_Bresser5, &ws.sensor_copy[i].w.light_klx);
}
if (ws.sensor_copy[i].w.light_ok) {
WSContentSend_PD(HTTP_Bresser5, i + 1, &ws.sensor_copy[i].w.light_klx);
}
#endif

}
} else {
ResponseAppend_P(PSTR(",\"Bresser\":{\"ID\":%8x,\"Type\":%x,\"Chan\":%d,\"Stat\":%d,\"Batt\":\"%-3s\",\"RSSI\":%1_f"),\
static_cast<int> (ws.sensor_copy[i].sensor_id), ws.sensor_copy[i].s_type, ws.sensor_copy[i].chan, ws.sensor_copy[i].startup, ws.sensor_copy[i].battery_ok ? "OK " : "Low", &ws.sensor_copy[i].rssi);
Expand Down

0 comments on commit d19eaca

Please sign in to comment.