2023-09-06 18:20:27 +03:00
|
|
|
import logging
|
|
|
|
|
Feature: Add more fine grained configuration steps (#28)
> ⚠️ Please read the following carefully:
> This release is a bit special. As "something" on Samsung's side changed,
> it is currently not possible to retrieve the status of "custom capabilities", eg.
> woofer, soundmode, eq, and others. Therefore I decided to give the option to
> disable the entities of these features as the value of these entities is not trustworthy.
> Instead I implemented all of these and more (thanks to @whitebearded) as service calls.
> Have fun using them!
### Added
- Configuration flow options for enable / disable
- "advanced audio" features (NightMode, Bassmode, VoiceEnhancer)
- "woofer" feature
- "soundmode" feature
- "eq" feature
- added `media_player` support for next and previous track
- Service calls for:
- "advanced audio" features (NightMode, Bassmode, VoiceEnhancer)
- "woofer" feature
- "soundmode" feature
- "speaker_level"
- "rear_speaker_mode"
- "space_fit_sound"
- "active_voice_amplifier"
### Changed
- Fixed state, also displaying "playing" and "paused" values
---------
Co-authored-by: Samuel Spagl <samuel.spagl@kobil.com>
2024-06-09 18:13:38 +03:00
|
|
|
from homeassistant.components.number import (
|
|
|
|
NumberEntity,
|
|
|
|
NumberEntityDescription,
|
|
|
|
NumberMode,
|
|
|
|
)
|
2023-09-06 18:20:27 +03:00
|
|
|
from homeassistant.helpers.entity import DeviceInfo
|
|
|
|
|
|
|
|
from .api_extension.SoundbarDevice import SoundbarDevice
|
Feature: Add more fine grained configuration steps (#28)
> ⚠️ Please read the following carefully:
> This release is a bit special. As "something" on Samsung's side changed,
> it is currently not possible to retrieve the status of "custom capabilities", eg.
> woofer, soundmode, eq, and others. Therefore I decided to give the option to
> disable the entities of these features as the value of these entities is not trustworthy.
> Instead I implemented all of these and more (thanks to @whitebearded) as service calls.
> Have fun using them!
### Added
- Configuration flow options for enable / disable
- "advanced audio" features (NightMode, Bassmode, VoiceEnhancer)
- "woofer" feature
- "soundmode" feature
- "eq" feature
- added `media_player` support for next and previous track
- Service calls for:
- "advanced audio" features (NightMode, Bassmode, VoiceEnhancer)
- "woofer" feature
- "soundmode" feature
- "speaker_level"
- "rear_speaker_mode"
- "space_fit_sound"
- "active_voice_amplifier"
### Changed
- Fixed state, also displaying "playing" and "paused" values
---------
Co-authored-by: Samuel Spagl <samuel.spagl@kobil.com>
2024-06-09 18:13:38 +03:00
|
|
|
from .const import CONF_ENTRY_DEVICE_ID, CONF_ENTRY_SETTINGS_WOOFER_NUMBER, DOMAIN
|
2024-02-08 18:58:57 +03:00
|
|
|
from .models import DeviceConfig
|
2023-09-06 18:20:27 +03:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
|
|
|
domain_data = hass.data[DOMAIN]
|
|
|
|
|
|
|
|
entities = []
|
|
|
|
for key in domain_data.devices:
|
|
|
|
device_config: DeviceConfig = domain_data.devices[key]
|
|
|
|
device = device_config.device
|
Feature: Add more fine grained configuration steps (#28)
> ⚠️ Please read the following carefully:
> This release is a bit special. As "something" on Samsung's side changed,
> it is currently not possible to retrieve the status of "custom capabilities", eg.
> woofer, soundmode, eq, and others. Therefore I decided to give the option to
> disable the entities of these features as the value of these entities is not trustworthy.
> Instead I implemented all of these and more (thanks to @whitebearded) as service calls.
> Have fun using them!
### Added
- Configuration flow options for enable / disable
- "advanced audio" features (NightMode, Bassmode, VoiceEnhancer)
- "woofer" feature
- "soundmode" feature
- "eq" feature
- added `media_player` support for next and previous track
- Service calls for:
- "advanced audio" features (NightMode, Bassmode, VoiceEnhancer)
- "woofer" feature
- "soundmode" feature
- "speaker_level"
- "rear_speaker_mode"
- "space_fit_sound"
- "active_voice_amplifier"
### Changed
- Fixed state, also displaying "playing" and "paused" values
---------
Co-authored-by: Samuel Spagl <samuel.spagl@kobil.com>
2024-06-09 18:13:38 +03:00
|
|
|
if device.device_id == config_entry.data.get(
|
|
|
|
CONF_ENTRY_DEVICE_ID
|
|
|
|
) and config_entry.data.get(CONF_ENTRY_SETTINGS_WOOFER_NUMBER):
|
2023-09-06 18:20:27 +03:00
|
|
|
entities.append(
|
2023-09-07 15:49:20 +03:00
|
|
|
SoundbarWooferNumberEntity(
|
2023-09-06 18:20:27 +03:00
|
|
|
device,
|
|
|
|
"woofer_level",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
async_add_entities(entities)
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2023-09-07 15:49:20 +03:00
|
|
|
class SoundbarWooferNumberEntity(NumberEntity):
|
2023-09-06 18:20:27 +03:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
device: SoundbarDevice,
|
|
|
|
append_unique_id: str,
|
|
|
|
):
|
|
|
|
self.entity_id = f"number.{device.device_name}_{append_unique_id}"
|
2024-02-08 18:58:57 +03:00
|
|
|
self.entity_description = NumberEntityDescription(
|
|
|
|
native_max_value=6,
|
|
|
|
native_min_value=-10,
|
|
|
|
mode=NumberMode.BOX,
|
|
|
|
native_step=1,
|
|
|
|
native_unit_of_measurement="dB",
|
|
|
|
key=append_unique_id,
|
|
|
|
)
|
2023-09-06 18:20:27 +03:00
|
|
|
self.__device = device
|
|
|
|
self._attr_unique_id = f"{device.device_id}_sw_{append_unique_id}"
|
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, self.__device.device_id)},
|
|
|
|
name=self.__device.device_name,
|
|
|
|
manufacturer=self.__device.manufacturer,
|
|
|
|
model=self.__device.model,
|
|
|
|
sw_version=self.__device.firmware_version,
|
|
|
|
)
|
2023-09-07 15:49:20 +03:00
|
|
|
self.__append_unique_id = append_unique_id
|
2023-09-06 18:20:27 +03:00
|
|
|
|
|
|
|
# ---------- GENERAL ---------------
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
2023-09-07 15:49:20 +03:00
|
|
|
return self.__append_unique_id
|
2023-09-06 18:20:27 +03:00
|
|
|
|
|
|
|
# ------ STATE FUNCTIONS --------
|
|
|
|
|
|
|
|
@property
|
|
|
|
def native_value(self) -> float | None:
|
2023-09-07 15:49:20 +03:00
|
|
|
return self.__device.woofer_level
|
2023-09-06 18:20:27 +03:00
|
|
|
|
|
|
|
async def async_set_native_value(self, value: float):
|
2023-09-07 15:49:20 +03:00
|
|
|
await self.__device.set_woofer(int(value))
|