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

feat: maximum available capacity slider #13

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down
11 changes: 8 additions & 3 deletions config/nexxtender.s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 3 additions & 2 deletions config/nexxtender.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions config/nexxtender_packages/esp.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
substitutions:
device_name: nexxtender
friendly_name: Nexxtender

esp32:
board: az-delivery-devkit-v4
framework:
Expand Down
37 changes: 36 additions & 1 deletion config/nexxtender_packages/generic_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -242,7 +246,9 @@ script:
ESP_LOGD("${device_name}_generic_data script_write_config", "Checksum CRC16 Failed");
return;
}
int rounded_i_max = static_cast<int>(id(g_${generic_data_id_prefix}_i_max)); // Round down to nearest integer
int rounded_i_evse_max = static_cast<int>(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());
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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: |-
Expand All @@ -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<float>(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
Expand Down