12
12
STARTUP_MESSAGE ,
13
13
)
14
14
from homeassistant .const import EVENT_HOMEASSISTANT_START , EVENT_HOMEASSISTANT_STOP
15
- from homeassistant .core import callback
15
+ from homeassistant .core import callback , HomeAssistant , ServiceCall
16
16
import homeassistant .helpers .config_validation as cv
17
- from homeassistant .helpers .typing import ConfigType , HomeAssistantType , ServiceDataType
17
+ from homeassistant .helpers .typing import ConfigType
18
18
from smbus import SMBus
19
19
import voluptuous as vol
20
20
29
29
I2C_ADDRESS = 0x1A
30
30
31
31
32
- async def async_setup (hass : HomeAssistantType , config : ConfigType ) -> bool :
32
+ async def async_setup (hass : HomeAssistant , config : ConfigType ) -> bool :
33
33
"""Set up the Argon40 component."""
34
34
35
35
_LOGGER .info (STARTUP_MESSAGE )
@@ -59,16 +59,16 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
59
59
shutdown_pin = 4
60
60
GPIO .setup (shutdown_pin , GPIO .IN , pull_up_down = GPIO .PUD_DOWN )
61
61
62
- @callback
63
- def event_detect_callback (channel ):
64
- if GPIO .input (shutdown_pin ):
65
- _LOGGER .debug ("Rising edge detected on 4" )
66
- # hass.bus.async_fire("argon40_event", {"key": "pressed"})
67
- else :
68
- _LOGGER .debug ("Falling edge detected on 4" )
69
- hass .bus .async_fire ("argon40_event" , {"action" : "double-tap" })
62
+ # @callback
63
+ # def event_detect_callback(channel):
64
+ # if GPIO.input(shutdown_pin):
65
+ # _LOGGER.debug("Rising edge detected on 4")
66
+ # # hass.bus.async_fire("argon40_event", {"key": "pressed"})
67
+ # else:
68
+ # _LOGGER.debug("Falling edge detected on 4")
69
+ # hass.bus.async_fire("argon40_event", {"action": "double-tap"})
70
70
71
- GPIO .add_event_detect (shutdown_pin , GPIO .BOTH , callback = event_detect_callback )
71
+ # GPIO.add_event_detect(shutdown_pin, GPIO.BOTH, callback=event_detect_callback)
72
72
73
73
bus .write_byte (I2C_ADDRESS , 10 )
74
74
@@ -81,7 +81,7 @@ def event_detect_callback(channel):
81
81
)
82
82
return False
83
83
84
- async def set_fan_speed (service : ServiceDataType ) -> None :
84
+ async def set_fan_speed (service : ServiceCall ) -> None :
85
85
value = service .data .get (ATTR_SPEED_NAME )
86
86
_LOGGER .debug ("Set fan speed to %s" , value )
87
87
bus .write_byte (I2C_ADDRESS , value )
@@ -94,7 +94,7 @@ async def set_fan_speed(service: ServiceDataType) -> None:
94
94
schema = SERVICE_SET_FAN_SPEED_SCHEMA ,
95
95
)
96
96
97
- async def set_mode (service : ServiceDataType ) -> None :
97
+ async def set_mode (service : ServiceCall ) -> None :
98
98
value = service .data .get (ATTR_ALWAYS_ON_NAME )
99
99
_LOGGER .debug ("Set always on mode to %s" , value )
100
100
if value :
0 commit comments