Node-red-node-pi-gpiod true/false vs. 0/1

Hi. Am successfully using the these nodes to control a remote RPi. I noticed that injecting a Boolean true or false raises an Assertion error. Works fine with a numeric 0 or 1. Is this part of the design?

I'll assume you are using the output node. What do you have the type set to?
What pin are you using?
What model of the Pi are you using?

Hi Paul,

Yes, using the output node on gpio 13. Type is Digital Output. Works with 0 or 1 but not true or false. The standard GPIO node works with either. Thanks

Ken Kayser

Tobaccoville, NC

kxkayser@gmail.com

Where do you see the error? It works for me on GPIO 13 (pin 33)
What model Pi?
What OS on the Pi?
What version of NR and node.js

Can you provide your flow?

Hi Paul,

Below is the test flow. I am running on a Pi 3B+, latest Raspbian and NR ver 0.20.7. Thanks.

The error appears in the debug panel as:

8/2/2019, 6:26:40 PMnode: cefa391b.f28498msg : error

"AssertionError [ERR_ASSERTION]: level must be 0 or 1."

[{"id":"cefa391b.f28498","type":"pi-gpiod out","z":"85c5823b.dd7b","name":"","host":"192.168.1.33","port":8888,"pin":"13","set":true,"level":"0","out":"out","sermin":"1000","sermax":"2000","x":580,"y":320,"wires":},{"id":"9f008ee6.20423","type":"inject","z":"85c5823b.dd7b","name":"True","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":240,"wires":[["cefa391b.f28498"]]},{"id":"e3907c91.69413","type":"inject","z":"85c5823b.dd7b","name":"False","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":400,"wires":[["cefa391b.f28498"]]}]

Ken Kayser

Tobaccoville, NC

kxkayser@gmail.com

Your flow can't be imported. Go read How to share code or flow json and then edit your last post

Oh...what gpio node are you using? It's not the standard one is it. node-red-contrib-?????

EDIT: ah ha it is node-red-contrib-gpiod ave you setup the PiGPIO daemon as it says to in the read me? https://flows.nodered.org/node/node-red-node-pi-gpiod

The disadvantage is that you must setup and run the PiGPIO daemon first.

Also is there a reason you can't use the standard gpio node?

Paul, I am using this node because I am controlling a Remote Pi gpio I have the deamon set up on the remote Pi and everything is working except when I try to use Boolean true/false. It works with text values 0 and 1 but the Boolean values would be cleaner. Don’t know if this node was designed like this or not. Can’t find a reference in the documentation. Thanks again.

@dceejay might be able to decide if it is a bug or an error in the documentation.

Can you forward to him? I don’t know how to do it. Thanks

I think the the underlying pigpio code only accepts 0 or 1 as valid states
image

so that is why it gives the error

The code for the pigpio node is copied a lot from the default Pi node and its underlying library is more forgiving of the payload value.

Looking at code for pigpio node - its converting true/false into a number but then actually sends the original msg.payload instead of the converted value.

Quick fix is to alter file
/home/pi/.node-red/node-modules/node-red-node-pi-gpiod/pi-gpiod.js


to use out instead of msg.payload (ignore line number variation)

I'll do some more testing and issue pull-request

1 Like

Good spot.

PR made
..............

Perfect. Thanks so much. Made the change and is working great.

Ken Kayser

Tobaccoville, NC

kxkayser@gmail.com