Compare commits
6 Commits
main
...
feature/ne
Author | SHA1 | Date |
---|---|---|
|
7c7648e51a | |
|
09c1640839 | |
|
88034c5531 | |
|
a28def5313 | |
|
735fd53644 | |
|
d42e1b2832 |
|
@ -15,7 +15,13 @@ jobs:
|
|||
contents: write
|
||||
steps:
|
||||
- name: "Checkout the repository"
|
||||
uses: "actions/checkout@v3.5.3"
|
||||
uses: "actions/checkout@v4.1.0"
|
||||
|
||||
- name: "Adjust version number"
|
||||
shell: "bash"
|
||||
run: |
|
||||
yq -i -o json '.version="${{ github.event.release.tag_name }}"' \
|
||||
"${{ github.workspace }}/custom_components/samsung_soundbar/manifest.json"
|
||||
|
||||
- name: "ZIP the integration directory"
|
||||
shell: "bash"
|
||||
|
|
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,5 +1,19 @@
|
|||
# Changelog
|
||||
|
||||
## [0.3.0] Icons and Chore
|
||||
|
||||
### Added
|
||||
|
||||
- Icons for the individual entities
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated the GitHub actions workflows
|
||||
- Change "magic numbers" to `MediaPlayerEntityFeature` object
|
||||
For more information see https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation
|
||||
- the `source` now returns the value `wifi` when the `media_app_name` is `AirPlay` or `Spotify`
|
||||
- removed some unnecessary logging statements, and changed others to `debug`
|
||||
|
||||
## [0.2.1] Chore: Format repository - 2024-02-08
|
||||
|
||||
### Changed
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,9 +20,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
"""Set up component from a config entry, config_entry contains data from config entry database."""
|
||||
# store shell object
|
||||
|
||||
_LOGGER.info(f"[{DOMAIN}] Starting to setup ConfigEntry {entry.data}")
|
||||
_LOGGER.info(f"[{DOMAIN}] Starting to setup a ConfigEntry")
|
||||
_LOGGER.debug(f"[{DOMAIN}] Setting up ConfigEntry with the following data: {entry.data}")
|
||||
if not DOMAIN in hass.data:
|
||||
_LOGGER.info(f"[{DOMAIN}] Domain not found in hass.data setting default")
|
||||
_LOGGER.debug(f"[{DOMAIN}] Domain not found in hass.data setting default")
|
||||
hass.data[DOMAIN] = SoundbarConfig(
|
||||
SmartThings(
|
||||
async_get_clientsession(hass), entry.data.get(CONF_ENTRY_API_KEY)
|
||||
|
@ -31,10 +32,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
)
|
||||
|
||||
domain_config: SoundbarConfig = hass.data[DOMAIN]
|
||||
_LOGGER.info(f"[{DOMAIN}] Retrieved Domain Config: {domain_config}")
|
||||
_LOGGER.debug(f"[{DOMAIN}] Retrieved Domain Config: {domain_config}")
|
||||
|
||||
if not entry.data.get(CONF_ENTRY_DEVICE_ID) in domain_config.devices:
|
||||
_LOGGER.info(
|
||||
_LOGGER.info(f"[{DOMAIN}] Setting up new Soundbar device")
|
||||
_LOGGER.debug(
|
||||
f"[{DOMAIN}] DeviceId: {entry.data.get(CONF_ENTRY_DEVICE_ID)} not found in domain_config, setting up new device."
|
||||
)
|
||||
smart_things_device = await domain_config.api.device(
|
||||
|
@ -51,7 +53,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
domain_config.devices[entry.data.get(CONF_ENTRY_DEVICE_ID)] = DeviceConfig(
|
||||
entry.data, soundbar_device
|
||||
)
|
||||
_LOGGER.info(f"[{DOMAIN}] after initializing Soundbar device")
|
||||
_LOGGER.info(f"[{DOMAIN}] Successfully initialized new Soundbar device")
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
return True
|
||||
|
|
|
@ -242,6 +242,8 @@ class SoundbarDevice:
|
|||
|
||||
@property
|
||||
def input_source(self):
|
||||
if self.media_app_name in ("AirPlay", "Spotify"):
|
||||
return "wifi"
|
||||
return self.device.status.input_source
|
||||
|
||||
@property
|
||||
|
|
|
@ -22,23 +22,20 @@ async def validate_input(api, device_id: str):
|
|||
|
||||
class ExampleConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_user(self, user_input=None):
|
||||
_LOGGER.error(f"Example Flow starts with user_input {user_input}")
|
||||
if user_input is not None:
|
||||
_LOGGER.error(f"User Input is not filled")
|
||||
try:
|
||||
session = async_get_clientsession(self.hass)
|
||||
api = pysmartthings.SmartThings(
|
||||
session, user_input.get(CONF_ENTRY_API_KEY)
|
||||
)
|
||||
_LOGGER.error(f"Validating Input {user_input}")
|
||||
device = await validate_input(api, user_input.get(CONF_ENTRY_DEVICE_ID))
|
||||
|
||||
_LOGGER.error(
|
||||
_LOGGER.debug(
|
||||
f"Successfully validated Input, Creating entry with title {DOMAIN} and data {user_input}"
|
||||
)
|
||||
return self.async_create_entry(title=DOMAIN, data=user_input)
|
||||
except Exception as excp:
|
||||
_LOGGER.error(f"Example Flow triggered an exception {excp}")
|
||||
_LOGGER.error(f"The ConfigFlow triggered an exception {excp}")
|
||||
return self.async_abort(reason="fetch_failed")
|
||||
|
||||
return self.async_show_form(
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
"iot_class": "cloud_polling",
|
||||
"issue_tracker": "https://github.com/samuelspagl/ha_samsung_soundbar/issues",
|
||||
"requirements": ["pysmartthings"],
|
||||
"version": "0.2.0"
|
||||
"version": "0.3.0"
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ from typing import Any, Mapping
|
|||
|
||||
from homeassistant.components.media_player import (DEVICE_CLASS_SPEAKER,
|
||||
MediaPlayerEntity)
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_SELECT_SOUND_MODE,
|
||||
SUPPORT_SELECT_SOURCE, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP)
|
||||
from homeassistant.components.media_player.const import \
|
||||
MediaPlayerEntityFeature
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.entity import DeviceInfo, generate_entity_id
|
||||
|
||||
|
@ -21,16 +19,16 @@ DEFAULT_NAME = "SmartThings Soundbar"
|
|||
CONF_MAX_VOLUME = "max_volume"
|
||||
|
||||
SUPPORT_SMARTTHINGS_SOUNDBAR = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_SELECT_SOUND_MODE
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -22,22 +22,13 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
device = device_config.device
|
||||
if device.device_id == config_entry.data.get(CONF_ENTRY_DEVICE_ID):
|
||||
entities.append(
|
||||
EqPresetSelectEntity(
|
||||
device,
|
||||
"eq_preset",
|
||||
)
|
||||
EqPresetSelectEntity(device, "eq_preset", "mdi:tune-vertical")
|
||||
)
|
||||
entities.append(
|
||||
SoundModeSelectEntity(
|
||||
device,
|
||||
"sound_mode_preset",
|
||||
)
|
||||
SoundModeSelectEntity(device, "sound_mode_preset", "mdi:surround-sound")
|
||||
)
|
||||
entities.append(
|
||||
InputSelectEntity(
|
||||
device,
|
||||
"input_preset",
|
||||
)
|
||||
InputSelectEntity(device, "input_preset", "mdi:video-input-hdmi")
|
||||
)
|
||||
async_add_entities(entities)
|
||||
return True
|
||||
|
@ -48,11 +39,13 @@ class EqPresetSelectEntity(SelectEntity):
|
|||
self,
|
||||
device: SoundbarDevice,
|
||||
append_unique_id: str,
|
||||
icon_string: str,
|
||||
):
|
||||
self.entity_id = f"number.{device.device_name}_{append_unique_id}"
|
||||
self.entity_description = SelectEntityDescription(
|
||||
key=append_unique_id,
|
||||
)
|
||||
self.__base_icon = icon_string
|
||||
self.__device = device
|
||||
self._attr_unique_id = f"{device.device_id}_sw_{append_unique_id}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
@ -72,6 +65,10 @@ class EqPresetSelectEntity(SelectEntity):
|
|||
def name(self):
|
||||
return self.__append_unique_id
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
return self.__base_icon
|
||||
|
||||
# ------ STATE FUNCTIONS --------
|
||||
|
||||
@property
|
||||
|
@ -90,11 +87,13 @@ class SoundModeSelectEntity(SelectEntity):
|
|||
self,
|
||||
device: SoundbarDevice,
|
||||
append_unique_id: str,
|
||||
icon_string: str,
|
||||
):
|
||||
self.entity_id = f"number.{device.device_name}_{append_unique_id}"
|
||||
self.entity_description = SelectEntityDescription(
|
||||
key=append_unique_id,
|
||||
)
|
||||
self.__base_icon = icon_string
|
||||
self.__device = device
|
||||
self._attr_unique_id = f"{device.device_id}_sw_{append_unique_id}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
@ -114,6 +113,10 @@ class SoundModeSelectEntity(SelectEntity):
|
|||
def name(self):
|
||||
return self.__append_unique_id
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
return self.__base_icon
|
||||
|
||||
# ------ STATE FUNCTIONS --------
|
||||
|
||||
@property
|
||||
|
@ -132,11 +135,13 @@ class InputSelectEntity(SelectEntity):
|
|||
self,
|
||||
device: SoundbarDevice,
|
||||
append_unique_id: str,
|
||||
icon_string: str,
|
||||
):
|
||||
self.entity_id = f"number.{device.device_name}_{append_unique_id}"
|
||||
self.entity_description = SelectEntityDescription(
|
||||
key=append_unique_id,
|
||||
)
|
||||
self.__base_icon = icon_string
|
||||
self.__device = device
|
||||
self._attr_unique_id = f"{device.device_id}_sw_{append_unique_id}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
@ -156,6 +161,10 @@ class InputSelectEntity(SelectEntity):
|
|||
def name(self):
|
||||
return self.__append_unique_id
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
return self.__base_icon
|
||||
|
||||
# ------ STATE FUNCTIONS --------
|
||||
|
||||
@property
|
||||
|
|
|
@ -19,16 +19,17 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
device = device_config.device
|
||||
|
||||
if device.device_id == config_entry.data.get(CONF_ENTRY_DEVICE_ID):
|
||||
entities.append(VolumeSensor(device, "volume_level"))
|
||||
entities.append(VolumeSensor(device, "volume_level", "mdi:volume-high"))
|
||||
async_add_entities(entities)
|
||||
return True
|
||||
|
||||
|
||||
class VolumeSensor(SensorEntity):
|
||||
def __init__(self, device: SoundbarDevice, append_unique_id: str):
|
||||
def __init__(self, device: SoundbarDevice, append_unique_id: str, icon_string: str):
|
||||
self.entity_id = f"sensor.{device.device_name}_{append_unique_id}"
|
||||
self.__device = device
|
||||
self._attr_unique_id = f"{device.device_id}_sw_{append_unique_id}"
|
||||
self.__base_icon = icon_string
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self.__device.device_id)},
|
||||
name=self.__device.device_name,
|
||||
|
@ -40,6 +41,10 @@ class VolumeSensor(SensorEntity):
|
|||
|
||||
_attr_device_class = SensorDeviceClass.VOLUME
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
return self.__base_icon
|
||||
|
||||
def update(self) -> None:
|
||||
"""Fetch new state data for the sensor.
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
lambda: device.night_mode,
|
||||
device.set_night_mode,
|
||||
device.set_night_mode,
|
||||
"mdi:weather-night",
|
||||
)
|
||||
)
|
||||
entities.append(
|
||||
|
@ -34,6 +35,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
lambda: device.bass_mode,
|
||||
device.set_bass_mode,
|
||||
device.set_bass_mode,
|
||||
"mdi:speaker-wireless",
|
||||
)
|
||||
)
|
||||
entities.append(
|
||||
|
@ -43,6 +45,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
lambda: device.voice_amplifier,
|
||||
device.set_voice_amplifier,
|
||||
device.set_voice_amplifier,
|
||||
"mdi:account-voice",
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
|
@ -57,12 +60,14 @@ class SoundbarSwitchAdvancedAudio(SwitchEntity):
|
|||
state_function,
|
||||
on_function,
|
||||
off_function,
|
||||
icon_string: str = "mdi:toggle-switch-variant",
|
||||
):
|
||||
self.entity_id = f"switch.{device.device_name}_{append_unique_id}"
|
||||
|
||||
self.__device = device
|
||||
self._name = f"{self.__device.device_name} {append_unique_id}"
|
||||
self._attr_unique_id = f"{device.device_id}_sw_{append_unique_id}"
|
||||
self.__base_icon = icon_string
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self.__device.device_id)},
|
||||
name=self.__device.device_name,
|
||||
|
@ -85,6 +90,10 @@ class SoundbarSwitchAdvancedAudio(SwitchEntity):
|
|||
def update(self):
|
||||
self.__state = self.__state_function()
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
return self.__base_icon
|
||||
|
||||
# ------ STATE FUNCTIONS --------
|
||||
@property
|
||||
def state(self):
|
||||
|
|
Loading…
Reference in New Issue