Wizard script is easiest to describe, but I always opt for C#. The first step is to set your GPIO input and output pins to modules so you can reference them.
Trigger:
Navigate to the correct GPIO and select ON
Run code:
Navigate to the Switch1 and select ON
For OFF, just do the same with the opposite command.
For C#:
Trigger: run when evaluates true
return true;
Run:
When.ModuleParameterIsChanging((module, parameter) =>
{
if (module.Instance.Name=="GPIO_sensor" && parameter.Name=="Status.Level" && parameter.Value=="1")
{
Modules.WithName("GPIO_switch").On();
}
else if (module.Instance.Name=="GPIO_sensor" && parameter.Name=="Status.Level" && parameter.Value=="0")
{
Modules.WithName("GPIO_switch").Off();
}
return true;
});
Program.GoBackground();
When I perform this type of task, I usually use the "When.ModuleParameterIsChanging" code. However, since you are looking for a specific GPIO state change, you should be able to add that to the trigger side. I do not know how the 3 approaches compare as far as computing overhead.