Don't create event entries for lighting4 rfxtrx devices (#115716)

These have no standardized command need to be reworked
in the backing library to support exposing as events.

Fixes #115545
This commit is contained in:
Joakim Plate 2024-04-27 09:24:11 +02:00 committed by GitHub
parent a25b2168a3
commit ff4b8fa5e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View file

@ -15,6 +15,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util import slugify from homeassistant.util import slugify
from . import DeviceTuple, RfxtrxEntity, async_setup_platform_entry from . import DeviceTuple, RfxtrxEntity, async_setup_platform_entry
from .const import DEVICE_PACKET_TYPE_LIGHTING4
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -27,7 +28,10 @@ async def async_setup_entry(
"""Set up config entry.""" """Set up config entry."""
def _supported(event: RFXtrxEvent) -> bool: 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( def _constructor(
event: RFXtrxEvent, event: RFXtrxEvent,

View file

@ -10,6 +10,7 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.components.rfxtrx import get_rfx_object from homeassistant.components.rfxtrx import get_rfx_object
from homeassistant.const import Platform from homeassistant.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .conftest import setup_rfx_test_cfg from .conftest import setup_rfx_test_cfg
@ -101,3 +102,25 @@ async def test_invalid_event_type(
await hass.async_block_till_done() await hass.async_block_till_done()
assert hass.states.get("event.arc_c1") == state 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 == []