Skip to content

Commit ef05d69

Browse files
committed
remove GPIO and simplify SMBus (for tests)
1 parent 32293b3 commit ef05d69

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

custom_components/argon40/__init__.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
from typing import Any
44

5-
from RPi import GPIO # pylint: disable=import-error
5+
# from RPi import GPIO # pylint: disable=import-error
66
from custom_components.argon40.const import (
77
ATTR_NAME,
88
DOMAIN,
@@ -29,29 +29,29 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
2929
_LOGGER.info(STARTUP_MESSAGE)
3030

3131
try:
32-
rev = GPIO.RPI_REVISION
33-
if rev == 2 or rev == 3:
34-
bus = SMBus(1)
35-
else:
36-
bus = SMBus(0)
37-
38-
@callback
39-
def cleanup_gpio(event: Any) -> None:
40-
"""Stuff to do before stopping."""
41-
GPIO.cleanup()
42-
43-
# not sure if @callback needed
44-
@callback
45-
def prepare_gpio(event: Any) -> None:
46-
"""Stuff to do when Home Assistant starts."""
47-
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gpio)
48-
49-
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_gpio)
50-
51-
GPIO.setwarnings(False)
52-
GPIO.setmode(GPIO.BCM)
53-
shutdown_pin = 4
54-
GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
32+
# rev = GPIO.RPI_REVISION
33+
# if rev == 2 or rev == 3:
34+
bus = SMBus(1)
35+
# else:
36+
# bus = SMBus(0)
37+
38+
# @callback
39+
# def cleanup_gpio(event: Any) -> None:
40+
# """Stuff to do before stopping."""
41+
# GPIO.cleanup()
42+
43+
# # not sure if @callback needed
44+
# @callback
45+
# def prepare_gpio(event: Any) -> None:
46+
# """Stuff to do when Home Assistant starts."""
47+
# hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gpio)
48+
49+
# hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_gpio)
50+
51+
# GPIO.setwarnings(False)
52+
# GPIO.setmode(GPIO.BCM)
53+
# shutdown_pin = 4
54+
# GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
5555

5656
address = 0x1A
5757
bus.write_byte(address, 10)
@@ -63,7 +63,7 @@ def prepare_gpio(event: Any) -> None:
6363
err.strerror,
6464
address,
6565
)
66-
pass
66+
return False
6767

6868
async def set_fan_speed(service: ServiceDataType) -> None:
6969
value = service.data.get(ATTR_NAME)

custom_components/argon40/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"@Misiu"
99
],
1010
"requirements": [
11-
"smbus-cffi==0.5.1",
12-
"RPi.GPIO==0.7.0"
11+
"smbus-cffi==0.5.1"
1312
]
1413
}

0 commit comments

Comments
 (0)