Closed spuder closed 1 year ago
Thank you for providing this code.
I'm trying to set and get the current state_machine state from a lambda.
set
get
I can set the transition from a lambda, but I can't read the state from a lambda.
Setting the transition works:
id(state_machine_mode).transition("ERROR");
However attempting to get the state returns this error
if (id(state_machine_mode).state != "ERROR") { }
error: 'class esphome::state_machine::StateMachineComponent' has no member named 'state'; did you mean 'states_'?
Is it possible to get the state from a lambda? If so what is the syntax
To get the current state from lambda use current_state(), e.g. id(state_machine_mode).current_state()
current_state()
id(state_machine_mode).current_state()
Thank you for providing this code.
I'm trying to
set
andget
the current state_machine state from a lambda.I can set the transition from a lambda, but I can't read the state from a lambda.
Setting the transition works:
However attempting to get the state returns this error
Is it possible to get the state from a lambda? If so what is the syntax