mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Always fire event for known devices in rfxtrx (#58845)
This commit is contained in:
parent
c7c1d6000f
commit
f0b3fbc5a7
@ -30,7 +30,6 @@ from .const import (
|
|||||||
COMMAND_GROUP_LIST,
|
COMMAND_GROUP_LIST,
|
||||||
CONF_AUTOMATIC_ADD,
|
CONF_AUTOMATIC_ADD,
|
||||||
CONF_DATA_BITS,
|
CONF_DATA_BITS,
|
||||||
CONF_FIRE_EVENT,
|
|
||||||
CONF_REMOVE_DEVICE,
|
CONF_REMOVE_DEVICE,
|
||||||
DATA_CLEANUP_CALLBACKS,
|
DATA_CLEANUP_CALLBACKS,
|
||||||
DATA_LISTENER,
|
DATA_LISTENER,
|
||||||
@ -186,8 +185,6 @@ async def async_setup_internal(hass, entry: config_entries.ConfigEntry):
|
|||||||
hass.helpers.dispatcher.async_dispatcher_send(SIGNAL_EVENT, event, device_id)
|
hass.helpers.dispatcher.async_dispatcher_send(SIGNAL_EVENT, event, device_id)
|
||||||
|
|
||||||
# Signal event to any other listeners
|
# 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
|
@callback
|
||||||
|
@ -35,7 +35,6 @@ from .binary_sensor import supported as binary_supported
|
|||||||
from .const import (
|
from .const import (
|
||||||
CONF_AUTOMATIC_ADD,
|
CONF_AUTOMATIC_ADD,
|
||||||
CONF_DATA_BITS,
|
CONF_DATA_BITS,
|
||||||
CONF_FIRE_EVENT,
|
|
||||||
CONF_OFF_DELAY,
|
CONF_OFF_DELAY,
|
||||||
CONF_REMOVE_DEVICE,
|
CONF_REMOVE_DEVICE,
|
||||||
CONF_REPLACE_DEVICE,
|
CONF_REPLACE_DEVICE,
|
||||||
@ -208,7 +207,6 @@ class OptionsFlow(config_entries.OptionsFlow):
|
|||||||
devices = {}
|
devices = {}
|
||||||
device = {
|
device = {
|
||||||
CONF_DEVICE_ID: device_id,
|
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),
|
CONF_SIGNAL_REPETITIONS: user_input.get(CONF_SIGNAL_REPETITIONS, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,11 +233,7 @@ class OptionsFlow(config_entries.OptionsFlow):
|
|||||||
|
|
||||||
device_data = self._selected_device
|
device_data = self._selected_device
|
||||||
|
|
||||||
data_schema = {
|
data_schema = {}
|
||||||
vol.Optional(
|
|
||||||
CONF_FIRE_EVENT, default=device_data.get(CONF_FIRE_EVENT, False)
|
|
||||||
): bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
if binary_supported(self._selected_device_object):
|
if binary_supported(self._selected_device_object):
|
||||||
if device_data.get(CONF_OFF_DELAY):
|
if device_data.get(CONF_OFF_DELAY):
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"""Constants for RFXtrx integration."""
|
"""Constants for RFXtrx integration."""
|
||||||
|
|
||||||
CONF_FIRE_EVENT = "fire_event"
|
|
||||||
CONF_DATA_BITS = "data_bits"
|
CONF_DATA_BITS = "data_bits"
|
||||||
CONF_AUTOMATIC_ADD = "automatic_add"
|
CONF_AUTOMATIC_ADD = "automatic_add"
|
||||||
CONF_SIGNAL_REPETITIONS = "signal_repetitions"
|
CONF_SIGNAL_REPETITIONS = "signal_repetitions"
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
},
|
},
|
||||||
"set_device_options": {
|
"set_device_options": {
|
||||||
"data": {
|
"data": {
|
||||||
"fire_event": "Enable device event",
|
|
||||||
"off_delay": "Off delay",
|
"off_delay": "Off delay",
|
||||||
"off_delay_enabled": "Enable off delay",
|
"off_delay_enabled": "Enable off delay",
|
||||||
"data_bit": "Number of data bits",
|
"data_bit": "Number of data bits",
|
||||||
|
@ -352,7 +352,7 @@ async def test_options_add_device(hass):
|
|||||||
assert result["step_id"] == "set_device_options"
|
assert result["step_id"] == "set_device_options"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
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
|
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["automatic_add"]
|
||||||
|
|
||||||
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]
|
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"]["signal_repetitions"] == 5
|
||||||
assert "delay_off" not in entry.data["devices"]["0b1100cd0213c7f230010f71"]
|
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 = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
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
|
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["automatic_add"]
|
||||||
|
|
||||||
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]
|
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"]["signal_repetitions"] == 5
|
||||||
assert entry.data["devices"]["0b1100cd0213c7f230010f71"]["off_delay"] == 4
|
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 = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
"fire_event": False,
|
|
||||||
"signal_repetitions": 5,
|
"signal_repetitions": 5,
|
||||||
"data_bits": 4,
|
"data_bits": 4,
|
||||||
"off_delay": "abcdef",
|
"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 = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
"fire_event": False,
|
|
||||||
"signal_repetitions": 5,
|
"signal_repetitions": 5,
|
||||||
"data_bits": 4,
|
"data_bits": 4,
|
||||||
"command_on": "0xE",
|
"command_on": "0xE",
|
||||||
@ -899,7 +895,6 @@ async def test_options_add_and_configure_device(hass):
|
|||||||
assert entry.data["automatic_add"]
|
assert entry.data["automatic_add"]
|
||||||
|
|
||||||
assert entry.data["devices"]["0913000022670e013970"]
|
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"]["signal_repetitions"] == 5
|
||||||
assert entry.data["devices"]["0913000022670e013970"]["off_delay"] == 9
|
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 = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
"fire_event": True,
|
|
||||||
"signal_repetitions": 5,
|
"signal_repetitions": 5,
|
||||||
"data_bits": 4,
|
"data_bits": 4,
|
||||||
"command_on": "0xE",
|
"command_on": "0xE",
|
||||||
@ -945,7 +939,6 @@ async def test_options_add_and_configure_device(hass):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert entry.data["devices"]["0913000022670e013970"]
|
assert entry.data["devices"]["0913000022670e013970"]
|
||||||
assert entry.data["devices"]["0913000022670e013970"]["fire_event"]
|
|
||||||
assert entry.data["devices"]["0913000022670e013970"]["signal_repetitions"] == 5
|
assert entry.data["devices"]["0913000022670e013970"]["signal_repetitions"] == 5
|
||||||
assert "delay_off" not in entry.data["devices"]["0913000022670e013970"]
|
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 = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
"fire_event": False,
|
|
||||||
"venetian_blind_mode": "EU",
|
"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 = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
"fire_event": False,
|
|
||||||
"venetian_blind_mode": "EU",
|
"venetian_blind_mode": "EU",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -17,8 +17,8 @@ async def test_fire_event(hass, rfxtrx):
|
|||||||
device="/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0",
|
device="/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0",
|
||||||
automatic_add=True,
|
automatic_add=True,
|
||||||
devices={
|
devices={
|
||||||
"0b1100cd0213c7f210010f51": {"fire_event": True},
|
"0b1100cd0213c7f210010f51": {},
|
||||||
"0716000100900970": {"fire_event": True},
|
"0716000100900970": {},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)
|
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user