Skip to content

DoorBird#8871

Closed
Klikini wants to merge 18 commits into
home-assistant:devfrom
Klikini:doorbird
Closed

DoorBird#8871
Klikini wants to merge 18 commits into
home-assistant:devfrom
Klikini:doorbird

Conversation

@Klikini
Copy link
Copy Markdown
Contributor

@Klikini Klikini commented Aug 6, 2017

Description:

Adds components for the DoorBird video doorbell.

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

Example entry for configuration.yaml (if applicable):

doorbird:
  host: 192.168.2.16
  username: ghaigb0001
  password: **********

binary_sensor:
  - platform: doorbird
    monitored_conditions:
      - doorbell

camera:
  - platform: doorbird
    last_visitor: true

switch:
  - platform: doorbird
    switches:
      - light_on
      - open_door

Checklist:

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.

About the older commits: I have tried everything and cannot seem to get rid of them. Help is welcome.

@mention-bot
Copy link
Copy Markdown

@Klikini, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @happyleavesaoc to be potential reviewers.

Copy link
Copy Markdown
Member

@fabaff fabaff left a comment

Choose a reason for hiding this comment

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

Please remove the commit for homeassistant/components/frontend/www_static/home-assistant-polymer.

}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_MONITORED_CONDITIONS, default=[]):
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.

If only doorbell is available then this should be the default and the configuration by the user omitted. According to the DoorBird docs there is an additional connector available. That one could be the second type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I saw that in the docs, but when I query my device, it will only return the doorbell status. I assume the docs are outdated. I'll just make it the default here.

Comment thread homeassistant/components/doorbird.py Outdated
return False
else:
_LOGGER.error("Could not connect to DoorBird at %s as %s: Error %s",
ip, username, str(status[1]))
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.

I would like to suggest to not send the username to the log file as for sharing the log file it would require to be sanitized and the chances are high that it won't happen.


if status[0]:
_LOGGER.info("Connected to DoorBird at %s as %s", ip, username)
hass.data[DOMAIN] = device
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 hass.data[DATA_YOUR_DOMAIN] instead hass.data[DOMAIN].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what this means. Do I define a new constant called DATA_DOORBIRD and use that here? But what would its value be? I'm using the Ring component as an example, and this is what is used there.

}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_SWITCHES, default=[]):
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.

Why not make switches optional with open_door as default? This seems to be one of the core features of DoorBird. Or is this just one of the two built-in relays?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If one was to be the default, I'd say light_on would be a better choice. It turns on the IR array for night vision, which all DoorBird devices include. The open_door switch is only useful if you have an electronic door strike installed.

from homeassistant.components.doorbird import DOMAIN
import homeassistant.helpers.config_validation as cv
from homeassistant.const import CONF_MONITORED_CONDITIONS, STATE_UNKNOWN
from homeassistant.util import Throttle
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 order the import.

"""A binary sensor of a DoorBird device."""
def __init__(self, device, sensor_type):
"""Initialize a binary sensor on a DoorBird device."""
if sensor_type not in SENSOR_TYPES:
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.

Already covered by the configuration validation.


def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the DoorBird binary sensor component."""
device = hass.data.get(DOMAIN)
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.

See comment on the component about this.


@property
def name(self):
""":returns: The name of the sensor."""
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 follow PEP257 for docstrings.

def icon(self):
""":returns: An icon to display."""
icon = SENSOR_TYPES[self._sensor_type]["icon"][self._state]
return "mdi:" + str(icon)
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 string formatting.

CONF_SHOW_LAST_VISITOR = 'last_visitor'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_SHOW_LAST_VISITOR, default=False): cv.boolean
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.

Should be vol.Optional if you want to set a default. Is "optional" according to your docs.


from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.doorbird import DOMAIN
from homeassistant.const import STATE_UNKNOWN
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

multiple spaces after keyword

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented Aug 18, 2017

We do you not use our lock component?

@Klikini
Copy link
Copy Markdown
Contributor Author

Klikini commented Aug 18, 2017 via email

@cveenman
Copy link
Copy Markdown

Andy, What's holding up merge of your pull request?

@Klikini
Copy link
Copy Markdown
Contributor Author

Klikini commented Aug 30, 2017

@cveenman: I don't know. @fabaff

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented Aug 30, 2017

You need cleanup your PR and remove changes on home-assistant-polymer

@Klikini
Copy link
Copy Markdown
Contributor Author

Klikini commented Sep 2, 2017

@pvizeli I'm not sure how to fix the submodule issue. I didn't make any changes to it, so I'm not sure why it always gets pushed. I tried checking out 1ea7137c78b3df577f5df72a6c9bbe91bb5f7cd0 (the diff of the submodule between this branch and home-assistant/dev is home-assistant/frontend@1ea7137...1ad4259 and it is currently checkout out as 1ad42592134c290119879e8f8505ef5736a3071e) but it creates a new hash instead.

As for cleaning up the RachioPy commits, I said I had tried and failed to do that.

Am I missing something in the docs, or does Git just hate me lately?

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented Sep 3, 2017

Make a new PR and copy you files into this new PR. That is the fast way to fix that.

@Klikini Klikini closed this Sep 3, 2017
@Klikini
Copy link
Copy Markdown
Contributor Author

Klikini commented Sep 3, 2017

#9281

@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
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.

8 participants