Add new integration for Bond hub (#37477)
* create foundation for Bond integration * add Bond hub integration (fix lint) * Update homeassistant/components/bond/__init__.py adding async_unload_entry per PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * add Bond hub integration (fix missing import after applying PR suggestion) * Update tests/components/bond/test_init.py add a unit for unloading per PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py add unit test for unload per PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * add Bond hub integration (fix formatting) * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/strings.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update requirements_all.txt PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update requirements_test_all.txt PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * add Bond hub integration (remove friendly name from config per PR suggestion) * Update homeassistant/components/bond/__init__.py add per PR review feedback Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/__init__.py remove per PR review feedback Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py fix unit test Co-authored-by: Chris Talkington <chris@talkingtontech.com> Co-authored-by: Chris Talkington <chris@talkingtontech.com>
This commit is contained in:
1 parent
6749424508
commit
9b77e16ffc
18 files changed
+617
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"""Reusable utilities for the Bond component."""
|
||||
|
||||
from typing import List
|
||||
|
||||
from bond import Bond
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
class BondDevice:
|
||||
"""Helper device class to hold ID and attributes together."""
|
||||
|
||||
def __init__(self, device_id: str, attrs: dict):
|
||||
"""Create a helper device from ID and attributes returned by API."""
|
||||
self.device_id = device_id
|
||||
self._attrs = attrs
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Get the name of this device."""
|
||||
return self._attrs["name"]
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
"""Get the type of this device."""
|
||||
return self._attrs["type"]
|
||||
|
||||
|
||||
async def get_bond_devices(hass: HomeAssistant, bond: Bond) -> List[BondDevice]:
|
||||
"""Fetch all available devices using Bond API."""
|
||||
device_ids = await hass.async_add_executor_job(bond.getDeviceIds)
|
||||
devices = [
|
||||
BondDevice(
|
||||
device_id, await hass.async_add_executor_job(bond.getDevice, device_id)
|
||||
)
|
||||
for device_id in device_ids
|
||||
]
|
||||
return devices
|
||||
Reference in new issue
Block a user