Skip to content

Commit

Permalink
Don't create event entries for lighting4 rfxtrx devices (#115716)
Browse files Browse the repository at this point in the history
These have no standardized command need to be reworked
in the backing library to support exposing as events.

Fixes #115545
  • Loading branch information
elupus authored Apr 27, 2024
1 parent a25b216 commit ff4b8fa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion homeassistant/components/rfxtrx/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from homeassistant.util import slugify

from . import DeviceTuple, RfxtrxEntity, async_setup_platform_entry
from .const import DEVICE_PACKET_TYPE_LIGHTING4

_LOGGER = logging.getLogger(__name__)

Expand All @@ -27,7 +28,10 @@ async def async_setup_entry(
"""Set up config entry."""

def _supported(event: RFXtrxEvent) -> bool:
return isinstance(event, (ControlEvent, SensorEvent))
return (
isinstance(event, (ControlEvent, SensorEvent))
and event.device.packettype != DEVICE_PACKET_TYPE_LIGHTING4
)

def _constructor(
event: RFXtrxEvent,
Expand Down
23 changes: 23 additions & 0 deletions tests/components/rfxtrx/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from homeassistant.components.rfxtrx import get_rfx_object
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er

from .conftest import setup_rfx_test_cfg

Expand Down Expand Up @@ -101,3 +102,25 @@ async def test_invalid_event_type(
await hass.async_block_till_done()

assert hass.states.get("event.arc_c1") == state


async def test_ignoring_lighting4(hass: HomeAssistant, rfxtrx) -> None:
"""Test with 1 sensor."""
entry = await setup_rfx_test_cfg(
hass,
devices={
"0913000022670e013970": {
"data_bits": 4,
"command_on": 0xE,
"command_off": 0x7,
}
},
)

registry = er.async_get(hass)
entries = [
entry
for entry in registry.entities.get_entries_for_config_entry_id(entry.entry_id)
if entry.domain == Platform.EVENT
]
assert entries == []

0 comments on commit ff4b8fa

Please sign in to comment.