Package: samsung-multiroom
Control Samsung Multiroom speakers.Installationpipinstallsamsung_multiroomExample speaker controlInitialisefromsamsung_multiroomimportSamsungMultiroomSpeaker# initialise (replace with your speaker's ip address)speaker=SamsungMultiroomSpeaker('192.168.1.129')# get speaker namespeaker.get_name()Basic functions# get/set volumevolume=speaker.get_volume()print(volume)speaker.set_volume(10)# switch source to connect with your samsung tvspeaker.set_source('soundshare')# mute/unmutespeaker.mute()speaker.unmute()Audio source browsers# browse dlna device called nasbrowser=speaker.service('dlna').browser# or shorterbrowser=speaker.browser('dlna')browser=browser.browse('/nas/Music/By Folder/Air/Moon Safari/CD 1')foriteminbrowser:print(item.object_type,item.object_id,item.artist,'-',item.name)# browse TuneIn radiosbrowser=speaker.service('tunein').browserbrowser=browser.browse('/Trending/')foriteminbrowser:print(item.object_type,item.object_id,item.name)App integrations# check available servicesnames=speaker.get_services_names()print(names)# authenticate (unless you've done it already via mobile app)speaker.service('Deezer').login('your email','your password')browser=speaker.service('Deezer').browserbrowser=browser.browse('/Browse/Rock/Artists/Queen')foriteminbrowser:print(item.object_type,item.object_id,item.name)Player functions# create playlist from browser items (see above) and playspeaker.player.play(browser)# pause/resumespeaker.player.pause()speaker.player.resume()# repeat modefromsamsung_multiroomimportREPEAT_ALL,REPEAT_ONE,REPEAT_OFFspeaker.player.repeat(REPEAT_ALL)# get track infotrack=speaker.player.get_current_track()print(track)Equalizer functions# get preset namespresets=speaker.equalizer.get_presets_names()print(presets)# set predefined equalizer settingsspeaker.equalizer.set('Pop')# set adhoc settingsspeaker.equalizer.set([4,3,2,1,2,3,0])# <-6, 6># overwrite current presetspeaker.equalizer.save()# ... or save as a new presetspeaker.equalizer.save('Experimental')Clock functions# set alarmbrowser=speaker.service('tunein').browserbrowser=browser.browse('/Trending/')speaker.clock.alarm.slot(0).set(time='17:28',weekdays=[0,1,5],# Mon, Tue, Friplaylist=browser,)# enable/disable alarm 0speaker.clock.alarm.slot(0).enable()speaker.clock.alarm.slot(0).disable()# sleep after 30 secondsspeaker.clock.timer.start(300)remaining_time=speaker.clock.timer.get_remaining_time()print(remaining_time)Speaker discoveryfromsamsung_multiroomimportSamsungSpeakerDiscoveryspeakers=SamsungSpeakerDiscovery().discover()# takes some timeforsinspeakers:print(s.get_name(),'@',s.ip_address)Speaker grouping# (after speaker discovery)main_speaker=speakers[0]rest_speakers=speakers[1:]speaker_group=main_speaker.group('My first group',rest_speakers)# now use speaker group like a speakerspeaker_group.set_volume(10)browser=speaker_group.service('dlna').browserbrowser=browser.browse('/nas/Music/By Folder/Air/Moon Safari/CD 1')speaker_group.player.play(browser)Events (preview)You can monitor events emitted by the speaker without polling. Full list of supported events can be found in
samsung_multiroom/event/type/.importasynciofromsamsung_multiroomimportSamsungMultiroomSpeaker# listener will be passed an Event object (see samsung_multiroom/event/type/)deflistener(event):print(event.name,event)asyncdefmain():speaker=SamsungMultiroomSpeaker('192.168.1.129')event_loop=speaker.event_loopevent_loop.add_listener('*',listener)awaitevent_loop.loop()loop=asyncio.get_event_loop()loop.run_until_complete(main())loop.close()# listen to all eventsevent_loop.add_listener('*',listener)# listen to events within a namespaceevent_loop.add_listener('speaker.service.*',listener)# listen to a single eventevent_loop.add_listener('speaker.service.changed',listener)LicenseMIT LicenseCopyright (c) 2018 Krystian GalutowskiPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.