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
Husb238 USB PD controller #6693
base: dev
Are you sure you want to change the base?
Conversation
Hey there @latonita, CODEOWNERS = ["@latonita"] And run (message by NeedsCodeownersLabel) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #6693 +/- ##
==========================================
+ Coverage 53.70% 54.21% +0.50%
==========================================
Files 50 50
Lines 9408 9594 +186
Branches 1654 1691 +37
==========================================
+ Hits 5053 5201 +148
- Misses 4056 4069 +13
- Partials 299 324 +25 ☔ View full report in Codecov by Sentry. |
It seems that the HUSB238 chip is a little longer than the 30 ms time limit. I suppose it come from calling Husb238Component::read_all_() method. This generates permanent alerts in the logs:
@latonita Is it possible to increase the request interval? |
okay, I took a look there
this shall help to minimize the latency |
File does not end with a newline
@lboue try current version. |
@latonita
|
@latonita |
Didn't i make it? :)) ahaha. Okay. There is a public function which can be called from lambda, but I haven't tried to use it yet. I will also make a yaml parameter for voltage selection. |
This function takes a ‘SrcVoltageSelection’ type as a parameter:
I think we'll need a function to convert a string to this type and called binary_sensor:
- platform: gpio
id: set_voltage_button
pin: 39
on_click:
then:
- lambda:
id(husb_01).command_request_pdo("9V"); Otherwise it returns an error during compilation:
Like this one: static float string_to_voltage(char *const string_voltage) {
switch (string_voltage) {
case "5V":
return SrcVoltage::PD_5V;
case "9V":
return SrcVoltage::PD_9V;
case "12V":
return SrcVoltage::PD_12V;
case "15V":
return SrcVoltage::PD_15V;
case "18V":
return SrcVoltage::PD_18V;
case "20V":
return SrcVoltage::PD_20V;
default:
ESP_LOGW(TAG, "Invalid or no string voltage selected");
}
} |
@lboue for now try this i will think of something easier :)) |
@lboue okay, i have added simpler function :)))) - lambda: |-
id(husb_01).command_request_voltage(12); |
Thanks. Now I can select the voltage with a select componant: But contracted Voltage stays at 5V. # 5V: 0.00A, 9V: 0.00A, 12V: 0.00A, 15V: 0.00A, 18V: 0.00A, 20V: 0.00A
- platform: template
name: Selected Voltage
id: husb238_voltage
options:
- "5"
- "9"
- "12"
- "15"
- "18"
- "20"
initial_option: "5"
optimistic: true
on_value:
then:
- lambda: |-
int voltage = atoi(x.c_str());
id(husb_01).command_request_voltage(voltage);
set_action:
- logger.log:
format: "Selected option: %s"
args: ["x.c_str()"] Logs
|
@lboue i added some more logging. please enable verbose log level, build new version and post log results |
Thansk. I am facing a build issue against last commit:
CI build fails too: |
|
Thanks. This time I've got reading errors:
|
@lboue drop me an email to anton.viktorov at live.com or text me in discord, same email there |
@latonita
|
@latonita |
What does this implement/fix?
Types of changes
Related issue or feature (if applicable): fixes esphome/feature-requests#2674
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: