Blog

Infrared receiver signal callbacks now return a bool

Core and integrations

As of Home Assistant Core 2027.1, callbacks that handle received infrared signals must return a bool that tells whether they recognized the signal. The infrared receiver entity state now only updates when at least one subscriber recognizes a signal.

See the architecture discussion for the full background.

Background

Until now, an InfraredReceiverEntity updated its state, the timestamp of the last received signal, on every IR signal it captured. Receivers pick up noise, signals from unrelated remotes, and repeated frames, and each of them caused a state change.

This is implemented in core PR #195653.

The new contract

The following callbacks must return True if they recognized the signal, and False otherwise:

  • The callback passed to infrared.async_subscribe_receiver.
  • The callback passed to InfraredReceiverEntity.async_subscribe_received_signal.
  • InfraredReceiverConsumerEntity._handle_signal.

Return True every time the signal is a frame meant for your device, even if it doesn't change the state of your entities. Return False for frames from other devices or protocols.

The receiver entity delivers each signal to all subscribers, and only updates its state if at least one of them returns True.

Callbacks returning None

Callbacks that return None keep working, but Home Assistant logs a deprecation warning once per callback. None is treated as not recognized, so the signal no longer updates the receiver state unless another subscriber returns True for it.

What to change

Return True when your callback recognizes a signal, and False on every other path.

Before:

Python
@override
@callback
def _handle_signal(self, signal: InfraredReceivedSignal) -> None:
    command = NECCommand.from_raw_timings(signal.timings)
    if command is None or command.address != MY_REMOTE_ADDRESS:
        return

    self._trigger_event(...)
    self.async_write_ha_state()

After:

Python
@override
@callback
def _handle_signal(self, signal: InfraredReceivedSignal) -> bool:
    command = NECCommand.from_raw_timings(signal.timings)
    if command is None or command.address != MY_REMOTE_ADDRESS:
        return False

    self._trigger_event(...)
    self.async_write_ha_state()
    return True

More details can be found in the infrared entity documentation.