# Toggle Switch link to integer tag

**URL:** <https://forum.inductiveautomation.com/t/toggle-switch-link-to-integer-tag/96692>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 2, 2024, 2:34am UTC](https://forum.inductiveautomation.com/t/toggle-switch-link-to-integer-tag/96692 "2024-10-02T02:34:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amir\_Baghaki](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Amir\_Baghaki](https://forum.inductiveautomation.com/u/Amir_Baghaki)\
**Post date:** [October 2, 2024, 2:34am UTC](https://forum.inductiveautomation.com/t/toggle-switch-link-to-integer-tag/96692/1 "2024-10-02T02:34:05Z")

</div>

Hello everyone,

Thank you in advance for your time and insights on this topic. I am looking to control an integer tag on a PLC that represents different modes of program operation, with values ranging from 1 to 5. Specifically, a value of 2 indicates "Manual Mode."

I need to implement a toggle switch on the user interface that allows users to switch between "Auto" and "Manual." The desired behavior is as follows:

- When the tag is set to 2, the toggle switch should indicate "Manual."
- When the tag is set to 1, 3, 4, or 5, the toggle switch should indicate "Auto."

Additionally, I require this link to be bi-directional:

- If the toggle switch is set to "Auto" and you change it to "Manual," the tag should set to 2.
- Conversely, if the toggle switch is set to "Manual" and you change it to "Auto," the tag should set to 1.

I would appreciate any guidance on the best approach to establish this functionality.

Thank you!

---

<div class="post-metadata">

**Author:** ![Victor\_Anderson](https://avatars.discourse-cdn.com/v4/letter/v/b19c9b/32.png) [@Victor\_Anderson](https://forum.inductiveautomation.com/u/Victor_Anderson)\
**Post date:** [October 2, 2024, 5:58am UTC](https://forum.inductiveautomation.com/t/toggle-switch-link-to-integer-tag/96692/2 "2024-10-02T05:58:22Z")

</div>

Use a multi-state button.  
Use two states, one with text Manual and value 2, one with text Auto and value 1

For the controlValue bind this to your tag with Bidirectional set to true.  
For the indicatorValue, bind it to your tag, add transform, select script, use this script

```python
def transform(self, value, quality, timestamp):
	if value > 2:
		return 1
	return value

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 2, 2024, 8:03am UTC](https://forum.inductiveautomation.com/t/toggle-switch-link-to-integer-tag/96692/3 "2024-10-02T08:03:40Z")

</div>

I agree that a multistate button is the appropriate component for this.

However, I'd change the `indicatorValue` binding to an expression binding:

```python
if ({this.props.controlValue} = 2, 2, 1)

```

---

<div class="post-metadata">

**Author:** ![Amir\_Baghaki](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Amir\_Baghaki](https://forum.inductiveautomation.com/u/Amir_Baghaki)\
**Post date:** [October 2, 2024, 11:10am UTC](https://forum.inductiveautomation.com/t/toggle-switch-link-to-integer-tag/96692/4 "2024-10-02T11:10:56Z")

</div>

Thanks Victor, works the best!  
I appreciate it.

---

<div class="post-metadata">

**Author:** ![Amir\_Baghaki](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Amir\_Baghaki](https://forum.inductiveautomation.com/u/Amir_Baghaki)\
**Post date:** [October 2, 2024, 11:11am UTC](https://forum.inductiveautomation.com/t/toggle-switch-link-to-integer-tag/96692/5 "2024-10-02T11:11:54Z")

</div>

Thanks Pascal for the hint. I'll use it.
