Skip to content

Commit

Permalink
Allow enabling/disable multiple config entries in a single call (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Dec 8, 2023
1 parent 16ae7fc commit bc7f37a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class SpookService(AbstractSpookAdminService):

domain = DOMAIN
service = "disable_config_entry"
schema = {vol.Required("config_entry_id"): cv.string}
schema = {vol.Required("config_entry_id"): vol.All(cv.ensure_list, [cv.string])}

async def async_handle_service(self, call: ServiceCall) -> None:
"""Handle the service call."""
await self.hass.config_entries.async_set_disabled_by(
call.data["config_entry_id"],
disabled_by=ConfigEntryDisabler.USER,
)
for config_entry_id in call.data["config_entry_id"]:
await self.hass.config_entries.async_set_disabled_by(
config_entry_id,
disabled_by=ConfigEntryDisabler.USER,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ class SpookService(AbstractSpookAdminService):

domain = DOMAIN
service = "enable_config_entry"
schema = {vol.Required("config_entry_id"): cv.string}
schema = {vol.Required("config_entry_id"): vol.All(cv.ensure_list, [cv.string])}

async def async_handle_service(self, call: ServiceCall) -> None:
"""Handle the service call."""
await self.hass.config_entries.async_set_disabled_by(
call.data["config_entry_id"],
disabled_by=None,
)
for config_entry_id in call.data["config_entry_id"]:
await self.hass.config_entries.async_set_disabled_by(
config_entry_id,
disabled_by=None,
)
26 changes: 24 additions & 2 deletions documentation/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Disable a single instance of an integration by its {term}`config entry <config e
- Required
- Default / Example
* - `config_entry_id`
- {term}`string <string>`
- {term}`string <string>` | {term}`list of strings <list>`
- Yes
- `dc23e666e6100f184e642a0ac345d3eb`
```
Expand All @@ -69,6 +69,17 @@ data:
config_entry_id: "dc23e666e6100f184e642a0ac345d3eb"
```

Or multiple at once:

```{code-block} yaml
:linenos:
service: homeassistant.disable_config_entry
data:
config_entry_id:
- "dc23e666e6100f184e642a0ac345d3eb"
- "df98a97c9341a0f184e642a0ac345d3b"
```

:::

### Enable an integration
Expand Down Expand Up @@ -106,7 +117,7 @@ Enable a single instance of an integration by its {term}`config entry <config en
- Required
- Default / Example
* - `config_entry_id`
- {term}`string <string>`
- {term}`string <string>` | {term}`list of strings <list>`
- Yes
- `dc23e666e6100f184e642a0ac345d3eb`
```
Expand All @@ -129,6 +140,17 @@ data:
config_entry_id: "dc23e666e6100f184e642a0ac345d3eb"
```

Or multiple at once:

```{code-block} yaml
:linenos:
service: homeassistant.enable_config_entry
data:
config_entry_id:
- "dc23e666e6100f184e642a0ac345d3eb"
- "df98a97c9341a0f184e642a0ac345d3b"
```

:::

### Disable polling for updates
Expand Down

0 comments on commit bc7f37a

Please sign in to comment.