Closed whakru closed 1 year ago
I was just trying to set this up with opi zero and it seems there is a few issues with this module. It adds board
and mode
to the config schema but also references old OrangePi.GPIO module as requirement - but uses OPi.GPIO.
I can't see any use for the board
option as there is no setboard
for OPi.GPIO.
mode
needs to be one of [BCM, BOARD, SUNXI, CUSTOM]
Below patch removes the board
setting and fixes requirement module - this works for me. I will try and do a PR later.
--- orangepi.py.orig 2022-10-10 09:44:28.139118027 +1100
+++ orangepi.py 2022-10-10 09:51:30.311322016 +1100
@@ -7,28 +7,9 @@
from ...types import ConfigType, PinType
from . import GenericGPIO, PinDirection, PinPUD
-ALLOWED_BOARDS = [
- "zero",
- "r1",
- "zeroplus",
- "zeroplus2h5",
- "zeroplus2h3",
- "pcpcplus",
- "one",
- "lite",
- "plus2e",
- "pc2",
- "prime",
-]
ALLOWED_MODES = ["bcm", "board", "mode_soc"]
-REQUIREMENTS = ("OrangePi.GPIO",)
+REQUIREMENTS = ("OPi.GPIO",)
CONFIG_SCHEMA = {
- "board": {
- "type": "string",
- "required": True,
- "empty": False,
- "allowed": ALLOWED_BOARDS + list(map(str.upper, ALLOWED_BOARDS)),
- },
"mode": {
"type": "string",
"required": True,
@@ -58,12 +39,7 @@
PinPUD.UP: gpio.PUD_UP,
PinPUD.DOWN: gpio.PUD_DOWN,
}
-
- board = self.config["board"].upper()
mode = self.config["mode"].upper()
- if not hasattr(gpio, board):
- raise AssertionError("%s board not found" % board)
- gpio.setboard(getattr(gpio, board))
gpio.setmode(getattr(gpio, mode))
def setup_pin(
And your config will need to specify mode (which essentially identifies the pin numbering)
gpio_modules:
- name: orangepi
module: orangepi
mode: bcm
Describe the bug i just want to tweak the GPIO on my orange pi 3 lts. Took an example and it doesn't work.
Error messages and traceback
Config
Hardware Orange pi 3 lts
System: Home Assistant 2022.9.6 Supervisor 2022.09.1 Frontend 20220907.2 - latest
Integration MQTT IO Current version: 0.1.3