I can’t seem to figure out how to initiate and use array variables in esphomeyaml. I saw on the Automations and Templates page (linked below) that I can use array variables but I don’t know the initialization syntax. Since I haven’t successfully created one, I haven’t tried using the variable in lambda so tips there are also welcome.
src\main.cpp:35:94: error: no matching function for call to 'esphome::Application::make_global_variable(<brace-enclosed initializer list>)'
GlobalVariableComponent<int[4]> *gpio14_relays = App.make_global_variable<int[4]>({1,2,3,4});
^
src\main.cpp:35:94: note: candidates are:
In file included from .piolibdeps\esphome-core\src/esphome.h:1:0,
from src\main.cpp:3:
.piolibdeps\esphome-core\src/esphome/application.h:337:31: note: template<class T> esphome::GlobalVariableComponent<T>* esphome::Application::make_global_variable()
GlobalVariableComponent<T> *make_global_variable();
config
globals:
- id: gpio14_relays
type: int[4]
restore_value: no
initial_value: "{1,2,3,4}"
The below code should also work. But gives compile time error
globals:
- id: gpio14_relays
type: int[]
restore_value: no
initial_value: "{1,2}"
In file included from src/esphome.h:17:0,
from src/main.cpp:3:
src/esphome/components/globals/globals_component.h: In instantiation of ‘class esphome::globals::GlobalsComponent<int >’:
src/main.cpp:3279:63: required from here
src/esphome/components/globals/globals_component.h:47:12: error: ‘esphome::globals::GlobalsComponent::value_’ has incomplete type
T value_{};
^
src/esphome/components/globals/globals_component.h:47:12: error: invalid use of array with unspecified bounds
src/esphome/components/globals/globals_component.h:48:17: error: ‘esphome::globals::GlobalsComponent::prev_value_’ has incomplete type
T prev_value_{};
^
src/esphome/components/globals/globals_component.h:48:17: error: invalid use of array with unspecified bounds
src/main.cpp: In function ‘void setup()’:
src/main.cpp:3279:63: error: no matching function for call to ‘esphome::globals::GlobalsComponent<int >::GlobalsComponent()’
my_global_int = new globals::GlobalsComponent<int >({1, 2});
^