#ifndef LOADBALANCER_H_
#define LOADBALANCER_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"

void loadbalancer_init(void);

void loadbalancer_set_enabled(bool enabled);
bool loadbalancer_is_enabled(void);

// GRID limit (A)
void     loadbalancer_grid_set_enabled(bool en);
bool     loadbalancer_grid_is_enabled(void);
esp_err_t loadbalancer_grid_set_max_import_a(uint8_t a);
uint8_t  loadbalancer_grid_get_max_import_a(void);

// PV optimizer (W)
void     loadbalancer_pv_set_enabled(bool en);
bool     loadbalancer_pv_is_enabled(void);
esp_err_t loadbalancer_pv_set_max_import_w(int32_t w);
int32_t  loadbalancer_pv_get_max_import_w(void);

// Aliases legacy (se quiseres manter chamadas antigas)
esp_err_t load_balancing_set_max_grid_current(uint8_t value);
uint8_t  load_balancing_get_max_grid_current(void);

#ifdef __cplusplus
}
#endif

#endif /* LOADBALANCER_H_ */
