Change Inverted logic for GPIO Actor

If sensor is set to active, GPIO pin should be high under normal conditions.
If inverted, GPIO pin should be low when sensor is active.
This logic is aligned with the old craftbeerpi3 GPIOSystem plugin
This commit is contained in:
avollkopf 2021-02-07 12:07:48 +01:00
parent 9938ce6de1
commit 9caca9074a

View file

@ -20,17 +20,17 @@ except Exception:
import RPi.GPIO as GPIO
@parameters([Property.Select(label="GPIO", options=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]), Property.Select(label="Inverted", options=["Yes", "No"])])
@parameters([Property.Select(label="GPIO", options=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]), Property.Select(label="Inverted", options=["Yes", "No"],description="No: Active on high; Yes: Active on low")])
class GPIOActor(CBPiActor):
def get_GPIO_state(self, state):
# ON
if state == 1:
return 0 if self.inverted == False else 1
return 1 if self.inverted == False else 0
# OFF
if state == 0:
return 1 if self.inverted == False else 0
return 0 if self.inverted == False else 1
async def start(self):
await super().start()