Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
akropp committed Aug 7, 2023
1 parent cf13324 commit a79b491
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
15 changes: 9 additions & 6 deletions custom_components/savantaudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
import datetime
import logging

from homeassistant import config_entries, core
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import Config, HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv

from .const import CONF_SOURCES, CONF_ZONES, DOMAIN, PLATFORMS
from .const import CONF_SOURCES, CONF_ZONES, DOMAIN, PLATFORMS, STARTUP_MESSAGE

_LOGGER = logging.getLogger(__name__)

async def async_setup_entry(
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
hass: HomeAssistant, entry: config_entries.ConfigEntry
) -> bool:
"""Set up platform from a ConfigEntry."""
_LOGGER.info(f'async_setup_entry: {DOMAIN}')
if hass.data.get(DOMAIN) is None:
hass.data.setdefault(DOMAIN, {})
_LOGGER.info(STARTUP_MESSAGE)

config = dict(entry.data)
# Update our config to include new repos and remove those that have been removed.
Expand All @@ -34,7 +37,7 @@ async def async_setup_entry(
return True

async def async_unload_entry(
hass: core.HomeAssistant,
hass: HomeAssistant,
entry: config_entries.ConfigEntry
) -> bool:
"""Unload a config entry."""
Expand All @@ -52,12 +55,12 @@ async def async_unload_entry(

return unload_ok

async def update_listener(hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry) -> None:
async def update_listener(hass: HomeAssistant, config_entry: config_entries.ConfigEntry) -> None:
"""Update listener."""
_LOGGER.info(f'update_listener: {DOMAIN}')
await hass.config_entries.async_reload(config_entry.entry_id)

async def async_setup(hass: core.HomeAssistant, config: dict) -> bool:
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the Savant component from yaml configuration."""
_LOGGER.info(f'async_setup: {DOMAIN}')
hass.data.setdefault(DOMAIN, {})
Expand Down
15 changes: 15 additions & 0 deletions custom_components/savantaudio/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import savantaudio.client as sa

NAME = "Savant Audio Switch Custom Component"
DOMAIN = "savantaudio"
VERSION = "0.1.12"

ISSUE_URL = "https://github.com/akropp/savantaudio-homeassistant/issues"

KNOWN_ZONES = "known_zones"
KNOWN_HOSTS = "known_hosts"
DEFAULT_PORT = 8085
Expand All @@ -17,3 +22,13 @@
# platforms
MEDIA_PLAYER = "media_player"
PLATFORMS = [MEDIA_PLAYER]

STARTUP_MESSAGE = f"""
-------------------------------------------------------------------
{NAME}
Version: {VERSION}
This is a custom integration!
If you have any issues with this you need to open an issue here:
{ISSUE_URL}
-------------------------------------------------------------------
"""
2 changes: 1 addition & 1 deletion custom_components/savantaudio/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from http.client import SWITCHING_PROTOCOLS
import logging

# from homeassistant.components.media_player.const import DOMAIN
from homeassistant.components.media_player import (
PLATFORM_SCHEMA,
MediaPlayerDeviceClass,
MediaPlayerEntity,
MediaPlayerEntityFeature,
)
from homeassistant.components.media_player.const import DOMAIN
from homeassistant.const import (
ATTR_ENTITY_ID,
CONF_ENABLED,
Expand Down

0 comments on commit a79b491

Please sign in to comment.