Skip to content

Commit

Permalink
mathieucarbou/MycilaConfig @ 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Nov 12, 2024
1 parent 502bb05 commit 1cd8253
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion include/YaSolRDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

// UDP communication

#define YASOLR_UDP_PORT 53964
#define YASOLR_UDP_PORT 53964
// #define YASOLR_UDP_MSG_TYPE_JSY_DATA 0x01 // old json
#define YASOLR_UDP_MSG_TYPE_JSY_DATA 0x02 // new json

Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ lib_deps =
mathieucarbou/AsyncTCP @ 3.2.14
; https://github.com/mathieucarbou/AsyncTCPSock/archive/refs/tags/v1.0.3-dev.zip
mathieucarbou/ESPAsyncWebServer @ 3.3.22
mathieucarbou/MycilaConfig @ 4.0.0
mathieucarbou/MycilaConfig @ 5.0.0
mathieucarbou/MycilaDS18 @ 4.1.0
mathieucarbou/MycilaESPConnect @ 6.1.1
mathieucarbou/MycilaEasyDisplay @ 3.0.2
Expand Down
20 changes: 10 additions & 10 deletions src/Website.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ void YaSolR::WebsiteClass::initLayout() {
config.set(KEY_OUTPUT2_DIMMER_LIMIT, "100", false);

router.beginCalibration([]() {
config.set(KEY_OUTPUT1_RESISTANCE, String(router.getOutputs()[0]->config.calibratedResistance));
config.set(KEY_OUTPUT2_RESISTANCE, String(router.getOutputs()[1]->config.calibratedResistance));
config.set(KEY_OUTPUT1_RESISTANCE, String(router.getOutputs()[0]->config.calibratedResistance).c_str());
config.set(KEY_OUTPUT2_RESISTANCE, String(router.getOutputs()[1]->config.calibratedResistance).c_str());
});

YaSolR::Website.initCards();
Expand Down Expand Up @@ -391,17 +391,17 @@ void YaSolR::WebsiteClass::initLayout() {
_output1DimmerMapper.attachCallback([this](const char* value) {
const char* comma = strchr(value, ',');
if (comma != nullptr) {
config.set(KEY_OUTPUT1_DIMMER_MIN, String(value).substring(0, comma - value));
config.set(KEY_OUTPUT1_DIMMER_MAX, String(comma + 1));
config.set(KEY_OUTPUT1_DIMMER_MIN, String(value).substring(0, comma - value).c_str());
config.set(KEY_OUTPUT1_DIMMER_MAX, comma + 1);
}
_output1DimmerMapper.update(value);
dashboard.refreshCard(&_output1DimmerMapper);
});
_output2DimmerMapper.attachCallback([this](const char* value) {
const char* comma = strchr(value, ',');
if (comma != nullptr) {
config.set(KEY_OUTPUT2_DIMMER_MIN, String(value).substring(0, comma - value));
config.set(KEY_OUTPUT2_DIMMER_MAX, String(comma + 1));
config.set(KEY_OUTPUT2_DIMMER_MIN, String(value).substring(0, comma - value).c_str());
config.set(KEY_OUTPUT2_DIMMER_MAX, comma + 1);
}
_output2DimmerMapper.update(value);
dashboard.refreshCard(&_output2DimmerMapper);
Expand Down Expand Up @@ -989,15 +989,15 @@ void YaSolR::WebsiteClass::resetPID() {

void YaSolR::WebsiteClass::_sliderConfig(Card& card, const char* key) {
card.attachCallback([key, &card](int value) {
config.set(key, String(value));
config.set(key, String(value).c_str());
card.update(config.getInt(key));
dashboard.refreshCard(&card);
});
}

void YaSolR::WebsiteClass::_percentageSlider(Card& card, const char* key) {
card.attachCallback([key, &card](int value) {
config.set(key, String(value));
config.set(key, String(value).c_str());
card.update(value);
dashboard.refreshCard(&card);
});
Expand All @@ -1023,7 +1023,7 @@ void YaSolR::WebsiteClass::_numConfig(Card& card, const char* key) {
if (strlen(value) == 0) {
config.unset(key);
} else {
config.set(key, String(strtol(value, nullptr, 10)));
config.set(key, String(strtol(value, nullptr, 10)).c_str());
}
card.update(config.getInt(key));
dashboard.refreshCard(&card);
Expand All @@ -1037,7 +1037,7 @@ void YaSolR::WebsiteClass::_pinConfig(Card& card, const char* key) {
if (strlen(value) == 0) {
config.unset(key);
} else {
config.set(key, String(strtol(value, nullptr, 10)));
config.set(key, String(strtol(value, nullptr, 10)).c_str());
}
initCards();
dashboard.refreshCard(&card);
Expand Down
42 changes: 21 additions & 21 deletions src/init/Boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Mycila::Task bootTask("Boot", [](void* params) {
config.configure(KEY_MQTT_PUBLISH_INTERVAL, "5");
config.configure(KEY_MQTT_SECURED, YASOLR_FALSE);
config.configure(KEY_MQTT_SERVER);
config.configure(KEY_MQTT_TOPIC, Mycila::AppInfo.defaultMqttClientId);
config.configure(KEY_MQTT_TOPIC, Mycila::AppInfo.defaultMqttClientId.c_str());
config.configure(KEY_MQTT_USERNAME);
config.configure(KEY_NET_DNS);
config.configure(KEY_NET_GATEWAY);
Expand Down Expand Up @@ -109,30 +109,30 @@ Mycila::Task bootTask("Boot", [](void* params) {
config.configure(KEY_PID_OUT_MIN, "-1000");
config.configure(KEY_PID_P_MODE, "2");
config.configure(KEY_PID_SETPOINT, "0");
config.configure(KEY_PIN_DISPLAY_SCL, String(YASOLR_DISPLAY_CLOCK_PIN));
config.configure(KEY_PIN_DISPLAY_SDA, String(YASOLR_DISPLAY_DATA_PIN));
config.configure(KEY_PIN_JSY_RX, String(YASOLR_JSY_RX_PIN));
config.configure(KEY_PIN_JSY_TX, String(YASOLR_JSY_TX_PIN));
config.configure(KEY_PIN_LIGHTS_GREEN, String(YASOLR_LIGHTS_GREEN_PIN));
config.configure(KEY_PIN_LIGHTS_RED, String(YASOLR_LIGHTS_RED_PIN));
config.configure(KEY_PIN_LIGHTS_YELLOW, String(YASOLR_LIGHTS_YELLOW_PIN));
config.configure(KEY_PIN_OUTPUT1_DIMMER, String(YASOLR_OUTPUT1_DIMMER_PIN));
config.configure(KEY_PIN_OUTPUT1_DS18, String(YASOLR_OUTPUT1_TEMP_PIN));
config.configure(KEY_PIN_OUTPUT1_RELAY, String(YASOLR_OUTPUT1_RELAY_PIN));
config.configure(KEY_PIN_OUTPUT2_DIMMER, String(YASOLR_OUTPUT2_DIMMER_PIN));
config.configure(KEY_PIN_OUTPUT2_DS18, String(YASOLR_OUTPUT2_TEMP_PIN));
config.configure(KEY_PIN_OUTPUT2_RELAY, String(YASOLR_OUTPUT2_RELAY_PIN));
config.configure(KEY_PIN_PZEM_RX, String(YASOLR_PZEM_RX_PIN));
config.configure(KEY_PIN_PZEM_TX, String(YASOLR_PZEM_TX_PIN));
config.configure(KEY_PIN_RELAY1, String(YASOLR_RELAY1_PIN));
config.configure(KEY_PIN_RELAY2, String(YASOLR_RELAY2_PIN));
config.configure(KEY_PIN_ROUTER_DS18, String(YASOLR_SYSTEM_TEMP_PIN));
config.configure(KEY_PIN_ZCD, String(YASOLR_ZCD_PIN));
config.configure(KEY_PIN_DISPLAY_SCL, String(YASOLR_DISPLAY_CLOCK_PIN).c_str());
config.configure(KEY_PIN_DISPLAY_SDA, String(YASOLR_DISPLAY_DATA_PIN).c_str());
config.configure(KEY_PIN_JSY_RX, String(YASOLR_JSY_RX_PIN).c_str());
config.configure(KEY_PIN_JSY_TX, String(YASOLR_JSY_TX_PIN).c_str());
config.configure(KEY_PIN_LIGHTS_GREEN, String(YASOLR_LIGHTS_GREEN_PIN).c_str());
config.configure(KEY_PIN_LIGHTS_RED, String(YASOLR_LIGHTS_RED_PIN).c_str());
config.configure(KEY_PIN_LIGHTS_YELLOW, String(YASOLR_LIGHTS_YELLOW_PIN).c_str());
config.configure(KEY_PIN_OUTPUT1_DIMMER, String(YASOLR_OUTPUT1_DIMMER_PIN).c_str());
config.configure(KEY_PIN_OUTPUT1_DS18, String(YASOLR_OUTPUT1_TEMP_PIN).c_str());
config.configure(KEY_PIN_OUTPUT1_RELAY, String(YASOLR_OUTPUT1_RELAY_PIN).c_str());
config.configure(KEY_PIN_OUTPUT2_DIMMER, String(YASOLR_OUTPUT2_DIMMER_PIN).c_str());
config.configure(KEY_PIN_OUTPUT2_DS18, String(YASOLR_OUTPUT2_TEMP_PIN).c_str());
config.configure(KEY_PIN_OUTPUT2_RELAY, String(YASOLR_OUTPUT2_RELAY_PIN).c_str());
config.configure(KEY_PIN_PZEM_RX, String(YASOLR_PZEM_RX_PIN).c_str());
config.configure(KEY_PIN_PZEM_TX, String(YASOLR_PZEM_TX_PIN).c_str());
config.configure(KEY_PIN_RELAY1, String(YASOLR_RELAY1_PIN).c_str());
config.configure(KEY_PIN_RELAY2, String(YASOLR_RELAY2_PIN).c_str());
config.configure(KEY_PIN_ROUTER_DS18, String(YASOLR_SYSTEM_TEMP_PIN).c_str());
config.configure(KEY_PIN_ZCD, String(YASOLR_ZCD_PIN).c_str());
config.configure(KEY_RELAY1_LOAD, "0");
config.configure(KEY_RELAY1_TYPE, YASOLR_RELAY_TYPE_NO);
config.configure(KEY_RELAY2_LOAD, "0");
config.configure(KEY_RELAY2_TYPE, YASOLR_RELAY_TYPE_NO);
config.configure(KEY_UDP_PORT, String(YASOLR_UDP_PORT));
config.configure(KEY_UDP_PORT, String(YASOLR_UDP_PORT).c_str());
config.configure(KEY_WIFI_PASSWORD);
config.configure(KEY_WIFI_SSID);

Expand Down
8 changes: 4 additions & 4 deletions src/init/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Mycila::Task initEventsTask("Init Events", [](void* params) {
restartTask.resume();
});

config.listen([](const char* k, const String& newValue) {
logger.info(TAG, "'%s' => '%s'", k, newValue.c_str());
config.listen([](const char* k, const char* newValue) {
logger.info(TAG, "'%s' => '%s'", k, newValue);
const String key = k;

if (key == KEY_ENABLE_DEBUG) {
Expand Down Expand Up @@ -272,8 +272,8 @@ Mycila::Task initEventsTask("Init Events", [](void* params) {
} else {
logger.info(TAG, "Captive Portal: WiFi configured");
config.setBool(KEY_ENABLE_AP_MODE, false);
config.set(KEY_WIFI_SSID, espConnect.getConfiguredWiFiSSID());
config.set(KEY_WIFI_PASSWORD, espConnect.getConfiguredWiFiPassword());
config.set(KEY_WIFI_SSID, espConnect.getConfiguredWiFiSSID().c_str());
config.set(KEY_WIFI_PASSWORD, espConnect.getConfiguredWiFiPassword().c_str());
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/init/MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Mycila::Task initMqttSubscribersTask("Init MQTT Subscribers", [](void* params) {
const String key = topic.substring(start + 1, end);
const char* keyRef = config.keyRef(key.c_str());
if (keyRef)
config.set(keyRef, payload);
config.set(keyRef, payload.c_str());
});

// relays
Expand Down

0 comments on commit 1cd8253

Please sign in to comment.