DoorBird Component#9281
Conversation
| """Wait for the correct amount of assumed time to pass.""" | ||
| if self._state and self._assume_off <= datetime.datetime.now(): | ||
| self._state = False | ||
| self._assume_off = datetime.datetime.min No newline at end of file |
| else: | ||
| _LOGGER.error("Could not connect to DoorBird at %s: Error %s", | ||
| ip, str(status[1])) | ||
| return False No newline at end of file |
|
|
||
| def disable_motion_detection(self): | ||
| """Network callbacks are not supported by HA yet.""" | ||
| pass No newline at end of file |
| @Throttle(_MIN_UPDATE_INTERVAL) | ||
| def update(self): | ||
| """Pull the latest value from the device.""" | ||
| self._state = self._device.doorbell_state() No newline at end of file |
|
Fix lint please... |
| """Initialize a binary sensor on a DoorBird device.""" | ||
| self._device = device | ||
| self._sensor_type = sensor_type | ||
| self._state = STATE_UNKNOWN |
| class DoorBirdCamera(Camera): | ||
| """The camera on a DoorBird device.""" | ||
|
|
||
| def __init__(self, hass, url, name, interval=None): |
There was a problem hiding this comment.
Don't pass in hass. It will be set on the entity when it has been added to home assistant.
There was a problem hiding this comment.
What do I replace the references with to access that? self.hass?
|
|
||
| add_devices(switches) | ||
| _LOGGER.info("Added DoorBird switches") | ||
| return True |
There was a problem hiding this comment.
Platforms for EntityComponent should not return anything.
| """A relay in a DoorBird device.""" | ||
| def __init__(self, device, switch): | ||
| """Initialize a relay in a DoorBird device.""" | ||
| if switch not in SWITCHES: |
There was a problem hiding this comment.
You already validate this in the config schema.
|
|
||
| now = datetime.datetime.now() | ||
| self._assume_off = now + SWITCHES[self._switch]["time"] | ||
| return True |
|
|
||
| def turn_off(self, **kwargs): | ||
| """The relays are time-based and cannot be turned off.""" | ||
| return False |
There was a problem hiding this comment.
Raise not implemented error.
| "icon": { | ||
| True: "bell-ring", | ||
| False: "bell", | ||
| "None": "bell-outline" |
There was a problem hiding this comment.
Why not map this to None?
There was a problem hiding this comment.
I assumed None behaved like null and would cause problems. I guess not!
| """Get the name of the camera.""" | ||
| return self._name | ||
|
|
||
| def camera_image(self): |
There was a problem hiding this comment.
Remove this. Since you implement the async version you don't need the sync version.
|
|
||
| def enable_motion_detection(self): | ||
| """Network callbacks are not supported by HA yet.""" | ||
| pass |
There was a problem hiding this comment.
Don't overwrite if you don't support it.
|
|
||
| def disable_motion_detection(self): | ||
| """Network callbacks are not supported by HA yet.""" | ||
| pass |
There was a problem hiding this comment.
Don't overwrite if you don't support it.
| import async_timeout | ||
|
|
||
| from homeassistant.components.camera import PLATFORM_SCHEMA, Camera | ||
| from homeassistant.components.doorbird import DOMAIN |
| switches = [] | ||
| for switch in SWITCHES: | ||
| if switch in config.get(CONF_SWITCHES): | ||
| _LOGGER.debug("Adding DoorBird switch " + |
There was a problem hiding this comment.
_LOGGER.debug("Adding DoorBird switch %s", SWITCHES[switch]["name"])| _LIVE_INTERVAL)] | ||
|
|
||
| if config.get(CONF_SHOW_LAST_VISITOR): | ||
| _LOGGER.debug("Adding DoorBird camera " + _CAMERA_LAST_VISITOR) |
There was a problem hiding this comment.
_LOGGER.debug("Adding DoorBird camera %s", _CAMERA_LAST_VISITOR)| """Set up the DoorBird camera platform.""" | ||
| device = hass.data.get(DOMAIN) | ||
|
|
||
| _LOGGER.debug("Adding DoorBird camera " + _CAMERA_LIVE) |
There was a problem hiding this comment.
_LOGGER.debug("Adding DoorBird camera %s", _CAMERA_LIVE)| self._device = device | ||
| self._sensor_type = sensor_type | ||
| self._state = None | ||
| super(DoorBirdBinarySensor, self).__init__() |
There was a problem hiding this comment.
Remove. There's no init methods in the parent classes.
|
|
||
| async_add_devices(entities) | ||
| _LOGGER.info("Added DoorBird camera(s)") | ||
| return True |
There was a problem hiding this comment.
'homeassistant.util.async.run_coroutine_threadsafe' imported but unused
MartinHjelmare
left a comment
There was a problem hiding this comment.
One fix and this should be good to go.
| """Set up the DoorBird binary sensor component.""" | ||
| device = hass.data.get(DOORBIRD_DOMAIN) | ||
| add_devices([DoorBirdBinarySensor(device, "doorbell")], True) | ||
| return True |
There was a problem hiding this comment.
Remove. Sorry I missed it before.
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):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.