Hi
I will try to describe it better in this example:
removing the Output SW with the Things configuration:
before things file:
Channels:
// Heizung
Type pigpio-digital-output : GPIO-output-27 [ gpioId=27, invert=true]
after things file:
Channels:
// Heizung
// Type pigpio-digital-output : GPIO-output-27 [ gpioId=27, invert=true]
Items config - SW with the same name:
before Items file:
Switch GpioOutput02 {channel=“gpio:pigpio-remote:GPIO-pi-1:GPIO-output-02”}
after things file:
Switch GpioOutput02
// {channel=“gpio:pigpio-remote:GPIO-pi-1:GPIO-output-02”}
new Rules
(control GPIO 27 switching On/Off):
rule "GpioOutput02"
// GPIO 27 On-OFF
when
Item GpioOutput02 changed
then
if(GpioOutput02.state == ON ){
executeCommandLine("/home/openhabian/GpioOut02On.sh")
logInfo("set.rules", "GpioOutput02 is On")
}
else {
executeCommandLine("/home/openhabian/GpioOut02Off.sh")
logInfo("set.rules", "GpioOutput02 is Off")
}
end
ssh to OpenHAB
sudo nano /home/openhabian/GpioOut02On.sh
Type:
pigs w 27 1
Ctrl x
Y (Save file)
Type:
sudo chmod 755 /home/openhabian/GpioOut02On.sh
Similar for Off:
sudo nano /home/openhabian/GpioOut02Off.sh
Type:
pigs w 27 0
Ctrl x
Y (Save file)
Type:
sudo chmod 755 /home/openhabian/GpioOut02Off.sh
sudo reboot
After restart, GPIO 27 (Item GpioOutput02) does not switch to ON.
At the first request to change the state of GpioOut02, the GpioOut02-Relay is switched via the GpioOut02On.sh or GpioOut02Off.sh script.
Note:
For non-inverted relays it is necessary to change the command in GpioOut02Off.sh and GpioOut02On.sh file.
Maybe I explained it in more detail and
I hope it helped …