Closed 3ative closed 1 year ago
This seems linked to an spi refactor, from what i see there is a work-around that could go quite fast for you (and looks like the "correct way" to do it:
set_brightness write on the spi bus (which is not yet started (which explain your problem))
you should change your lambda for:
on_value:
- lambda: |-
if (id(oled).is_ready()) { id(oled).set_brightness(id(oled_brightness).state); } else { id(oled).init_brightness(id(oled_brightness).state); }
it's probably possible to patch up the set_brightness to do that natively.
let me know if this works for you.
@xdecock BOO-YA! there you go, nice one... thanks for the info
I re-wrote my code a bit (I wanted a 0-100% slider). Here's what I have now and it works a treat:
number:
- platform: template
id: oled_brightness
name: Brightness
optimistic: true
min_value: 0
max_value: 100
step: 5
initial_value: 50
on_value:
- lambda: |-
if (id(oled).is_ready()) {
id(oled).set_brightness(id(oled_brightness).state/100);
} else {
id(oled).init_brightness(id(oled_brightness).state/100);
}
Also, any idea why other OLEDs were changed to use "set_contrast", a few ESPHomes ago, and yet this still uses "set_brightness" ??
I'm just discovering the code inside esphome, and as i can help a bit, i do provide support, i currently have on PR open with 20-30 lines, so no expert, i'll try to fix the root cause of the issue for your screen. if you could test it once done, i'll be happy (as i don't have the screen at hand)
Oh, soz... I thought you were a DEV - you replied so quickly with something that worked.
I'm still testing stuff on my screen here (for a tutorial/project). But no worries if you want to send code for me to test on it. Here is not the best option to continue on that. Come join my DISCORD server: https://discord.com/invite/3RbZgvHeJ9
Could you give a try to this?
external_components:
# equivalent shorthand for GitHub pull request
- source: github://pr#5454
components: [ ssd1351_base, ssd1351_spi ]
Could you give a try to this?
external_components: # equivalent shorthand for GitHub pull request - source: github://pr#5454 components: [ ssd1351_base, ssd1351_spi ]
Tried. Allows my orig code:
number:
- platform: template
id: oled_brightness
name: Brightness
optimistic: true
min_value: 0
max_value: 100
step: 5
initial_value: 50
on_value:
- lambda: |-
id(oled).set_brightness(id(oled_brightness).state);
However, brightness doesn't change on screen.
Opps, forgot to divide by 100....
id(oled).set_brightness(id(oled_brightness).state/100);
Now all we need is 0 Brightness to turn off the OLED! LOL
That's a feature request ^^ and i'm not sure i have the patience to do that kind of dev blind
Le ven. 29 sept. 2023, 20:46, David Martin @.***> a écrit :
Now all we need is 0 Brightness to turn off the OLED! LOL
— Reply to this email directly, view it on GitHub https://github.com/esphome/issues/issues/4924#issuecomment-1741339866, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAME7PDVX6I6QZGIVPB74TX44JQVANCNFSM6AAAAAA5MZC2EQ . You are receiving this because you were mentioned.Message ID: @.***>
The problem
Using a lambda to call "set_brightness" in a "Button" works fine.
However, calling the same from "Number" prevents proper boot and panics the device
Which version of ESPHome has the issue?
2023.9.x
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2023.8.3
What platform are you using?
ESP32
Board
esp32dev
Component causing the issue
No response
Example YAML snippet
This works fine:
This panics it (even without moving the slider) :
Tried this, this is also fine:
-- But this is obviously two operations and therefore not ideal. 😊
Anything in the logs that might be useful for us?
Additional information
No response