Home Assistant Unofficial Reference 2024.12.1
util.py
Go to the documentation of this file.
1 """Useful functions for the IHC component."""
2 
3 import asyncio
4 
5 from ihcsdk.ihccontroller import IHCController
6 
7 from homeassistant.core import HomeAssistant, callback
8 
9 
10 async def async_pulse(
11  hass: HomeAssistant, ihc_controller: IHCController, ihc_id: int
12 ) -> None:
13  """Send a short on/off pulse to an IHC controller resource."""
14  await async_set_bool(hass, ihc_controller, ihc_id, True)
15  await asyncio.sleep(0.1)
16  await async_set_bool(hass, ihc_controller, ihc_id, False)
17 
18 
19 @callback
21  hass: HomeAssistant, ihc_controller: IHCController, ihc_id: int, value: bool
22 ) -> asyncio.Future[bool]:
23  """Set a bool value on an IHC controller resource."""
24  return hass.async_add_executor_job(
25  ihc_controller.set_runtime_value_bool, ihc_id, value
26  )
27 
28 
29 @callback
31  hass: HomeAssistant, ihc_controller: IHCController, ihc_id: int, value: int
32 ) -> asyncio.Future[bool]:
33  """Set a int value on an IHC controller resource."""
34  return hass.async_add_executor_job(
35  ihc_controller.set_runtime_value_int, ihc_id, value
36  )
37 
38 
39 @callback
41  hass: HomeAssistant, ihc_controller: IHCController, ihc_id: int, value: float
42 ) -> asyncio.Future[bool]:
43  """Set a float value on an IHC controller resource."""
44  return hass.async_add_executor_job(
45  ihc_controller.set_runtime_value_float, ihc_id, value
46  )
asyncio.Future[bool] async_set_float(HomeAssistant hass, IHCController ihc_controller, int ihc_id, float value)
Definition: util.py:42
None async_pulse(HomeAssistant hass, IHCController ihc_controller, int ihc_id)
Definition: util.py:12
asyncio.Future[bool] async_set_int(HomeAssistant hass, IHCController ihc_controller, int ihc_id, int value)
Definition: util.py:32
asyncio.Future[bool] async_set_bool(HomeAssistant hass, IHCController ihc_controller, int ihc_id, bool value)
Definition: util.py:22