ESPHome Select command allows creating entity that has several optional values, allowing one of them to be selected. Unfortunately it is not well documented, so new users have hard time to make it work.
One would expect that Select component should work as simple as setting up options, and that is it. It should set status based on selection on it’s own. but it does not work that way.
After some struggle I finally got it working and here I am making note (mostly to myself) how to do it, as I am sure I would need it again.
select: - platform: template name: Mode id: mode options: - "OFF" - "ON" - "AUTO" initial_option: "OFF" optimistic: true set_action: - logger.log: format: "Selected option: %s" args: ["x.c_str()"]
I made it work only by using platform:template (which is only platform type I found that is used, I could not find list of other platform types available).
name and id are obvious.
options is list of options that should be available as values. Must be strings.
initial_option sets default value. If omitted, the first element in a list would be default.
optimistic must be set to true if lambda expression is not used in set_action.
If you want to set state of select in action use:
- select.set: id: mode option: "OFF"
If you need to set state in lambda then use:
This is very basic working example. You can find more info at https://esphome.io/components/select/.