I am looking for a way to start/stop a group of speakers, I have at this moment “only” ben able to control on speaker and not a group.
I have created simple media_player to control volume and source of samsung speaker: https://github.com/macbury/ha_samsung_multi_room
Thanks for sharing - great work.
I see that the controls necessary for my R1 is very different. The source selection (with GetFunc/SetFunc) you use for a “soundbar” is pretty much irrelevant for a multi-room speaker. Instead I would need to select playback from presets (SetPlayPreset) and add some next/prev support for them.
But it should not be very difficult to add that to what you’ve already done.
Hi,
to switch a Samsung speaker or a group of speakers to OFF you can use the command for set a sleep timer with value 1 second.
http://your_speaker_IP:55001/UIC?cmd=%3Cname%3ESetSleepTimer%3C/name%3E%3Cp%20type=%22str%22%20name=%22option%22%20val=%22off%22/%3E%3Cp%20type=%22dec%22%20name=%22sleeptime%22%20val=%221%22/%3E
I hope this will help,
Kalle
very nicely done. works well.
I have HDMI TV Arc so the Samsung TV controls the soundbar and for some reason the “optical” source selects this. Soundshare doesn’tdo anything either. I’ve tried the various API commands so it’s certainly not your code.
Great work!
i have this function in use, it stoped working after 0.89 i cant understand why. please help
Same here! The .log says:
2019-03-10 07:49:42 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.radio_an_wochenende. Unknown error for call_service at pos 1:
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/automation/__init__.py", line 375, in action
await script_obj.async_run(variables, context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py", line 131, in async_run
await self._handle_action(action, variables, context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py", line 210, in _handle_action
action, variables, context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py", line 299, in _async_call_service
context=context
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 85, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1133, in async_call
self._execute_service(handler, service_call))
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1155, in _execute_service
await handler.func(service_call)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/shell_command/__init__.py", line 89, in async_service_handler
cmd, process.returncode)
File "/usr/lib/python3.5/logging/__init__.py", line 1315, in exception
self.error(msg, *args, exc_info=exc_info, **kwargs)
File "/usr/lib/python3.5/logging/__init__.py", line 1309, in error
self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python3.5/logging/__init__.py", line 1416, in _log
self.handle(record)
File "/usr/lib/python3.5/logging/__init__.py", line 1426, in handle
self.callHandlers(record)
File "/usr/lib/python3.5/logging/__init__.py", line 1488, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.5/logging/__init__.py", line 856, in handle
self.emit(record)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/system_log/__init__.py", line 168, in emit
_figure_out_source(record, stack, self.hass))
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/system_log/__init__.py", line 99, in __init__
self.root_cause = str(traceback.extract_tb(tb)[-1])
IndexError: list index out of range
Thanks
Try this repository. It is a fork of macbury’s and is working for me.
Note the change to the custom component folder structure required with later releases of HA.
I’ve tried this with my Samsung R3 speakers, but unfortunately it doesn’t work. Did anyone get this working with Samsung radiant speakers?
samsung_multi_room: Error on device update!
Traceback (most recent call last):
File "/config/custom_components/samsung_multi_room/media_player.py", line 85, in _exec_cmd
response = await self.session.get(url)
File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 497, in _request
await resp.start(conn)
File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 844, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 588, in read
await self._waiter
concurrent.futures._base.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 375, in async_device_update
await self.async_update()
File "/config/custom_components/samsung_multi_room/media_player.py", line 202, in async_update
value = await self.api.get_state()
File "/config/custom_components/samsung_multi_room/media_player.py", line 106, in get_state
return int(await self._exec_get('GetPowerStatus', 'powerStatus'))
File "/config/custom_components/samsung_multi_room/media_player.py", line 95, in _exec_get
return await self._exec_cmd('<name>{0}</name>'.format(action), key_to_extract)
File "/config/custom_components/samsung_multi_room/media_player.py", line 92, in _exec_cmd
return None
File "/usr/local/lib/python3.7/site-packages/async_timeout/__init__.py", line 45, in __exit__
self._do_exit(exc_type)
File "/usr/local/lib/python3.7/site-packages/async_timeout/__init__.py", line 92, in _do_exit
raise asyncio.TimeoutError
concurrent.futures._base.TimeoutError
Are you using the repository I linked to immediately above your post?
It’s working for me with Samsung MS-650 speakers.
Thanks Pete! Yes, I used that repository.
I found out that it has something to do with the ‘GetPowerStatus’ command that is missing on non-soundbar speakers:
I’ll will try to rewrite the code to fix it.
I get exactly the same error with the K650 with the dariornelas repo. Anyone else?
just released a new version with a new option:
power_options: False
Put this in your configuration and the component will not use the “GetPowerStatus” command.
Thanks Dornelas. I’ve been using your component for some time now.
I am much appreciative of the work you have done.
Could you please explain the power options. I have an MS650 soundbar. Does the power option mean I can now power on/off the soundbar?
Thanks.
Yes, you can power on/off the soundbar.
If power_options = True (the default value)
- Support for Turn On and Off
- On update, if device is On, update other values (volume, mute, source, etc…), if it’s Off do nothing
If power_options = False
- Does not support Turn On or Turn Off
- On update, always update everything (volume, mute, source)
There’s also an experimental feature, if you play some radio (only TuneIn) it will fetch the station info/picture and update the component. (only tested on HW-MS650)
New with Hass and successfully using your custom component installed with HACS.
Does anyone know how to get the ID’s from the apps on Samsung TV’s, like stated in the application.py file?
APPS = {‘YouTube’: ‘111299001912’,
‘Plex’: ‘3201512006963’,
‘Prime Video’: ‘3201512006785’,
‘Universal Guide’: ‘3201710015067’,
‘Netflix’: ‘11101200001’,
‘Apple TV’: ‘3201807016597’,
‘Steam Link’: ‘3201702011851’,
etc.
For example, the ID of Disney+ app so I can add it in the py file.
@dornelas Does your version of this integration support Samsungs Harman Kardon soundbars (Q series)?
Not sure.
But it should work
Unfortunately it doesn’t seem to be working with them (at least Q80R)
Have you tried without power options?