-
-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Samsung Family hub camera component #14458
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
Changes from all commits
fedc095
802b00e
e57505a
05ab976
3a38681
9451854
c47c374
3878a31
f0bafa9
4a2376e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """ | ||
| 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 | ||
|
|
||
| from homeassistant.components.camera import Camera | ||
| from homeassistant.components.sensor import PLATFORM_SCHEMA | ||
| from homeassistant.const import CONF_IP_ADDRESS, CONF_NAME | ||
| from homeassistant.helpers.aiohttp_client import async_get_clientsession | ||
| import homeassistant.helpers.config_validation as cv | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| REQUIREMENTS = ['python-family-hub-local==0.0.2'] | ||
|
|
||
| DEFAULT_NAME = 'FamilyHub Camera' | ||
|
|
||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||
| vol.Required(CONF_IP_ADDRESS): 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_ADDRESS) | ||
| 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): | ||
| """The representation of a Family Hub camera.""" | ||
|
|
||
| def __init__(self, name, family_hub_cam): | ||
| """Initialize camera component.""" | ||
| super().__init__() | ||
| self._name = name | ||
| self.family_hub_cam = family_hub_cam | ||
|
|
||
| async def camera_image(self): | ||
| """Return a still image response.""" | ||
| return await self.family_hub_cam.async_get_cam_image() | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Return the name of this camera.""" | ||
| return self._name | ||
|
|
||
| @property | ||
| def should_poll(self): | ||
| """Camera should poll periodically.""" | ||
| return True | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should this camera poll? The frontend drives the camera updates.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems I misunderstood what this does, I can fix it along with the method name later tonight and resubmit the PR.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! Please open a new PR based on fresh dev, as this PR is merged. |
||
There was a problem hiding this comment.
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.