Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charts test for Ln882h and w800 #1368

Merged
merged 11 commits into from
Sep 29, 2024
2 changes: 1 addition & 1 deletion src/cmnds/cmd_channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions src/cmnds/cmd_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/httpserver/hass.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/httpserver/http_fns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++)
{
Expand Down
7 changes: 4 additions & 3 deletions src/httpserver/json_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
/*
Expand Down Expand Up @@ -352,14 +352,15 @@ 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
printer(request, ",");
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);
Expand Down
3 changes: 2 additions & 1 deletion src/obk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading