Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Xiaomi TV platform. #12359

Merged
merged 4 commits into from Feb 16, 2018

Conversation

@simse
Copy link
Contributor

commented Feb 12, 2018

Description:

This pull request adds the platform Xiaomi TV, implementing the pymitv Python library.

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

Example entry for configuration.yaml (if applicable):

media_player:
  - platform: xiaomi_tv
    host: 192.168.0.41 # Optional
    name: Mi TV 3s # Optional

Checklist:

  • The code change is tested and works locally.

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.
# No host is needed for configuration, however it can be set.
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_HOST): cv.string,
vol.Optional(CONF_NAME): cv.string,

This comment has been minimized.

Copy link
@Danielhiversen

Danielhiversen Feb 13, 2018

Member

Add , default="Xiaomi TV"
Then you do not need the if check on line 46

This comment has been minimized.

Copy link
@simse

simse Feb 13, 2018

Author Contributor

I like that much better. Very elegant. Will update right away.

@property
def state(self):
"""Return _state variable, containing the appropriate constant."""
return self._state

This comment has been minimized.

Copy link
@Danielhiversen

Danielhiversen Feb 13, 2018

Member

Is it not possible to get the state from the TV?

This comment has been minimized.

Copy link
@simse

simse Feb 13, 2018

Author Contributor

No, and that is the main limitation of this platform. However, as it stands there's two options, when controlling power on the TV:

  • Currently, the TV sleeps and wakes up. This makes for instant turn on and off, however, it sacrifices ability to know state.
  • Another option, is to turn off the TV properly, then we would know the state for sure, but you would't be able to turn it on again. When user then manually turns the TV back on with the remote, it takes a couple of minutes.

I thought the first option sounded better.

class XiaomiTV(MediaPlayerDevice):
"""Represent the Xiaomi TV for Home Assistant."""

def __init__(self, ip, name=DEFAULT_TV):

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 13, 2018

undefined name 'DEFAULT_TV'


REQUIREMENTS = ['pymitv==1.0.0']

DEFAULT_NAME="Xiaomi TV"

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 13, 2018

missing whitespace around operator

@simse simse changed the title Added the Xiaomi TV platform. Add the Xiaomi TV platform. Feb 13, 2018


@property
def state(self):
"""Return _state variable, containing the appropriate constant."""

This comment has been minimized.

Copy link
@balloob
@balloob

This comment has been minimized.

Copy link
Member

commented Feb 16, 2018

Add that it's an assumed state and it's ok to merge:

    @property
    def assumed_state(self) -> bool:
        """Return True if unable to access real state of the entity."""
        return True

@balloob balloob merged commit dd7bffc into home-assistant:dev Feb 16, 2018

4 of 5 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
coverage/coveralls Coverage decreased (-0.004%) to 94.057%
Details
hound No violations found. Woof!
@MartinHjelmare
Copy link
Member

left a comment

Some small things that can be improved in a future PR.

Add support for the Xiaomi TVs.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/xiaomi_tv/

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Feb 17, 2018

Member

The url is wrong. Look at an existing platform to see the correct format.

This comment has been minimized.

Copy link
@simse

simse Feb 17, 2018

Author Contributor

Right yes, I had absolutely missed that. The correct url would be https://home-assistant.io/components/media_player.xiaomi_tv/.

"""

import logging
import voluptuous as vol

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Feb 17, 2018

Member

Add a blank line between standard library and 3rd party imports.

This comment has been minimized.

Copy link
@simse

simse Feb 17, 2018

Author Contributor

Just looked at another platform, and you're absolutely right. Will update in next pull request.

@balloob balloob referenced this pull request Feb 22, 2018

Merged

0.64.0 #12609

@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.