Skip to content

Commit

Permalink
Merge pull request #10 from guillempages/FixRegisterComponent
Browse files Browse the repository at this point in the history
Fix register component for upcoming ESPHome 2023.12.0
  • Loading branch information
tiaanv authored Dec 4, 2023
2 parents 59bdd5d + 519036f commit b826ba8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/t547/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
CONF_LAMBDA,
CONF_PAGES,
)
from esphome.const import __version__ as ESPHOME_VERSION

DEPENDENCIES = ["esp32"]

Expand Down Expand Up @@ -35,12 +36,18 @@
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])

await cg.register_component(var, config)
if cv.Version.parse(ESPHOME_VERSION) < cv.Version.parse("2023.12.0"):
await cg.register_component(var, config)

await display.register_display(var, config)

if CONF_LAMBDA in config:
if cv.Version.parse(ESPHOME_VERSION) < cv.Version.parse("2023.7.0"):
displayRef = display.DisplayBufferRef
else:
displayRef = display.DisplayRef
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(displayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

Expand Down
4 changes: 4 additions & 0 deletions components/t547/t547.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
namespace esphome {
namespace t547 {

#if ESPHOME_VERSION_CODE >= VERSION_CODE(2023,12,0)
class T547 : public display::DisplayBuffer {
#else
class T547 : public PollingComponent, public display::DisplayBuffer {
#endif // VERSION_CODE(2023,12,0)
public:
void set_greyscale(bool greyscale) {
this->greyscale_ = greyscale;
Expand Down

0 comments on commit b826ba8

Please sign in to comment.