This repository has been archived by the owner on Jun 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09a47db
commit f19318c
Showing
7 changed files
with
92 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
from .const import DOMAIN, DEVICES | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.const import CONF_DEVICE | ||
from homeassistant.const import CONF_DEVICE, CONF_ADDRESS | ||
|
||
async def async_setup(hass: HomeAssistant, hass_config: dict): | ||
hass.data.setdefault(DOMAIN, {}) | ||
return True | ||
|
||
|
||
async def async_setup_entry(hass: HomeAssistant, config_entry): | ||
identifier = config_entry.data[CONF_DEVICE] | ||
identifier = config_entry.data.get(CONF_DEVICE) | ||
address = config_entry.data.get(CONF_ADDRESS) | ||
if DOMAIN not in hass.data: | ||
hass.data[DOMAIN] = {} | ||
if DEVICES not in hass.data[DOMAIN]: | ||
hass.data[DOMAIN][DEVICES] = [] | ||
hass.data[DOMAIN][DEVICES].append(identifier) | ||
if identifier is not None: | ||
hass.data[DOMAIN][DEVICES].append(identifier) | ||
elif address is not None: | ||
hass.data[DOMAIN][DEVICES].append(address) | ||
hass.async_create_task(hass.config_entries.async_forward_entry_setup( | ||
config_entry, "media_player")) | ||
return True | ||
|
||
|
||
async def async_unload_entry(hass: HomeAssistant, config_entry): | ||
identifier = config_entry.data[CONF_DEVICE] | ||
hass.data[DOMAIN][DEVICES].remove(identifier) | ||
identifier = config_entry.data(CONF_DEVICE) | ||
address = config_entry.data.get(CONF_ADDRESS) | ||
if identifier is not None: | ||
hass.data[DOMAIN][DEVICES].remove(identifier) | ||
elif address is not None: | ||
hass.data[DOMAIN][DEVICES].remove(address) | ||
await hass.config_entries.async_forward_entry_unload(config_entry, "media_player") | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters