diff --git a/src/cmnds/cmd_channels.c b/src/cmnds/cmd_channels.c index 8a9d97238..b39a3b936 100644 --- a/src/cmnds/cmd_channels.c +++ b/src/cmnds/cmd_channels.c @@ -407,7 +407,7 @@ static commandResult_t CMD_SetChannelPrivate(const void *context, const char *cm return CMD_RES_OK; } static commandResult_t CMD_GetReadings(const void *context, const char *cmd, const char *args, int cmdFlags){ -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 char tmp[96]; float v, c, p; float e, elh; diff --git a/src/cmnds/cmd_if.c b/src/cmnds/cmd_if.c index c3cb00a3c..606db1c22 100644 --- a/src/cmnds/cmd_if.c +++ b/src/cmnds/cmd_if.c @@ -220,7 +220,7 @@ float getActiveRepeatingEvents(const char *s) { return RepeatingEvents_GetActiveCount(); } -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 float getVoltage(const char *s) { return DRV_GetReading(OBK_VOLTAGE); @@ -397,7 +397,7 @@ const constant_t g_constants[] = { //cnstdetail:"descr":"Current number of active repeating events", //cnstdetail:"requires":""} {"$activeRepeatingEvents", &getActiveRepeatingEvents}, -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 //cnstdetail:{"name":"$voltage", //cnstdetail:"title":"$voltage", //cnstdetail:"descr":"Current value of voltage from energy metering chip. You can use those variables to make, for example, a change handler that fires when voltage is above 245, etc.", @@ -422,6 +422,8 @@ const constant_t g_constants[] = { //cnstdetail:"title":"$day", //cnstdetail:"descr":"Current weekday from NTP", //cnstdetail:"requires":""} +#endif //ENABLE_DRIVER_BL0937 +#ifdef ENABLE_NTP {"$day", &getWeekDay}, //cnstdetail:{"name":"$hour", //cnstdetail:"title":"$hour", @@ -480,6 +482,7 @@ const constant_t g_constants[] = { //cnstdetail:"descr":"Returns 1 if NTP is on and already synced (so device has correct time), otherwise 0.", //cnstdetail:"requires":""} { "$NTPOn", &getNTPOn }, +#endif //ENABLE_NTP #ifdef ENABLE_DRIVER_BATTERY //cnstdetail:{"name":"$batteryVoltage", //cnstdetail:"title":"$batteryVoltage", @@ -491,8 +494,7 @@ const constant_t g_constants[] = { //cnstdetail:"descr":"Battery driver level", //cnstdetail:"requires":""} { "$batteryLevel", &getBatteryLevel }, -#endif -#endif +#endif // ENABLE_DRIVER_BATTERY //cnstdetail:{"name":"$uptime", //cnstdetail:"title":"$uptime", //cnstdetail:"descr":"Time since reboot in seconds", diff --git a/src/httpserver/hass.c b/src/httpserver/hass.c index 66cd94359..c7dc7e7e7 100644 --- a/src/httpserver/hass.c +++ b/src/httpserver/hass.c @@ -51,7 +51,7 @@ void hass_populate_unique_id(ENTITY_TYPE type, int index, char* uniq_id) { break; case ENERGY_METER_SENSOR: -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 sprintf(uniq_id, "%s_sensor_%s", longDeviceName, DRV_GetEnergySensorNames(index)->hass_uniq_id_suffix); #endif break; @@ -243,7 +243,7 @@ HassDeviceInfo* hass_init_device_info(ENTITY_TYPE type, int index, const char* p break; case ENERGY_METER_SENSOR: isSensor = true; - #ifndef OBK_DISABLE_ALL_DRIVERS + #ifdef ENABLE_DRIVER_BL0937 if (index <= OBK__LAST) sprintf(g_hassBuffer, "%s", DRV_GetEnergySensorNames(index)->name_friendly); else @@ -455,7 +455,7 @@ HassDeviceInfo* hass_init_binary_sensor_device_info(int index, bool bInverse) { return info; } -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 /// @brief Initializes HomeAssistant power sensor device discovery storage. /// @param index Index corresponding to energySensor_t. diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index a7d3420a9..869a8d5e8 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -1681,7 +1681,7 @@ void doHomeAssistantDiscovery(const char* topic, http_request_t* request) { topic = "homeassistant"; } -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 measuringPower = DRV_IsMeasuringPower(); measuringBattery = DRV_IsMeasuringBattery(); #endif @@ -1786,7 +1786,7 @@ void doHomeAssistantDiscovery(const char* topic, http_request_t* request) { } } -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 if (measuringPower == true) { for (i = OBK__FIRST; i <= OBK__LAST; i++) { diff --git a/src/httpserver/json_interface.c b/src/httpserver/json_interface.c index 4c2ff6a62..d3993e21b 100644 --- a/src/httpserver/json_interface.c +++ b/src/httpserver/json_interface.c @@ -194,7 +194,7 @@ static int http_tasmota_json_power(void* request, jsonCb_t printer) { /* {"StatusSNS":{"Time":"2022-07-30T10:11:26","ENERGY":{"TotalStartTime":"2022-05-12T10:56:31","Total":0.003,"Yesterday":0.003,"Today":0.000,"Power": 0,"ApparentPower": 0,"ReactivePower": 0,"Factor":0.00,"Voltage":236,"Current":0.000}}} */ - +#ifdef ENABLE_DRIVER_BL0937 // returns NaN values as 0 static float _getReading_NanToZero(energySensor_t type) { float retval = DRV_GetReading(type); @@ -231,7 +231,7 @@ static int http_tasmota_json_ENERGY(void* request, jsonCb_t printer) { } return 0; } - +#endif // ENABLE_DRIVER_BL0937 // Topic: tele/tasmota_48E7F3/SENSOR at 3:06 AM: // Sample: /* @@ -352,7 +352,7 @@ static int http_tasmota_json_status_SNS(void* request, jsonCb_t printer, bool bA JSON_PrintKeyValue_String(request, printer, "Time", buff, false); #ifndef OBK_DISABLE_ALL_DRIVERS - +#ifdef ENABLE_DRIVER_BL0937 if (DRV_IsMeasuringPower() || DRV_IsMeasuringBattery()) { // begin ENERGY block @@ -360,6 +360,7 @@ static int http_tasmota_json_status_SNS(void* request, jsonCb_t printer, bool bA printer(request, "\"ENERGY\":"); http_tasmota_json_ENERGY(request, printer); } +#endif // ENABLE_DRIVER_BL0937 bool bHasAnyDHT = false; for (int i = 0; i < PLATFORM_GPIO_MAX; i++) { int role = PIN_GetPinRoleForPinIndex(i); diff --git a/src/obk_config.h b/src/obk_config.h index 8b695d0bc..9e9753fbf 100644 --- a/src/obk_config.h +++ b/src/obk_config.h @@ -30,7 +30,8 @@ #elif PLATFORM_W800 -#define OBK_DISABLE_ALL_DRIVERS 1 +// try enabling drivers - e.g. to access charts +//#define OBK_DISABLE_ALL_DRIVERS 1 #define ENABLE_TASMOTA_JSON 1 #define ENABLE_DRIVER_DS1820 1 diff --git a/src/user_main.c b/src/user_main.c index 0143ceff7..a197f0f97 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -776,7 +776,7 @@ void Main_OnEverySecond() if (!g_reset) { // ensure any config changes are saved before reboot. CFG_Save_IfThereArePendingChanges(); -#ifndef OBK_DISABLE_ALL_DRIVERS +#ifdef ENABLE_DRIVER_BL0937 if (DRV_IsMeasuringPower()) { BL09XX_SaveEmeteringStatistics();