Always fire event for known devices in rfxtrx (#58845)

pull/59798/head
Joakim Plate 2021-11-16 19:03:18 +01:00 committed by GitHub
parent c7c1d6000f
commit f0b3fbc5a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 26 deletions

View File

@ -30,7 +30,6 @@ from .const import (
COMMAND_GROUP_LIST,
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
CONF_FIRE_EVENT,
CONF_REMOVE_DEVICE,
DATA_CLEANUP_CALLBACKS,
DATA_LISTENER,
@ -186,9 +185,7 @@ async def async_setup_internal(hass, entry: config_entries.ConfigEntry):
hass.helpers.dispatcher.async_dispatcher_send(SIGNAL_EVENT, event, device_id)
# Signal event to any other listeners
fire_event = devices.get(device_id, {}).get(CONF_FIRE_EVENT)
if fire_event:
hass.bus.async_fire(EVENT_RFXTRX_EVENT, event_data)
hass.bus.async_fire(EVENT_RFXTRX_EVENT, event_data)
@callback
def _add_device(event, device_id):

View File

@ -35,7 +35,6 @@ from .binary_sensor import supported as binary_supported
from .const import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
CONF_FIRE_EVENT,
CONF_OFF_DELAY,
CONF_REMOVE_DEVICE,
CONF_REPLACE_DEVICE,
@ -208,7 +207,6 @@ class OptionsFlow(config_entries.OptionsFlow):
devices = {}
device = {
CONF_DEVICE_ID: device_id,
CONF_FIRE_EVENT: user_input.get(CONF_FIRE_EVENT, False),
CONF_SIGNAL_REPETITIONS: user_input.get(CONF_SIGNAL_REPETITIONS, 1),
}
@ -235,11 +233,7 @@ class OptionsFlow(config_entries.OptionsFlow):
device_data = self._selected_device
data_schema = {
vol.Optional(
CONF_FIRE_EVENT, default=device_data.get(CONF_FIRE_EVENT, False)
): bool,
}
data_schema = {}
if binary_supported(self._selected_device_object):
if device_data.get(CONF_OFF_DELAY):

View File

@ -1,6 +1,5 @@
"""Constants for RFXtrx integration."""
CONF_FIRE_EVENT = "fire_event"
CONF_DATA_BITS = "data_bits"
CONF_AUTOMATIC_ADD = "automatic_add"
CONF_SIGNAL_REPETITIONS = "signal_repetitions"

View File

@ -49,7 +49,6 @@
},
"set_device_options": {
"data": {
"fire_event": "Enable device event",
"off_delay": "Off delay",
"off_delay_enabled": "Enable off delay",
"data_bit": "Number of data bits",

View File

@ -352,7 +352,7 @@ async def test_options_add_device(hass):
assert result["step_id"] == "set_device_options"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"fire_event": True, "signal_repetitions": 5}
result["flow_id"], user_input={"signal_repetitions": 5}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@ -362,7 +362,6 @@ async def test_options_add_device(hass):
assert entry.data["automatic_add"]
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]["fire_event"]
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]["signal_repetitions"] == 5
assert "delay_off" not in entry.data["devices"]["0b1100cd0213c7f230010f71"]
@ -442,7 +441,7 @@ async def test_options_add_remove_device(hass):
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={"fire_event": True, "signal_repetitions": 5, "off_delay": "4"},
user_input={"signal_repetitions": 5, "off_delay": "4"},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@ -452,7 +451,6 @@ async def test_options_add_remove_device(hass):
assert entry.data["automatic_add"]
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]["fire_event"]
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]["signal_repetitions"] == 5
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]["off_delay"] == 4
@ -864,7 +862,6 @@ async def test_options_add_and_configure_device(hass):
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
"fire_event": False,
"signal_repetitions": 5,
"data_bits": 4,
"off_delay": "abcdef",
@ -883,7 +880,6 @@ async def test_options_add_and_configure_device(hass):
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
"fire_event": False,
"signal_repetitions": 5,
"data_bits": 4,
"command_on": "0xE",
@ -899,7 +895,6 @@ async def test_options_add_and_configure_device(hass):
assert entry.data["automatic_add"]
assert entry.data["devices"]["0913000022670e013970"]
assert not entry.data["devices"]["0913000022670e013970"]["fire_event"]
assert entry.data["devices"]["0913000022670e013970"]["signal_repetitions"] == 5
assert entry.data["devices"]["0913000022670e013970"]["off_delay"] == 9
@ -932,7 +927,6 @@ async def test_options_add_and_configure_device(hass):
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
"fire_event": True,
"signal_repetitions": 5,
"data_bits": 4,
"command_on": "0xE",
@ -945,7 +939,6 @@ async def test_options_add_and_configure_device(hass):
await hass.async_block_till_done()
assert entry.data["devices"]["0913000022670e013970"]
assert entry.data["devices"]["0913000022670e013970"]["fire_event"]
assert entry.data["devices"]["0913000022670e013970"]["signal_repetitions"] == 5
assert "delay_off" not in entry.data["devices"]["0913000022670e013970"]
@ -988,7 +981,6 @@ async def test_options_configure_rfy_cover_device(hass):
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
"fire_event": False,
"venetian_blind_mode": "EU",
},
)
@ -1021,7 +1013,6 @@ async def test_options_configure_rfy_cover_device(hass):
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
"fire_event": False,
"venetian_blind_mode": "EU",
},
)

View File

@ -17,8 +17,8 @@ async def test_fire_event(hass, rfxtrx):
device="/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0",
automatic_add=True,
devices={
"0b1100cd0213c7f210010f51": {"fire_event": True},
"0716000100900970": {"fire_event": True},
"0b1100cd0213c7f210010f51": {},
"0716000100900970": {},
},
)
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)