diff --git a/CHANGELOG.md b/CHANGELOG.md index 2256de7..0a72546 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ - "soundmode" feature - "speaker_level" - "rear_speaker_mode" + - "space_fit_sound" + - "active_voice_amplifier" ### Changed diff --git a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py index f89e844..ef4a641 100644 --- a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py +++ b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py @@ -14,15 +14,15 @@ log = logging.getLogger(__name__) class SoundbarDevice: def __init__( - self, - device: DeviceEntity, - session, - max_volume: int, - device_name: str, - enable_eq: bool = False, - enable_soundmode: bool = False, - enable_advanced_audio: bool = False, - enable_woofer: bool = False, + self, + device: DeviceEntity, + session, + max_volume: int, + device_name: str, + enable_eq: bool = False, + enable_soundmode: bool = False, + enable_advanced_audio: bool = False, + enable_woofer: bool = False, ): self.device = device self._device_id = self.device.device_id @@ -91,8 +91,8 @@ class SoundbarDevice: payload = await self.get_execute_status() retry = 0 while ( - "x.com.samsung.networkaudio.supportedSoundmode" not in payload - and retry < 10 + "x.com.samsung.networkaudio.supportedSoundmode" not in payload + and retry < 10 ): await asyncio.sleep(1) payload = await self.get_execute_status() @@ -420,6 +420,22 @@ class SoundbarDevice: value=mode.value, ) + # ------------ OTHER FUNCTIONS ------------ + + async def set_active_voice_amplifier(self, enabled: bool): + await self.set_custom_execution_data( + href="/sec/networkaudio/activeVoiceAmplifier", + property="x.com.samsung.networkaudio.activeVoiceAmplifier", + value=1 if enabled else 0 + ) + + async def set_space_fit_sound(self, enabled: bool): + await self.set_custom_execution_data( + href="/sec/networkaudio/spacefitSound", + property="x.com.samsung.networkaudio.spacefitSound", + value=1 if enabled else 0 + ) + # ------------ SUPPORT FUNCTIONS ------------ async def update_execution_data(self, argument: str): diff --git a/custom_components/samsung_soundbar/media_player.py b/custom_components/samsung_soundbar/media_player.py index 8cc76c7..0e38fab 100644 --- a/custom_components/samsung_soundbar/media_player.py +++ b/custom_components/samsung_soundbar/media_player.py @@ -92,6 +92,20 @@ def addServices(): SmartThingsSoundbarMediaPlayer.async_set_rear_speaker_mode.__name__, ) + platform.async_register_entity_service( + "set_active_voice_amplifier", + cv.make_entity_service_schema({vol.Required("enabled"): bool}), + SmartThingsSoundbarMediaPlayer.async_set_active_voice_amplifier.__name__, + ) + + platform.async_register_entity_service( + "set_space_fit_sound", + cv.make_entity_service_schema({vol.Required("enabled"): bool}), + SmartThingsSoundbarMediaPlayer.async_set_space_fit_sound.__name__, + ) + + + async def async_setup_entry(hass, config_entry, async_add_entities): domain_data = hass.data[DOMAIN] @@ -267,6 +281,12 @@ class SmartThingsSoundbarMediaPlayer(MediaPlayerEntity): async def async_set_rear_speaker_mode(self, speaker_mode: str): await self.device.set_rear_speaker_mode(RearSpeakerMode(speaker_mode)) + async def async_set_active_voice_amplifier(self, enabled: bool): + await self.device.set_active_voice_amplifier(enabled) + + async def async_set_space_fit_sound(self, enabled: bool): + await self.device.set_space_fit_sound(enabled) + # This property can be uncommented for some extra_attributes # Still enabling this can cause side-effects. # @property diff --git a/custom_components/samsung_soundbar/services.yaml b/custom_components/samsung_soundbar/services.yaml index 1284ec8..84e3f53 100644 --- a/custom_components/samsung_soundbar/services.yaml +++ b/custom_components/samsung_soundbar/services.yaml @@ -134,4 +134,34 @@ set_rear_speaker_mode: translation_key: "speaker_identifier" options: - "Rear" - - "Front" \ No newline at end of file + - "Front" + +set_active_voice_amplifier: + name: Set active voice amplifier + description: Activates / deactivates the active voice amplifier + target: + device: + integration: samsung_soundbar + fields: + enabled: + name: Enabled / Disabled + required: true + example: true + default: false + selector: + boolean: + +set_space_fit_sound: + name: Set SpaceFitSound + description: Activates / deactivates the SpaceFitSound + target: + device: + integration: samsung_soundbar + fields: + enabled: + name: Enabled / Disabled + required: true + example: true + default: false + selector: + boolean: \ No newline at end of file