suptronics / x120x

Python script for UPS shield X1200 X1201 and X1202
1 stars 3 forks source link

'gpiod.Chip' object has no attribute 'get_line' #5

Open vishchoudhary100 opened 3 months ago

vishchoudhary100 commented 3 months ago

When I try to run the merged.py file, it show the error that 'Chip' object has no attribute 'get_line' File "/data/nvme/vscode/pi_status/stats/merged.py", line 55 pld_line = chip.get_line(PLD_PIN)

I am using a Raspberry pi 5 with X1201 UPS board

vishchoudhary100 commented 3 months ago

I solved the issue by using the following code

def get_ac_power_status(): PLD_PIN = 6 with gpiod.request_lines( "/dev/gpiochip4", consumer="get-line-value", config={PLD_PIN: gpiod.LineSettings(direction=Direction.INPUT)}, ) as request: value = request.get_value(PLD_PIN) return True if value == Value.ACTIVE else False