1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Add separate on/off ids on manual configured IHC lights (#20253)

* Add support for separate on/off ids on manual configured IHC lights.
This makes it easier to support IHC code units thats relies on being
turned on and off through specific inputs.
Also adds a pulse service (ihc.pulse) that supports sending a short on/off pulse to an IHC input.

* Fix

* Lint fix

* Add on/off id support in switch

* Make pulse async

* Code review fixes
This commit is contained in:
msvinth
2019-03-01 08:17:59 +01:00
committed by Martin Hjelmare
parent ee4be13bda
commit 0aba49adce
6 changed files with 109 additions and 23 deletions

View File

@@ -0,0 +1,22 @@
"""Useful functions for the IHC component."""
import asyncio
async def async_pulse(hass, ihc_controller, ihc_id: int):
"""Send a short on/off pulse to an IHC controller resource."""
await async_set_bool(hass, ihc_controller, ihc_id, True)
await asyncio.sleep(0.1)
await async_set_bool(hass, ihc_controller, ihc_id, False)
def async_set_bool(hass, ihc_controller, ihc_id: int, value: bool):
"""Set a bool value on an IHC controller resource."""
return hass.async_add_executor_job(ihc_controller.set_runtime_value_bool,
ihc_id, value)
def async_set_int(hass, ihc_controller, ihc_id: int, value: int):
"""Set a int value on an IHC controller resource."""
return hass.async_add_executor_job(ihc_controller.set_runtime_value_int,
ihc_id, value)