-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First draft of Wyoming satellite * Set up homeassistant in tests * Move satellite * Add devices with binary sensor and select * Add more events * Add satellite enabled switch * Fix mistake * Only set up necessary platforms for satellites * Lots of fixes * Add tests * Use config entry id as satellite id * Initial satellite test * Add satellite pipeline test * More tests * More satellite tests * Only support single device per config entry * Address comments * Make a copy of platforms
- Loading branch information
1 parent
677c50a
commit a9381d2
Showing
28 changed files
with
1,802 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Binary sensor for Wyoming.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from homeassistant.components.binary_sensor import ( | ||
BinarySensorEntity, | ||
BinarySensorEntityDescription, | ||
) | ||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.core import HomeAssistant, callback | ||
from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
|
||
from .const import DOMAIN | ||
from .entity import WyomingSatelliteEntity | ||
|
||
if TYPE_CHECKING: | ||
from .models import DomainDataItem | ||
|
||
|
||
async def async_setup_entry( | ||
hass: HomeAssistant, | ||
config_entry: ConfigEntry, | ||
async_add_entities: AddEntitiesCallback, | ||
) -> None: | ||
"""Set up binary sensor entities.""" | ||
item: DomainDataItem = hass.data[DOMAIN][config_entry.entry_id] | ||
|
||
# Setup is only forwarded for satellites | ||
assert item.satellite is not None | ||
|
||
async_add_entities([WyomingSatelliteAssistInProgress(item.satellite.device)]) | ||
|
||
|
||
class WyomingSatelliteAssistInProgress(WyomingSatelliteEntity, BinarySensorEntity): | ||
"""Entity to represent Assist is in progress for satellite.""" | ||
|
||
entity_description = BinarySensorEntityDescription( | ||
key="assist_in_progress", | ||
translation_key="assist_in_progress", | ||
) | ||
_attr_is_on = False | ||
|
||
async def async_added_to_hass(self) -> None: | ||
"""Call when entity about to be added to hass.""" | ||
await super().async_added_to_hass() | ||
|
||
self._device.set_is_active_listener(self._is_active_changed) | ||
|
||
@callback | ||
def _is_active_changed(self) -> None: | ||
"""Call when active state changed.""" | ||
self._attr_is_on = self._device.is_active | ||
self.async_write_ha_state() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.