mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Rfxtrx fixup config entry creation (#38185)
* Make sure import flow completely replace existing config * Make sure added device contain correct config data * Revert change to directly run init
This commit is contained in:
parent
3206f4dc83
commit
1776540757
@ -280,11 +280,14 @@ async def async_setup_internal(hass, entry: config_entries.ConfigEntry):
|
|||||||
@callback
|
@callback
|
||||||
def _add_device(event, device_id):
|
def _add_device(event, device_id):
|
||||||
"""Add a device to config entry."""
|
"""Add a device to config entry."""
|
||||||
|
config = DEVICE_DATA_SCHEMA({})
|
||||||
|
config[CONF_DEVICE_ID] = device_id
|
||||||
|
|
||||||
data = entry.data.copy()
|
data = entry.data.copy()
|
||||||
event_code = binascii.hexlify(event.data).decode("ASCII")
|
event_code = binascii.hexlify(event.data).decode("ASCII")
|
||||||
data[CONF_DEVICES][event_code] = device_id
|
data[CONF_DEVICES][event_code] = config
|
||||||
hass.config_entries.async_update_entry(entry=entry, data=data)
|
hass.config_entries.async_update_entry(entry=entry, data=data)
|
||||||
devices[device_id] = {}
|
devices[device_id] = config
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _start_rfxtrx(event):
|
def _start_rfxtrx(event):
|
||||||
|
@ -16,6 +16,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
async def async_step_import(self, import_config=None):
|
async def async_step_import(self, import_config=None):
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
await self.async_set_unique_id(DOMAIN)
|
entry = await self.async_set_unique_id(DOMAIN)
|
||||||
self._abort_if_unique_id_configured(import_config)
|
if entry and import_config.items() != entry.data.items():
|
||||||
|
self.hass.config_entries.async_update_entry(entry, data=import_config)
|
||||||
|
return self.async_abort(reason="already_configured")
|
||||||
return self.async_create_entry(title="RFXTRX", data=import_config)
|
return self.async_create_entry(title="RFXTRX", data=import_config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user