We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The example specifies both lambda and optimistic, which is not allowed:
lambda
optimistic
cover.template: - Invalid config for [cover.template]: Cannot specify more than one of lambda, optimistic.
Additionally, the generated c++ code (if I remove optimistic) does not seem to be valid:
binary_sensor: - platform: gpio id: garage_door device_class: garage_door name: Garage Door pin: number: 12 inverted: False mode: INPUT_PULLUP switch: - platform: gpio id: garage_door_switch name: Garage Door Switch pin: 27 cover: - platform: template id: garage_door_opener name: "Garage Door Opener" lambda: >- if (id(garage_door).value) { return cover::COVER_CLOSED; } else { return cover::COVER_OPEN; } open_action: - switch.turn_on: id: garage_door_switch - delay: 1s - switch.turn_off: id: garage_door_switch close_action: - switch.turn_on: id: garage_door_switch - delay: 1s - switch.turn_off: id: garage_door_switch - delay: 1s - switch.turn_on: id: garage_door_switch - delay: 1s - switch.turn_off: id: garage_door_switch stop_action: - switch.turn_on: id: garage_door_switch - delay: 1s - switch.turn_off: id: garage_door_switch
results in:
Compiling .pioenvs/garage/src/main.cpp.o src/main.cpp: In function 'void setup()': src/main.cpp:24:26: error: expected unqualified-id before '->' token template_cover.template->set_state_lambda([=]() { ^ *** [.pioenvs/garage/src/main.cpp.o] Error 1
from the following code:
auto template_cover = App.make_template_cover("Garage Door Opener"); auto gpio_switch = App.make_gpio_switch("Garage Door Switch", 27); auto *garage_door_switch = gpio_switch.switch_; auto gpio_binary_sensor = App.make_gpio_binary_sensor("Garage Door", GPIOInputPin(12, INPUT_PULLUP, false)); auto *garage_door = gpio_binary_sensor.gpio; garage_door->set_device_class("garage_door"); template_cover.template->set_state_lambda([=]() { if (garage_door->value) { return cover::COVER_CLOSED; } else { return cover::COVER_OPEN; } });
The text was updated successfully, but these errors were encountered:
Fix esphome#27 - invalid code gen for Template Cover
0afe153
8d2a182
65d0dd4
Fix template/switch cover example. Fixes #27
7a393c1
No branches or pull requests
The example specifies both
lambda
andoptimistic
, which is not allowed:Additionally, the generated c++ code (if I remove
optimistic
) does not seem to be valid:results in:
from the following code:
The text was updated successfully, but these errors were encountered: