sensorReporter icon indicating copy to clipboard operation
sensorReporter copied to clipboard

Btn_Pressed_State not optional when PUD is DOWN

Open rkoshak opened this issue 2 years ago • 2 comments

The advanced parameter for GPIO Sensor Btn_Pressed_State is not optional when PUD is set to DOWN.

rkoshak avatar Oct 25 '22 19:10 rkoshak

I'd expect Btn_Pressed_State to be optional regardless of the configuration of PUD The default value for PUD is DOWN (line 95):

pud = GPIO.PUD_UP if dev_cfg["PUD"] == "UP" else GPIO.PUD_DOWN

so it shouldn't make a difference if it is configured to DOWN or not present in the config. Is there a runtime exception when configured as you describe?

DanielDecker avatar Oct 29 '22 15:10 DanielDecker

I looked into this with my test system. I found 2 runtime exceptions:

  • AttributeError: 'RpiGpioSensor' object has no attribute 'pud' Triggers when Btn_Pressed_State is not defined, just as you describe.
  • Also if PUD is not in the config I get a KeyError: 'PUD', as I recall PUD should be optional.

I'll fix both with my next PR!

DanielDecker avatar Oct 31 '22 09:10 DanielDecker