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
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fedc095
add familyhub.py camera
Klathmon 802b00e
fix import and REQUIREMENTS
Klathmon e57505a
add to coveragerc
Klathmon 05ab976
fix formatting to make houndci-bot happy
Klathmon 3a38681
ran scripts/gen_requirements_all.py
Klathmon 9451854
use CONF_IP_ADDRESS
Klathmon c47c374
Revert "ran scripts/gen_requirements_all.py"
Klathmon 3878a31
fix library name
Klathmon f0bafa9
add missing docstrings and enable polling
Klathmon 4a2376e
Sort imports
fabaff File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
|
||
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): | ||
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. 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): | ||
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. This should be |
||
"""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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We have
CONF_IP_ADDRESS
inconst.py
. Please use that.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.
Got it, and i'm updating the docs now