mirror of
https://github.com/thecode/ha-rpi_gpio.git
synced 2025-08-02 15:37:44 +00:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e38a45ade9 | ||
![]() |
0383c19d77 | ||
![]() |
f9aa9b0485 | ||
![]() |
49b06ffa84 | ||
![]() |
94f5e1ba18 | ||
![]() |
a9f904da77 | ||
![]() |
7449569925 | ||
![]() |
81c89d0385 | ||
![]() |
e5a86e2593 | ||
![]() |
7a07346934 | ||
![]() |
2890971f59 | ||
![]() |
831af93917 | ||
![]() |
fedab2a3c7 | ||
![]() |
89eb52ee56 | ||
![]() |
003993a3e5 | ||
![]() |
797a4522e4 | ||
![]() |
df4788feba | ||
![]() |
974a66e7c5 | ||
![]() |
1bbefe1f7b | ||
![]() |
3400619946 | ||
![]() |
bdfac26fae | ||
![]() |
fa42ae379e | ||
![]() |
7c0d121839 | ||
![]() |
c894d86b8a | ||
![]() |
88fc778a13 | ||
![]() |
242bad8b82 |
2
.github/workflows/stale.yaml
vendored
2
.github/workflows/stale.yaml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 🚀 Run stale
|
- name: 🚀 Run stale
|
||||||
uses: actions/stale@v9.0.0
|
uses: actions/stale@v9.1.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
days-before-stale: 14
|
days-before-stale: 14
|
||||||
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v5.3.0
|
uses: actions/setup-python@v5.6.0
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
@ -210,4 +210,4 @@ switch:
|
|||||||
```
|
```
|
||||||
|
|
||||||
# Reporting issues
|
# Reporting issues
|
||||||
*Before* reporting issues please enable debug logging as described [here](https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging), check logs and report issue attaching the log file.
|
*Before* reporting issues please enable debug logging as described [here](https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging), check logs and report issue attaching the log file and the relevant YAML section.
|
||||||
|
@ -52,17 +52,20 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
sensors = []
|
sensors = []
|
||||||
for sensor in config.get(CONF_SENSORS):
|
for sensor in config.get(CONF_SENSORS):
|
||||||
sensors.append(
|
try:
|
||||||
GPIODBinarySensor(
|
sensors.append(
|
||||||
hub,
|
GPIODBinarySensor(
|
||||||
sensor[CONF_NAME],
|
hub,
|
||||||
sensor[CONF_PORT],
|
sensor[CONF_NAME],
|
||||||
sensor.get(CONF_UNIQUE_ID) or f"{DOMAIN}_{sensor[CONF_PORT]}_{sensor[CONF_NAME].lower().replace(' ', '_')}",
|
sensor[CONF_PORT],
|
||||||
sensor.get(CONF_INVERT_LOGIC),
|
sensor.get(CONF_UNIQUE_ID) or f"{DOMAIN}_{sensor[CONF_PORT]}_{sensor[CONF_NAME].lower().replace(' ', '_')}",
|
||||||
sensor.get(CONF_PULL_MODE),
|
sensor.get(CONF_INVERT_LOGIC),
|
||||||
sensor.get(CONF_BOUNCETIME)
|
sensor.get(CONF_PULL_MODE),
|
||||||
|
sensor.get(CONF_BOUNCETIME)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
_LOGGER.error(f"Failed to add binary sensor {sensor[CONF_NAME]} for port {sensor[CONF_PORT]}: {e}")
|
||||||
|
|
||||||
async_add_entities(sensors)
|
async_add_entities(sensors)
|
||||||
|
|
||||||
|
@ -71,21 +71,24 @@ async def async_setup_platform(
|
|||||||
invert_relay = config[CONF_INVERT_RELAY]
|
invert_relay = config[CONF_INVERT_RELAY]
|
||||||
covers = []
|
covers = []
|
||||||
for cover in config.get(CONF_COVERS):
|
for cover in config.get(CONF_COVERS):
|
||||||
covers.append(
|
try:
|
||||||
GPIODCover(
|
covers.append(
|
||||||
hub,
|
GPIODCover(
|
||||||
cover[CONF_NAME],
|
hub,
|
||||||
cover.get(CONF_RELAY_PIN),
|
cover[CONF_NAME],
|
||||||
relay_time,
|
cover.get(CONF_RELAY_PIN),
|
||||||
invert_relay,
|
relay_time,
|
||||||
"AS_IS",
|
invert_relay,
|
||||||
"PUSH_PULL",
|
"AS_IS",
|
||||||
cover.get(CONF_STATE_PIN),
|
"PUSH_PULL",
|
||||||
state_pull_mode,
|
cover.get(CONF_STATE_PIN),
|
||||||
invert_state,
|
state_pull_mode,
|
||||||
cover.get(CONF_UNIQUE_ID) or f"{DOMAIN}_{cover.get(CONF_RELAY_PIN)}_{cover[CONF_NAME].lower().replace(' ', '_')}",
|
invert_state,
|
||||||
|
cover.get(CONF_UNIQUE_ID) or f"{DOMAIN}_{cover.get(CONF_RELAY_PIN)}_{cover[CONF_NAME].lower().replace(' ', '_')}",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
_LOGGER.error(f"Failed to add cover {cover[CONF_NAME]} for port {cover.get(CONF_RELAY_PIN)}:{cover.get(CONF_STATE_PIN)}: {e}")
|
||||||
|
|
||||||
async_add_entities(covers)
|
async_add_entities(covers)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_START
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_START
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError,ServiceValidationError
|
||||||
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@ -73,6 +73,7 @@ class Hub:
|
|||||||
_LOGGER.debug(f"verify_gpiochip: {path} is a gpiochip_device")
|
_LOGGER.debug(f"verify_gpiochip: {path} is a gpiochip_device")
|
||||||
self._chip = gpiod.Chip(path)
|
self._chip = gpiod.Chip(path)
|
||||||
info = self._chip.get_info()
|
info = self._chip.get_info()
|
||||||
|
_LOGGER.debug(f"verify_gpiochip: {path} info is: {info}")
|
||||||
if not "pinctrl" in info.label:
|
if not "pinctrl" in info.label:
|
||||||
_LOGGER.debug(f"verify_gpiochip: {path} no pinctrl {info.label}")
|
_LOGGER.debug(f"verify_gpiochip: {path} no pinctrl {info.label}")
|
||||||
return False
|
return False
|
||||||
@ -82,10 +83,12 @@ class Hub:
|
|||||||
|
|
||||||
def verify_port_ready(self, port: int):
|
def verify_port_ready(self, port: int):
|
||||||
info = self._chip.get_line_info(port)
|
info = self._chip.get_line_info(port)
|
||||||
_LOGGER.debug(f"original port info: {info}")
|
_LOGGER.debug(f"original port {port} info: {info}")
|
||||||
if info.used and info.consumer != DOMAIN:
|
if info.used:
|
||||||
_LOGGER.error(f"Port {port} already in use by {info.consumer}")
|
if info.consumer != DOMAIN:
|
||||||
raise HomeAssistantError(f"Port {port} already in use by {info.consumer}")
|
raise HomeAssistantError(f"Port {port} already in use by {info.consumer}")
|
||||||
|
else:
|
||||||
|
raise HomeAssistantError(f"Port {port} already in use by another entity, check your config for duplicates port usage")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hub_id(self) -> str:
|
def hub_id(self) -> str:
|
||||||
@ -100,11 +103,11 @@ class Hub:
|
|||||||
line_request = self._chip.request_lines(
|
line_request = self._chip.request_lines(
|
||||||
consumer=DOMAIN,
|
consumer=DOMAIN,
|
||||||
config={port: gpiod.LineSettings(
|
config={port: gpiod.LineSettings(
|
||||||
direction = Direction.OUTPUT,
|
direction = Direction.OUTPUT,
|
||||||
bias = BIAS[bias],
|
bias = BIAS[bias],
|
||||||
drive = DRIVE[drive_mode],
|
drive = DRIVE[drive_mode],
|
||||||
active_low = active_low,
|
active_low = active_low,
|
||||||
output_value = Value.ACTIVE if init_state is not None and init_state else Value.INACTIVE)})
|
output_value = Value.ACTIVE if init_state is not None and init_state else Value.INACTIVE)})
|
||||||
_LOGGER.debug(f"add_switch line_request: {line_request}")
|
_LOGGER.debug(f"add_switch line_request: {line_request}")
|
||||||
return line_request
|
return line_request
|
||||||
|
|
||||||
@ -132,9 +135,9 @@ class Hub:
|
|||||||
active_low = active_low,
|
active_low = active_low,
|
||||||
debounce_period = timedelta(milliseconds=debounce),
|
debounce_period = timedelta(milliseconds=debounce),
|
||||||
event_clock = Clock.REALTIME)})
|
event_clock = Clock.REALTIME)})
|
||||||
|
_LOGGER.debug(f"add_sensor line_request: {line_request}")
|
||||||
current_is_on = True if line_request.get_value(port) == Value.ACTIVE else False
|
current_is_on = True if line_request.get_value(port) == Value.ACTIVE else False
|
||||||
_LOGGER.debug(f"add_sensor line_request: {line_request}. current state: {current_is_on}")
|
_LOGGER.debug(f"add_sensor current state: {current_is_on}")
|
||||||
return line_request, current_is_on
|
return line_request, current_is_on
|
||||||
|
|
||||||
def add_cover(self, relay_port, relay_active_low, relay_bias, relay_drive,
|
def add_cover(self, relay_port, relay_active_low, relay_bias, relay_drive,
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"issue_tracker": "https://github.com/thecode/ha-rpi_gpio/issues",
|
"issue_tracker": "https://github.com/thecode/ha-rpi_gpio/issues",
|
||||||
"requirements": [ "gpiod>=2.2.1" ],
|
"requirements": [ "gpiod>=2.2.1" ],
|
||||||
"version": "2024.12.2"
|
"version": "2025.2.1"
|
||||||
}
|
}
|
||||||
|
@ -56,18 +56,21 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
switches = []
|
switches = []
|
||||||
for switch in config.get(CONF_SWITCHES):
|
for switch in config.get(CONF_SWITCHES):
|
||||||
switches.append(
|
try:
|
||||||
GPIODSwitch(
|
switches.append(
|
||||||
hub,
|
GPIODSwitch(
|
||||||
switch[CONF_NAME],
|
hub,
|
||||||
switch[CONF_PORT],
|
switch[CONF_NAME],
|
||||||
switch.get(CONF_UNIQUE_ID) or f"{DOMAIN}_{switch[CONF_PORT]}_{switch[CONF_NAME].lower().replace(' ', '_')}",
|
switch[CONF_PORT],
|
||||||
switch.get(CONF_INVERT_LOGIC),
|
switch.get(CONF_UNIQUE_ID) or f"{DOMAIN}_{switch[CONF_PORT]}_{switch[CONF_NAME].lower().replace(' ', '_')}",
|
||||||
switch.get(CONF_PULL_MODE),
|
switch.get(CONF_INVERT_LOGIC),
|
||||||
switch.get(CONF_DRIVE),
|
switch.get(CONF_PULL_MODE),
|
||||||
switch[CONF_PERSISTENT]
|
switch.get(CONF_DRIVE),
|
||||||
|
switch[CONF_PERSISTENT]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
_LOGGER.error(f"Failed to add switch {switch[CONF_NAME]} for port {switch[CONF_PORT]}: {e}")
|
||||||
|
|
||||||
async_add_entities(switches)
|
async_add_entities(switches)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
black==24.10.0
|
black==25.1.0
|
||||||
flake8==7.1.1
|
flake8==7.3.0
|
||||||
isort==5.13.2
|
isort==6.0.1
|
||||||
mypy==1.14.0
|
mypy==1.17.0
|
||||||
pre-commit==4.0.1
|
pre-commit==4.2.0
|
||||||
pydocstyle==6.3.0
|
pydocstyle==6.3.0
|
||||||
pylint==3.3.2
|
pylint==3.3.7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user