Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion content/components/switch/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ advanced stuff (see the full API Reference for more info).
>
> For example, if you are using a {{< docref "/components/switch/gpio" >}}, calling `publish_state()` will
> not change the GPIO pin level. To do that, you need to call `turn_on()`,
> `turn_off()` or `toggle()`. The same applies to other switch platforms.
> `turn_off()`, `toggle()` or `control()`. The same applies to other switch platforms.

- `state` : Retrieve the current state of the switch.

Expand All @@ -206,6 +206,16 @@ advanced stuff (see the full API Reference for more info).
id(my_switch).toggle();
```

- `control()` : Control the switch state using a boolean parameter.
This provides a unified interface for setting switch state dynamically.

```yaml
// Within lambda, control switch based on a condition
id(my_switch).control(true); // Turn ON
id(my_switch).control(false); // Turn OFF
id(my_switch).control(some_condition); // Set based on condition
```

{{< anchor "switch-on_turn_on_off_trigger" >}}

### `switch.on_turn_on` / `switch.on_turn_off` Trigger
Expand Down