ESPHome
2024.11.2
|
This class is used to encode all control actions on a lock device. More...
#include <lock.h>
Public Member Functions | |
LockCall (Lock *parent) | |
LockCall & | set_state (LockState state) |
Set the state of the lock device. More... | |
LockCall & | set_state (optional< LockState > state) |
Set the state of the lock device. More... | |
LockCall & | set_state (const std::string &state) |
Set the state of the lock device based on a string. More... | |
void | perform () |
const optional< LockState > & | get_state () const |
Protected Member Functions | |
void | validate_ () |
Protected Attributes | |
Lock *const | parent_ |
optional< LockState > | state_ |
This class is used to encode all control actions on a lock device.
It is supposed to be used by all code that wishes to control a lock device (mqtt, api, lambda etc). Create an instance of this class by calling id(lock_device).make_call();
. Then set all attributes with the set_x
methods. Finally, to apply the changes call .perform();
.
The integration that implements the lock device receives this instance with the control
method. It should check all the properties it implements and apply them as needed. It should do so by getting all properties it controls with the getter methods in this class. If the optional value is set (check with .has_value()
) that means the user wants to control this property. Get the value of the optional with the star operator (*call.get_state()
) and apply it.
LockCall & esphome::lock::LockCall::set_state | ( | const std::string & | state | ) |