Skip to content

Adding enigma2 media player#15799

Closed
fbradyirl wants to merge 1 commit into
home-assistant:devfrom
fbradyirl:e2
Closed

Adding enigma2 media player#15799
fbradyirl wants to merge 1 commit into
home-assistant:devfrom
fbradyirl:e2

Conversation

@fbradyirl
Copy link
Copy Markdown
Contributor

@fbradyirl fbradyirl commented Aug 2, 2018

Description:

Adding enigma2 media player.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5984

Example entry for configuration.yaml (if applicable):

# Example configuration.yaml entry
media_player:
  - platform: enigma2
    host: 192.168.1.12
    name: Vu Duo2

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@fbradyirl
Copy link
Copy Markdown
Contributor Author

@frenck docs are now added. Thanks!

@frenck
Copy link
Copy Markdown
Member

frenck commented Aug 9, 2018

Thanks, @fbradyirl! Removed docs-missing label.

# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Enigma2 TV platform."""
name = config.get(CONF_NAME)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use dict.get(key) on required config keys or keys that have default values. Use dict[key].

add_devices([Enigma2Device(name, remote_config)])


# pylint: disable=abstract-method
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already globally disabled.

class Enigma2Device(MediaPlayerDevice):
"""Representation of a Enigma2 box."""

# pylint: disable=too-many-public-methods
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.


# pylint: disable=abstract-method
class Enigma2Device(MediaPlayerDevice):
"""Representation of a Enigma2 box."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"of an"

def __init__(self, name, config):
"""Initialize the Enigma2 device."""
import openwebif.api
self._state = STATE_UNKNOWN
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Init state to None. The base entity class will handle unknown state.

def media_title(self):
"""Title of current playing media."""
if self.currservice_serviceref.startswith('1:0:0'):
return "[Recording Playback] - " + \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use new style string formatting instead of string concatenation.

@property
def volume_level(self):
"""Volume level of the media player (0..1)."""
_LOGGER.info('self.volume : %s', self.volume)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug max. Please move this to a volume method instead, if it's really needed.


def mute_volume(self, mute):
"""Send mute command."""
self.e2_box.mute_volume()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mute parameter is a boolean saying if the muting should be true/on or false/off. Please implement that.


def update(self):
"""Update state of the media_player."""
_LOGGER.info("Updating...")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this.

vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to have this configurable? We prefer to set a hardcoded sensible timeout, if possible.

@cgarwood
Copy link
Copy Markdown
Member

cgarwood commented Nov 3, 2018

This PR seems to have gone stale. You can open a new PR when you are ready to finish.

@cgarwood cgarwood closed this Nov 3, 2018
@ghost ghost removed the in progress label Nov 3, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants