diff --git a/README.md b/README.md index be4e00b..ecf1a00 100644 --- a/README.md +++ b/README.md @@ -102,19 +102,22 @@ By following these steps, you can easily find the Bluetooth MAC address of your file: config/nexxtender.yaml refresh: 0s substitutions: - device_name: nexxtender - friendly_name: Nexxtender + ## Uncomment and modify when you want to use a different device name. + # device_name: nexxtender + # friendly_name: Nexxtender ## Uncomment and modify when you want to use a different threshold. # charging_mode_eco_threshold: "8" # Single phase (6A + 2 margin) # charging_mode_eco_bi_threshold: "14" # Bi-phase (12A + 2 margin) # charging_mode_eco_tri_threshold: "20" # Tri-phase (18A + 2 margin) - # slider_max_car_charging_speed: "32" # The max value of the slider for the maximum car charging speed slider + # slider_max_car_charging_speed: "32" # The max value of the slider for the maximum car charging speed slider, default set to 32 + # slider_max_available_capacity: "40" # The max value of the slider for the maximum available capacity slider, default set to 40 ``` - The charging power mode is estimated based on the number of phases used during the charge. - The substitution `charging_mode_eco_threshold` and the others are optional, and you can set it to whatever Amp you want to be used as a threshold for the ECO/MAX sensor. Default values are the ones set in the example. Attention, it does not influence your charger; it is just a way of indicating which speed the charger is delivering. - - The substitution `slider_max_car_charging_speed` lets you override the maximum value for the configuration slider of the maximum car charging speed. This is usually set to the value of the circuit breaker A. Default value is the one set in the example. + - The substitution `slider_max_car_charging_speed` lets you override the maximum value for the configuration slider of the maximum car charging speed. This is usually set to the value of the circuit breaker A. Default value is the ones set in the example. + - The substitution `slider_max_available_capacity` lets you override the maximum value for the configuration slider of the maximum available capacity of the grid. This is usually set to the value of the circuit breaker A. Default value is the ones set in the example. 3. **Update the secrets.yaml:** diff --git a/config/nexxtender.s3.yaml b/config/nexxtender.s3.yaml index 1de7fd9..140d6a2 100644 --- a/config/nexxtender.s3.yaml +++ b/config/nexxtender.s3.yaml @@ -13,7 +13,12 @@ packages: charging_advanced_data: !include nexxtender_packages/charging_advanced_data.yaml #transactions: !include nexxtender_packages/transactions.yaml #diagnostics: !include nexxtender_packages/diagnostics.yaml - + substitutions: - device_name: nexxtender - friendly_name: Nexxtender + # device_name: nexxtender + # friendly_name: Nexxtender + # charging_mode_eco_mono_threshold: "8" + # charging_mode_eco_bi_threshold: "14" + # charging_mode_eco_tri_threshold: "20" + # slider_max_car_charging_speed: "32" + # slider_max_available_capacity: "40" diff --git a/config/nexxtender.yaml b/config/nexxtender.yaml index 38384bc..8f3eb37 100644 --- a/config/nexxtender.yaml +++ b/config/nexxtender.yaml @@ -15,9 +15,10 @@ packages: #dev_debug: !include nexxtender_packages/dev_debug.yaml substitutions: - device_name: nexxtender - friendly_name: Nexxtender + # device_name: nexxtender + # friendly_name: Nexxtender # charging_mode_eco_mono_threshold: "8" # charging_mode_eco_bi_threshold: "14" # charging_mode_eco_tri_threshold: "20" # slider_max_car_charging_speed: "32" + # slider_max_available_capacity: "40" diff --git a/config/nexxtender_packages/esp.yaml b/config/nexxtender_packages/esp.yaml index 8f29f26..b403b6f 100644 --- a/config/nexxtender_packages/esp.yaml +++ b/config/nexxtender_packages/esp.yaml @@ -1,3 +1,7 @@ +substitutions: + device_name: nexxtender + friendly_name: Nexxtender + esp32: board: az-delivery-devkit-v4 framework: diff --git a/config/nexxtender_packages/generic_data.yaml b/config/nexxtender_packages/generic_data.yaml index ba68122..d8235c6 100644 --- a/config/nexxtender_packages/generic_data.yaml +++ b/config/nexxtender_packages/generic_data.yaml @@ -6,6 +6,7 @@ substitutions: generic_data_id_prefix: generic_data generic_data_update_interval: 60s slider_max_car_charging_speed: "32" + slider_max_available_capacity: "40" globals: - id: g_${generic_data_id_prefix}_config_init @@ -28,6 +29,9 @@ globals: - id: g_${generic_data_id_prefix}_i_evse_max type: float initial_value: '0' + - id: g_${generic_data_id_prefix}_i_max + type: float + initial_value: '0' - id: g_${generic_data_id_prefix}_charge_mode type: int initial_value: '6' @@ -242,7 +246,9 @@ script: ESP_LOGD("${device_name}_generic_data script_write_config", "Checksum CRC16 Failed"); return; } + int rounded_i_max = static_cast(id(g_${generic_data_id_prefix}_i_max)); // Round down to nearest integer int rounded_i_evse_max = static_cast(id(g_${generic_data_id_prefix}_i_evse_max)); // Round down to nearest integer + x[0] = rounded_i_max; x[1] = rounded_i_evse_max; x[2] = id(g_${generic_data_id_prefix}_charge_mode); add_crc_to_data(x, x.size()); @@ -415,6 +421,8 @@ script: String value_string; int value; id(${generic_data_id_prefix}_i_max).publish_state(getInt8(x, 0)); + id(g_${generic_data_id_prefix}_i_max) = getInt8(x, 0); + id(max_available_capacity).publish_state(getInt8(x, 0)); id(${generic_data_id_prefix}_i_evse_max).publish_state(getInt8(x, 1)); id(g_${generic_data_id_prefix}_i_evse_max) = getInt8(x, 1); id(max_charging_speed).publish_state(getInt8(x, 1)); @@ -517,7 +525,7 @@ number: step: 1 max_value: ${slider_max_car_charging_speed} min_value: 6 - mode: box + mode: slider entity_category: "config" set_action: - lambda: |- @@ -533,6 +541,33 @@ number: id(g_${generic_data_id_prefix}_i_evse_max) = value; id(script_send_config_old).execute(); } + - platform: template + id: max_available_capacity + name: Maximum available capacity + icon: "mdi:current-ac" + unit_of_measurement: A + restore_value: true + optimistic: true + device_class: current + step: 1 + max_value: ${slider_max_available_capacity} + min_value: 6 + mode: slider + entity_category: "config" + set_action: + - lambda: |- + std::string config = id(g_${generic_data_id_prefix}_config); + if (config.empty()) { return; } + float value = static_cast(x); + ESP_LOGD("Maximum available capacity", "Received: %f, previous value: %f", value, id(g_${generic_data_id_prefix}_i_max)); + if (id(g_${generic_data_id_prefix}_i_max) == 0) { + ESP_LOGD("Setting Maximum available capacity", "%f A", value); + id(g_${generic_data_id_prefix}_i_max) = value; + } else if (id(g_${generic_data_id_prefix}_i_max) != value) { + ESP_LOGD("Setting Maximum available capacity and sending config", "Received: %f, previous value: %f", value, id(g_${generic_data_id_prefix}_i_max)); + id(g_${generic_data_id_prefix}_i_max) = value; + id(script_send_config_old).execute(); + } select: - platform: template