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

Samsung Family hub camera component #14458

Merged
merged 10 commits into from May 14, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Expand Up @@ -347,6 +347,7 @@ omit =
homeassistant/components/calendar/todoist.py
homeassistant/components/camera/bloomsky.py
homeassistant/components/camera/canary.py
homeassistant/components/camera/familyhub.py
homeassistant/components/camera/ffmpeg.py
homeassistant/components/camera/foscam.py
homeassistant/components/camera/mjpeg.py
Expand Down
60 changes: 60 additions & 0 deletions homeassistant/components/camera/familyhub.py
@@ -0,0 +1,60 @@
"""
Family Hub camera for Samsung Refrigerators.

For more details about this platform, please refer to the documentation
https://home-assistant.io/components/camera.familyhub/
"""
import logging
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (CONF_NAME)
from homeassistant.components.camera import Camera
from homeassistant.helpers.aiohttp_client import async_get_clientsession

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['pyfamilyhublocal==0.0.2']

CONF_IP = 'address'
Copy link
Member

Choose a reason for hiding this comment

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

We have CONF_IP_ADDRESS in const.py. Please use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, and i'm updating the docs now


DEFAULT_NAME = 'FamilyHub Camera'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_IP): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
})


async def async_setup_platform(hass,
config, async_add_devices, discovery_info=None):
"""Set up the Family Hub Camera."""
from pyfamilyhublocal import FamilyHubCam
address = config.get(CONF_IP)
name = config.get(CONF_NAME)

session = async_get_clientsession(hass)
family_hub_cam = FamilyHubCam(address, hass.loop, session)

async_add_devices([FamilyHubCamera(name, family_hub_cam)], True)


class FamilyHubCamera(Camera):

Choose a reason for hiding this comment

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

too many blank lines (3)


def __init__(self, name, family_hub_cam):
super().__init__()
self._name = name
self.family_hub_cam = family_hub_cam

async def camera_image(self):
Copy link
Member

Choose a reason for hiding this comment

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

This should be async_camera_image.

"""Return a still image response."""
return await self.family_hub_cam.async_get_cam_image()

@property
def name(self):
return self._name

@property
def should_poll(self):
return False
3 changes: 3 additions & 0 deletions requirements_all.txt
Expand Up @@ -474,6 +474,9 @@ libnacl==1.6.1
# homeassistant.components.dyson
libpurecoollink==0.4.2

# homeassistant.components.camera.foscam
pyfamilyhublocal==0.0.2

# homeassistant.components.camera.foscam
libpyfoscam==1.0

Expand Down