You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
868 B

4 years ago
  1. """Discover Samsung Smart TV services."""
  2. from . import SSDPDiscoverable
  3. from ..const import ATTR_NAME
  4. # For some models, Samsung forces a [TV] prefix to the user-specified name.
  5. FORCED_NAME_PREFIX = '[TV]'
  6. class Discoverable(SSDPDiscoverable):
  7. """Add support for discovering Samsung Smart TV services."""
  8. def get_entries(self):
  9. """Get all the Samsung RemoteControlReceiver entries."""
  10. return self.find_by_st(
  11. "urn:samsung.com:device:RemoteControlReceiver:1")
  12. def info_from_entry(self, entry):
  13. """Get most important info, by default the description location."""
  14. info = super().info_from_entry(entry)
  15. # Strip the forced prefix, if present
  16. if info[ATTR_NAME].startswith(FORCED_NAME_PREFIX):
  17. info[ATTR_NAME] = info[ATTR_NAME][len(FORCED_NAME_PREFIX):].strip()
  18. return info