Hi,
I’m trying to set the state of a template switch in the main.cpp, but i’m not certain how to do this the correct way?
Main.cpp switch declaration:
// switch.template:
// platform: template
// name: Input IO
// id: Input_IO
// internal: true
// optimistic: true
// disabled_by_default: false
// assumed_state: false
// restore_state: false
Input_IO = new template_::TemplateSwitch();
Input_IO->set_component_source("template.switch");
App.register_component(Input_IO);
App.register_switch(Input_IO);
Input_IO->set_name("Input IO");
Input_IO->set_disabled_by_default(false);
Input_IO->set_internal(true);
Input_IO->set_optimistic(true);
Input_IO->set_assumed_state(false);
Input_IO->set_restore_state(false);
I wan’t to set the state of the template switch ‘Input_IO’ the following way in my main.cpp :
// Check if Temperature Set message from Toon, then kill manualboiler process
f = makeFloat (DataValue);
if (Input_IO->state == true && MsgType == WRITE_DATA && DataId == CONTROL_SETPOINT && (f > Input_Temp->state))
{
Input_IO = false;
}
However when compiling I get the following error/warning:
src/main.cpp: In function 'void processRequest(long unsigned int, OpenThermResponseStatus)':
src/main.cpp:289:14: warning: converting 'false' to pointer type 'esphome::template_::TemplateSwitch*' [-Wconversion-null]
Input_IO = false;
Can somebody give me a hint/clue in the right direction? I’m unable to find any(clear) documentation regarding how to set switch/number template state directly in main.cpp ( instead of doing trough normal yaml procedure )
Thanks,
Bart