File: samsung_tv.py

package info (click to toggle)
python-netdisco 2.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 508 kB
  • sloc: python: 1,532; xml: 247; sh: 10; makefile: 8
file content (25 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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