Add radio_frequency platform to ESPHome#168448
Conversation
Implement the new radio_frequency platform on ESPHome, mirroring the infrared platform pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Always return frequency ranges from device info, matching the updated RadioFrequencyTransmitterEntity contract. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey there @jesserockz, @kbx81, @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
Adds ESPHome support for the new radio_frequency entity domain, following the existing ESPHome infrared platform structure so RF transmitters can be exposed and used via the shared abstraction layer.
Changes:
- Introduce an ESPHome
radio_frequencyplatform entity that can transmit raw RF timings via the native API. - Register
RadioFrequencyInfo→Platform.RADIO_FREQUENCYmapping so ESPHome can dynamically set up the platform. - Add ESPHome tests covering entity creation by capabilities, transmit success/failure, availability transitions, and frequency-range filtering.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
homeassistant/components/esphome/radio_frequency.py |
New ESPHome platform implementation for RF transmitter entities and transmit command wiring. |
homeassistant/components/esphome/entry_data.py |
Maps the new ESPHome API info type to the new HA platform for dynamic setup. |
tests/components/esphome/test_radio_frequency.py |
Test coverage mirroring the existing infrared tests for transmitter behavior and API calls. |
In rf-protocols 1.0.0, RadioFrequencyCommand.get_raw_timings() returns a flat list[int] of signed alternating microseconds directly, so the ESPHome platform can pass it straight through without unpacking Timing objects. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| def supported_frequency_ranges(self) -> list[tuple[int, int]]: | ||
| """Return supported frequency ranges from device info.""" | ||
| return [(self._static_info.frequency_min, self._static_info.frequency_max)] |
There was a problem hiding this comment.
would have been nicer if this was a tuple of tuples since it should be immutable but base entity concern
There was a problem hiding this comment.
Will migrate this in a future PR
| timings=[350, -1050], | ||
| ) | ||
|
|
||
| with pytest.raises(HomeAssistantError) as exc_info: |
There was a problem hiding this comment.
match only regex-matches against str(exception), but here we're asserting on translation_domain and translation_key attributes, which aren't in the string form.
| self._static_info.key, | ||
| frequency=command.frequency, | ||
| timings=timings, | ||
| modulation=MODULATION_TYPE_TO_ESPHOME[command.modulation], |
There was a problem hiding this comment.
this will blow up with KeyError if add more but don't update here
There was a problem hiding this comment.
Right now we're only supporting OOK modulation in all of HA. When we migrate to supporting other ones, we're going to add supported_modulations property, which will steer Home Assistant to limit to only valid modulations being passed in.
| frequency=command.frequency, | ||
| timings=timings, | ||
| modulation=MODULATION_TYPE_TO_ESPHOME[command.modulation], | ||
| repeat_count=command.repeat_count + 1, |
There was a problem hiding this comment.
its not obvious why this is +1 here
Breaking change
Proposed change
Implement the new
radio_frequencyentity platform on ESPHome, mirroring the existinginfraredplatform pattern.This PR relies on:
radio_frequencyentity platform.Opened as a draft because it depends on the linked PRs. Typing and linting will fail on things imported from the
radio_frequencyintegration until #168447 lands; that is expected and can be ignored for now.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: