-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add Honeywell String Lights integration #168450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
da090bc
Add honeywell_string_lights integration
balloob ebef8d8
Re-use fixtures from rf integration
balloob 922f31a
Address comments
balloob aa9b932
Remove device name
balloob f6ebc42
gen_requirements_all
balloob b0028a9
use async_load_command
balloob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "domain": "honeywell", | ||
| "name": "Honeywell", | ||
| "integrations": ["lyric", "evohome", "honeywell"] | ||
| "integrations": ["lyric", "evohome", "honeywell", "honeywell_string_lights"] | ||
| } |
20 changes: 20 additions & 0 deletions
20
homeassistant/components/honeywell_string_lights/__init__.py
This file contains hidden or 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,20 @@ | ||
| """The Honeywell String Lights integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import Platform | ||
| from homeassistant.core import HomeAssistant | ||
|
|
||
| PLATFORMS: list[Platform] = [Platform.LIGHT] | ||
|
|
||
|
|
||
| async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: | ||
| """Set up Honeywell String Lights from a config entry.""" | ||
| await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) | ||
| return True | ||
|
|
||
|
|
||
| async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: | ||
| """Unload a config entry.""" | ||
| return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) |
61 changes: 61 additions & 0 deletions
61
homeassistant/components/honeywell_string_lights/config_flow.py
This file contains hidden or 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,61 @@ | ||
| """Config flow for the Honeywell String Lights integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from rf_protocols import RadioFrequencyCommand | ||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.components.radio_frequency import async_get_transmitters | ||
| from homeassistant.config_entries import ConfigFlow, ConfigFlowResult | ||
| from homeassistant.exceptions import HomeAssistantError | ||
| from homeassistant.helpers import entity_registry as er, selector | ||
|
|
||
| from .const import CONF_TRANSMITTER, DOMAIN | ||
| from .light import COMMANDS | ||
|
|
||
|
|
||
| class HoneywellStringLightsConfigFlow(ConfigFlow, domain=DOMAIN): | ||
| """Handle a config flow for Honeywell String Lights.""" | ||
|
|
||
| VERSION = 1 | ||
|
|
||
| async def async_step_user( | ||
| self, user_input: dict[str, Any] | None = None | ||
| ) -> ConfigFlowResult: | ||
| """Handle the initial step.""" | ||
| sample_command: RadioFrequencyCommand = await self.hass.async_add_executor_job( | ||
| COMMANDS.load_command, "turn_on" | ||
| ) | ||
| try: | ||
| transmitters = async_get_transmitters( | ||
| self.hass, sample_command.frequency, sample_command.modulation | ||
| ) | ||
| except HomeAssistantError: | ||
| return self.async_abort(reason="no_transmitters") | ||
|
|
||
| if not transmitters: | ||
| return self.async_abort(reason="no_compatible_transmitters") | ||
|
|
||
| if user_input is not None: | ||
| registry = er.async_get(self.hass) | ||
| entity_entry = registry.async_get(user_input[CONF_TRANSMITTER]) | ||
| assert entity_entry is not None | ||
| await self.async_set_unique_id(entity_entry.id) | ||
| self._abort_if_unique_id_configured() | ||
| return self.async_create_entry( | ||
| title="Honeywell String Lights", | ||
| data={CONF_TRANSMITTER: entity_entry.id}, | ||
| ) | ||
|
|
||
| return self.async_show_form( | ||
| step_id="user", | ||
| data_schema=vol.Schema( | ||
| { | ||
| vol.Required(CONF_TRANSMITTER): selector.EntitySelector( | ||
| selector.EntitySelectorConfig(include_entities=transmitters), | ||
| ), | ||
| } | ||
| ), | ||
| ) | ||
This file contains hidden or 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,9 @@ | ||
| """Constants for the Honeywell String Lights integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Final | ||
|
|
||
| DOMAIN: Final = "honeywell_string_lights" | ||
|
|
||
| CONF_TRANSMITTER: Final = "transmitter" |
76 changes: 76 additions & 0 deletions
76
homeassistant/components/honeywell_string_lights/entity.py
This file contains hidden or 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,76 @@ | ||
| """Common entity for Honeywell String Lights integration.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
|
|
||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import STATE_UNAVAILABLE | ||
| from homeassistant.core import Event, EventStateChangedData, callback | ||
| from homeassistant.helpers import entity_registry as er | ||
| from homeassistant.helpers.device_registry import DeviceInfo | ||
| from homeassistant.helpers.entity import Entity | ||
| from homeassistant.helpers.event import async_track_state_change_event | ||
|
|
||
| from .const import CONF_TRANSMITTER, DOMAIN | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class HoneywellStringLightsEntity(Entity): | ||
| """Honeywell String Lights base entity.""" | ||
|
|
||
| _attr_has_entity_name = True | ||
|
|
||
| def __init__(self, entry: ConfigEntry) -> None: | ||
| """Initialize the entity.""" | ||
| self._transmitter = entry.data[CONF_TRANSMITTER] | ||
| self._attr_unique_id = entry.entry_id | ||
| self._attr_device_info = DeviceInfo( | ||
| identifiers={(DOMAIN, entry.entry_id)}, | ||
|
balloob marked this conversation as resolved.
|
||
| manufacturer="Honeywell", | ||
| model="String Lights", | ||
| ) | ||
|
balloob marked this conversation as resolved.
|
||
|
|
||
| async def async_added_to_hass(self) -> None: | ||
| """Subscribe to transmitter entity state changes.""" | ||
| await super().async_added_to_hass() | ||
|
|
||
| transmitter_entity_id = er.async_validate_entity_id( | ||
| er.async_get(self.hass), self._transmitter | ||
| ) | ||
|
balloob marked this conversation as resolved.
|
||
|
|
||
| @callback | ||
| def _async_transmitter_state_changed( | ||
| event: Event[EventStateChangedData], | ||
| ) -> None: | ||
| """Handle transmitter entity state changes.""" | ||
| new_state = event.data["new_state"] | ||
| transmitter_available = ( | ||
| new_state is not None and new_state.state != STATE_UNAVAILABLE | ||
| ) | ||
| if transmitter_available != self.available: | ||
| _LOGGER.info( | ||
| "Transmitter %s used by %s is %s", | ||
| transmitter_entity_id, | ||
| self.entity_id, | ||
| "available" if transmitter_available else "unavailable", | ||
| ) | ||
|
|
||
| self._attr_available = transmitter_available | ||
| self.async_write_ha_state() | ||
|
|
||
| self.async_on_remove( | ||
| async_track_state_change_event( | ||
| self.hass, | ||
| [transmitter_entity_id], | ||
| _async_transmitter_state_changed, | ||
| ) | ||
| ) | ||
|
|
||
| # Set initial availability based on current transmitter entity state | ||
| transmitter_state = self.hass.states.get(transmitter_entity_id) | ||
| self._attr_available = ( | ||
| transmitter_state is not None | ||
| and transmitter_state.state != STATE_UNAVAILABLE | ||
| ) | ||
This file contains hidden or 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,65 @@ | ||
| """Light platform for Honeywell String Lights.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from rf_protocols import get_codes | ||
|
|
||
| from homeassistant.components.light import ColorMode, LightEntity | ||
| from homeassistant.components.radio_frequency import async_send_command | ||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import STATE_ON | ||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback | ||
| from homeassistant.helpers.restore_state import RestoreEntity | ||
|
|
||
| from .entity import HoneywellStringLightsEntity | ||
|
|
||
| PARALLEL_UPDATES = 1 | ||
|
|
||
| COMMANDS = get_codes("honeywell/string_lights") | ||
|
|
||
|
|
||
| async def async_setup_entry( | ||
| hass: HomeAssistant, | ||
| config_entry: ConfigEntry, | ||
| async_add_entities: AddConfigEntryEntitiesCallback, | ||
| ) -> None: | ||
| """Set up the Honeywell String Lights light platform.""" | ||
| async_add_entities([HoneywellStringLight(config_entry)]) | ||
|
|
||
|
|
||
| class HoneywellStringLight(HoneywellStringLightsEntity, LightEntity, RestoreEntity): | ||
| """Representation of a Honeywell String Lights set controlled via RF.""" | ||
|
|
||
| _attr_assumed_state = True | ||
| _attr_color_mode = ColorMode.ONOFF | ||
| _attr_supported_color_modes = {ColorMode.ONOFF} | ||
| _attr_name = None | ||
| _attr_should_poll = False | ||
|
|
||
| async def async_added_to_hass(self) -> None: | ||
| """Restore last known state.""" | ||
| await super().async_added_to_hass() | ||
| if (last_state := await self.async_get_last_state()) is not None: | ||
| self._attr_is_on = last_state.state == STATE_ON | ||
|
|
||
| async def async_turn_on(self, **kwargs: Any) -> None: | ||
| """Turn on the light.""" | ||
| await self._async_send_command("turn_on") | ||
| self._attr_is_on = True | ||
| self.async_write_ha_state() | ||
|
|
||
| async def async_turn_off(self, **kwargs: Any) -> None: | ||
| """Turn off the light.""" | ||
| await self._async_send_command("turn_off") | ||
| self._attr_is_on = False | ||
| self.async_write_ha_state() | ||
|
|
||
| async def _async_send_command(self, name: str) -> None: | ||
| """Load the named command and send it via the configured transmitter.""" | ||
| command = await COMMANDS.async_load_command(name) | ||
| await async_send_command( | ||
| self.hass, self._transmitter, command, context=self._context | ||
| ) |
12 changes: 12 additions & 0 deletions
12
homeassistant/components/honeywell_string_lights/manifest.json
This file contains hidden or 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,12 @@ | ||
| { | ||
| "domain": "honeywell_string_lights", | ||
| "name": "Honeywell String Lights", | ||
| "codeowners": ["@balloob"], | ||
| "config_flow": true, | ||
| "dependencies": ["radio_frequency"], | ||
| "documentation": "https://www.home-assistant.io/integrations/honeywell_string_lights", | ||
| "integration_type": "device", | ||
| "iot_class": "assumed_state", | ||
| "quality_scale": "bronze", | ||
| "requirements": ["rf-protocols==2.1.0"] | ||
| } |
124 changes: 124 additions & 0 deletions
124
homeassistant/components/honeywell_string_lights/quality_scale.yaml
This file contains hidden or 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,124 @@ | ||
| rules: | ||
| # Bronze | ||
| action-setup: | ||
| status: exempt | ||
| comment: | | ||
| This integration does not register custom service actions. | ||
| appropriate-polling: | ||
| status: exempt | ||
| comment: | | ||
| This integration transmits RF commands and does not poll. | ||
| brands: done | ||
| common-modules: done | ||
| config-flow-test-coverage: done | ||
| config-flow: done | ||
| dependency-transparency: done | ||
| docs-actions: | ||
| status: exempt | ||
| comment: | | ||
| This integration does not register custom service actions. | ||
| docs-high-level-description: done | ||
| docs-installation-instructions: done | ||
| docs-removal-instructions: done | ||
| entity-event-setup: done | ||
| entity-unique-id: done | ||
| has-entity-name: done | ||
| runtime-data: | ||
| status: exempt | ||
| comment: | | ||
| This integration does not use runtime data. | ||
| test-before-configure: | ||
| status: exempt | ||
| comment: | | ||
| RF transmission is a one-way broadcast with no device to contact. | ||
| test-before-setup: | ||
| status: exempt | ||
| comment: | | ||
| RF transmission is a one-way broadcast with no device to contact. | ||
| unique-config-entry: done | ||
| # Silver | ||
| action-exceptions: done | ||
| config-entry-unloading: done | ||
| docs-configuration-parameters: | ||
| status: exempt | ||
| comment: | | ||
| This integration has no options. | ||
| docs-installation-parameters: todo | ||
| entity-unavailable: | ||
| status: exempt | ||
| comment: | | ||
| RF transmission is a one-way broadcast; the light uses assumed state. | ||
| integration-owner: done | ||
| log-when-unavailable: | ||
| status: exempt | ||
| comment: | | ||
| RF transmission is a one-way broadcast; the light uses assumed state. | ||
| parallel-updates: done | ||
| reauthentication-flow: | ||
| status: exempt | ||
| comment: | | ||
| This integration does not authenticate. | ||
| test-coverage: todo | ||
| # Gold | ||
| devices: done | ||
| diagnostics: todo | ||
| discovery-update-info: | ||
| status: exempt | ||
| comment: | | ||
| This integration does not support discovery. | ||
| discovery: | ||
| status: exempt | ||
| comment: | | ||
| RF devices cannot be discovered. | ||
| docs-data-update: | ||
| status: exempt | ||
| comment: | | ||
| RF transmission is one-way; there is no data update. | ||
| docs-examples: todo | ||
| docs-known-limitations: todo | ||
| docs-supported-devices: todo | ||
| docs-supported-functions: todo | ||
| docs-troubleshooting: todo | ||
| docs-use-cases: todo | ||
| dynamic-devices: | ||
| status: exempt | ||
| comment: | | ||
| Each config entry represents a single static device. | ||
| entity-category: | ||
| status: exempt | ||
| comment: | | ||
| The single entity represents the primary device function. | ||
| entity-device-class: | ||
| status: exempt | ||
| comment: | | ||
| Light entities do not have device classes. | ||
| entity-disabled-by-default: | ||
| status: exempt | ||
| comment: | | ||
| The single entity represents the primary device function. | ||
| entity-translations: | ||
| status: exempt | ||
| comment: | | ||
| The entity uses the device name. | ||
| exception-translations: todo | ||
| icon-translations: | ||
| status: exempt | ||
| comment: | | ||
| Light uses the default icon for its state. | ||
| reconfiguration-flow: todo | ||
| repair-issues: | ||
| status: exempt | ||
| comment: | | ||
| No known repairable issues. | ||
| stale-devices: | ||
| status: exempt | ||
| comment: | | ||
| Each config entry represents a single static device. | ||
|
|
||
| # Platinum | ||
| async-dependency: done | ||
| inject-websession: | ||
| status: exempt | ||
| comment: | | ||
| This integration does not use a web session. | ||
| strict-typing: todo |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.