Skip to content

Commit

Permalink
Update r4875g1-can-web.latest.YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpalmowski authored Dec 6, 2024
1 parent 6159cb5 commit 1264c56
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions r4875g1-can-web.latest.YAML
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ canbus:

substitutions:
multiplier_default: '0.0009765625' # 1/1024 conversion factor
multiplier_current: '0.05' # 1/20 conversion factor # 1/15 conversion factor 0.06666 to be used if pin 9 and pin 10 on r4875g1 board edge are connected
multiplier_current: '0.0666666' # 1/20 conversion factor # 1/15 conversion factor 0.06666 to be used if pin 9 and pin 10 on r4875g1 board edge are connected

binary_sensor:
- platform: template
Expand Down Expand Up @@ -333,7 +333,7 @@ number:
- delay: 0.01s # Small delay to ensure the value is properly updated
- lambda: |-
float amp_value = id(can_amp_input).state; // Get the current Amp value
int scaled_value = (int)(amp_value * 20); // Scale the Amp value (Amp * 20)
int scaled_value = (int)(amp_value * 15); // Scale the Amp value (Amp * 15)
ESP_LOGI("custom", "Received Amp: %.1fA, Scaled value: %d", amp_value, scaled_value);
uint8_t high_byte = (scaled_value >> 8) & 0xFF;
Expand All @@ -347,7 +347,7 @@ number:
std::vector<uint8_t> can_data(8, 0x00); // Initialize with 8 zeros
can_data[0] = 0x01; // First byte is always 0x01
can_data[1] = 0x03; // Second byte is 0x03
int scaled_value = (int)(id(can_amp_input).state * 20); // Scale the Amp value
int scaled_value = (int)(id(can_amp_input).state * 15); // Scale the Amp value
can_data[6] = (scaled_value >> 8) & 0xFF; // Encode the high byte in the 7th byte
can_data[7] = scaled_value & 0xFF; // Encode the low byte in the 8th byte
return can_data;
Expand All @@ -370,7 +370,7 @@ number:
- delay: 0.01s # Small delay to ensure the value is properly updated
- lambda: |-
float fallback_amp_value = id(fallback_amp_input).state; // Get the fallback Amp value
int fallback_scaled_value = (int)(fallback_amp_value * 20); // Scale the Amp value (Amp * 20)
int fallback_scaled_value = (int)(fallback_amp_value * 15); // Scale the Amp value (Amp * 15)
ESP_LOGI("custom", "Fallback Amp: %.1fA, Scaled value: %d", fallback_amp_value, fallback_scaled_value);
uint8_t high_byte = (fallback_scaled_value >> 8) & 0xFF; // Get high byte
Expand All @@ -384,7 +384,7 @@ number:
std::vector<uint8_t> can_data(8, 0x00); // Initialize with 8 zeros
can_data[0] = 0x01; // First byte is always 0x01
can_data[1] = 0x04; // Second byte is 0x04 for the Fallback Amps setting
int fallback_scaled_value = (int)(id(fallback_amp_input).state * 20); // Scale the Amp value
int fallback_scaled_value = (int)(id(fallback_amp_input).state * 15); // Scale the Amp value
can_data[6] = (fallback_scaled_value >> 8) & 0xFF; // Encode the high byte in the 7th byte
can_data[7] = fallback_scaled_value & 0xFF; // Encode the low byte in the 8th byte
return can_data;
Expand Down Expand Up @@ -625,7 +625,7 @@ time:
std::vector<uint8_t> can_data(8, 0x00); // Initialize with 8 zeros
can_data[0] = 0x01; // First byte is always 0x01
can_data[1] = 0x03; // Second byte is 0x03
int scaled_value = (int)(id(can_amp_input).state * 20); // Scale the Amp value
int scaled_value = (int)(id(can_amp_input).state * 15); // Scale the Amp value
can_data[6] = (scaled_value >> 8) & 0xFF; // Encode the high byte in the 7th byte
can_data[7] = scaled_value & 0xFF; // Encode the low byte in the 8th byte
return can_data;
Expand Down

0 comments on commit 1264c56

Please sign in to comment.