diff options
author | Ruben Undheim <ruben.undheim@gmail.com> | 2018-12-21 21:01:06 +0100 |
---|---|---|
committer | Ruben Undheim <ruben.undheim@gmail.com> | 2018-12-21 21:01:06 +0100 |
commit | d41ea366e7c2e51c9f7e68092d89e3f0be580362 (patch) | |
tree | 949fd6476faf99d225a5787356a48b54b8b15192 /netdisco/discoverables/samsung_tv.py |
Import python-netdisco_2.2.0.orig.tar.gz
[dgit import orig python-netdisco_2.2.0.orig.tar.gz]
Diffstat (limited to 'netdisco/discoverables/samsung_tv.py')
-rw-r--r-- | netdisco/discoverables/samsung_tv.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/netdisco/discoverables/samsung_tv.py b/netdisco/discoverables/samsung_tv.py new file mode 100644 index 0000000..4ad31bb --- /dev/null +++ b/netdisco/discoverables/samsung_tv.py @@ -0,0 +1,25 @@ +"""Discover Samsung Smart TV services.""" +from . import SSDPDiscoverable +from ..const import ATTR_NAME + +# For some models, Samsung forces a [TV] prefix to the user-specified name. +FORCED_NAME_PREFIX = '[TV]' + + +class Discoverable(SSDPDiscoverable): + """Add support for discovering Samsung Smart TV services.""" + + def get_entries(self): + """Get all the Samsung RemoteControlReceiver entries.""" + return self.find_by_st( + "urn:samsung.com:device:RemoteControlReceiver:1") + + def info_from_entry(self, entry): + """Get most important info, by default the description location.""" + info = super().info_from_entry(entry) + + # Strip the forced prefix, if present + if info[ATTR_NAME].startswith(FORCED_NAME_PREFIX): + info[ATTR_NAME] = info[ATTR_NAME][len(FORCED_NAME_PREFIX):].strip() + + return info |