desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Return a still image response from the camera.'
| def camera_image(self):
| now = utcnow()
if self._ready_for_snapshot(now):
url = self.device.snapshot_url
try:
response = requests.get(url)
except requests.exceptions.RequestException as error:
_LOGGER.error('Error getting camera image: %s', error)
return None
... |
'Initialize an Unifi camera.'
| def __init__(self, nvr, uuid, name, password):
| super(UnifiVideoCamera, self).__init__()
self._nvr = nvr
self._uuid = uuid
self._name = name
self._password = password
self.is_streaming = False
self._connect_addr = None
self._camera = None
|
'Return the name of this camera.'
| @property
def name(self):
| return self._name
|
'Return true if the camera is recording.'
| @property
def is_recording(self):
| caminfo = self._nvr.get_camera(self._uuid)
return caminfo['recordingSettings']['fullTimeRecordEnabled']
|
'Return the brand of this camera.'
| @property
def brand(self):
| return 'Ubiquiti'
|
'Return the model of this camera.'
| @property
def model(self):
| caminfo = self._nvr.get_camera(self._uuid)
return caminfo['model']
|
'Login to the camera.'
| def _login(self):
| from uvcclient import camera as uvc_camera
caminfo = self._nvr.get_camera(self._uuid)
if self._connect_addr:
addrs = [self._connect_addr]
else:
addrs = [caminfo['host'], caminfo['internalHost']]
if (self._nvr.server_version >= (3, 2, 0)):
client_cls = uvc_camera.UVCCameraClie... |
'Return the image of this camera.'
| def camera_image(self):
| from uvcclient import camera as uvc_camera
if (not self._camera):
if (not self._login()):
return
def _get_image(retry=True):
try:
return self._camera.get_snapshot()
except uvc_camera.CameraConnectError:
_LOGGER.error('Unable to contact cam... |
'Initialize as a subclass of MjpegCamera.'
| def __init__(self, hass, device_info, monitor):
| super().__init__(hass, device_info)
self._monitor_id = int(monitor['Id'])
self._is_recording = None
|
'Update the recording state periodically.'
| @property
def should_poll(self):
| return True
|
'Update our recording state from the ZM API.'
| def update(self):
| _LOGGER.debug('Updating camera state for monitor %i', self._monitor_id)
status_response = zoneminder.get_state(('api/monitors/alarm/id:%i/command:status.json' % self._monitor_id))
if (not status_response):
_LOGGER.warning('Could not get status for monitor %i', self._... |
'Return whether the monitor is in alarm mode.'
| @property
def is_recording(self):
| return self._is_recording
|
'Initialize access to the BloomSky camera images.'
| def __init__(self, bs, device):
| super(BloomSkyCamera, self).__init__()
self._name = device['DeviceName']
self._id = device['DeviceID']
self._bloomsky = bs
self._url = ''
self._last_url = ''
self._last_image = ''
self._logger = logging.getLogger(__name__)
|
'Update the camera\'s image if it has changed.'
| def camera_image(self):
| try:
self._url = self._bloomsky.devices[self._id]['Data']['ImageURL']
self._bloomsky.refresh_devices()
if (self._url != self._last_url):
response = requests.get(self._url, timeout=10)
self._last_url = self._url
self._last_image = response.content
excep... |
'Return the name of this BloomSky device.'
| @property
def name(self):
| return self._name
|
'Initialize a Foscam camera.'
| def __init__(self, device_info):
| super(FoscamCam, self).__init__()
ip_address = device_info.get(CONF_IP)
port = device_info.get(CONF_PORT)
self._username = device_info.get(CONF_USERNAME)
self._password = device_info.get(CONF_PASSWORD)
self._name = device_info.get(CONF_NAME)
self._motion_status = False
from foscam import... |
'Return a still image reponse from the camera.'
| def camera_image(self):
| (result, response) = self._foscam_session.snap_picture_2()
if (result == FOSCAM_COMM_ERROR):
return None
return response
|
'Camera Motion Detection Status.'
| @property
def motion_detection_enabled(self):
| return self._motion_status
|
'Enable motion detection in camera.'
| def enable_motion_detection(self):
| (ret, err) = self._foscam_session.enable_motion_detection()
if (ret == FOSCAM_COMM_ERROR):
_LOGGER.debug('Unable to communicate with Foscam Camera: %s', err)
self._motion_status = True
else:
self._motion_status = False
|
'Disable motion detection.'
| def disable_motion_detection(self):
| (ret, err) = self._foscam_session.disable_motion_detection()
if (ret == FOSCAM_COMM_ERROR):
_LOGGER.debug('Unable to communicate with Foscam Camera: %s', err)
self._motion_status = True
else:
self._motion_status = False
|
'Return the name of this camera.'
| @property
def name(self):
| return self._name
|
'Initialize Verisure File Camera component.'
| def __init__(self, hass, device_label, directory_path):
| super().__init__()
self._device_label = device_label
self._directory_path = directory_path
self._image = None
self._image_id = None
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, self.delete_image)
|
'Return image response.'
| def camera_image(self):
| self.check_imagelist()
if (not self._image):
_LOGGER.debug('No image to display')
return
_LOGGER.debug('Trying to open %s', self._image)
with open(self._image, 'rb') as file:
return file.read()
|
'Check the contents of the image list.'
| def check_imagelist(self):
| hub.update_smartcam_imageseries()
image_ids = hub.get_image_info("$.imageSeries[?(@.deviceLabel=='%s')].image[0].imageId", self._device_label)
if (not image_ids):
return
new_image_id = image_ids[0]
if ((new_image_id == '-1') or (self._image_id == new_image_id)):
_LOGGER.debug('The ... |
'Delete an old image.'
| def delete_image(self, event):
| remove_image = os.path.join(self._directory_path, '{}{}'.format(self._image_id, '.jpg'))
try:
os.remove(remove_image)
_LOGGER.debug('Deleting old image %s', remove_image)
except OSError as error:
if (error.errno != errno.ENOENT):
raise
|
'Return the name of this camera.'
| @property
def name(self):
| return hub.get_first("$.customerImageCameras[?(@.deviceLabel=='%s')].area", self._device_label)
|
'Initialize Local File Camera component.'
| def __init__(self, name, file_path):
| super().__init__()
self._name = name
self._file_path = file_path
(content, _) = mimetypes.guess_type(file_path)
if (content is not None):
self.content_type = content
|
'Return image response.'
| def camera_image(self):
| try:
with open(self._file_path, 'rb') as file:
return file.read()
except FileNotFoundError:
_LOGGER.warning('Could not read camera %s image from file: %s', self._name, self._file_path)
|
'Return the name of this camera.'
| @property
def name(self):
| return self._name
|
'Initialize Neato cleaning map.'
| def __init__(self, hass, robot):
| super().__init__()
self.robot = robot
self._robot_name = '{} {}'.format(self.robot.name, 'Cleaning Map')
self._robot_serial = self.robot.serial
self.neato = hass.data[NEATO_LOGIN]
self._image_url = None
self._image = None
|
'Return image response.'
| def camera_image(self):
| self.update()
return self._image
|
'Check the contents of the map list.'
| @Throttle(timedelta(seconds=10))
def update(self):
| self.neato.update_robots()
image_url = None
map_data = self.hass.data[NEATO_MAP_DATA]
image_url = map_data[self._robot_serial]['maps'][0]['url']
if (image_url == self._image_url):
_LOGGER.debug('The map image_url is the same as old')
return
image = self.neato... |
'Return the name of this camera.'
| @property
def name(self):
| return self._robot_name
|
'Set up for access to the Netatmo camera images.'
| def __init__(self, data, camera_name, home, camera_type, verify_ssl):
| super(NetatmoCamera, self).__init__()
self._data = data
self._camera_name = camera_name
self._verify_ssl = verify_ssl
if home:
self._name = ((home + ' / ') + camera_name)
else:
self._name = camera_name
camera_id = data.camera_data.cameraByName(camera=camera_name, home=h... |
'Return a still image response from the camera.'
| def camera_image(self):
| try:
if self._localurl:
response = requests.get('{0}/live/snapshot_720.jpg'.format(self._localurl), timeout=10)
elif self._vpnurl:
response = requests.get('{0}/live/snapshot_720.jpg'.format(self._vpnurl), timeout=10, verify=self._verify_ssl)
else:
_LOGGER.... |
'Return the name of this Netatmo camera device.'
| @property
def name(self):
| return self._name
|
'Return the camera brand.'
| @property
def brand(self):
| return 'Netatmo'
|
'Return the camera model.'
| @property
def model(self):
| if (self._cameratype == 'NOC'):
return 'Presence'
elif (self._cameratype == 'NACamera'):
return 'Welcome'
return None
|
'Return the unique ID for this sensor.'
| @property
def unique_id(self):
| return self._unique_id
|
'Initialize Raspberry Pi camera component.'
| def __init__(self, device_info):
| super().__init__()
self._name = device_info[CONF_NAME]
self._config = device_info
kill_raspistill()
cmd_args = ['raspistill', '--nopreview', '-o', device_info[CONF_FILE_PATH], '-t', '0', '-w', str(device_info[CONF_IMAGE_WIDTH]), '-h', str(device_info[CONF_IMAGE_HEIGHT]), '-tl', str(device_info[CONF_... |
'Return raspstill image response.'
| def camera_image(self):
| with open(self._config[CONF_FILE_PATH], 'rb') as file:
return file.read()
|
'Return the name of this camera.'
| @property
def name(self):
| return self._name
|
'Initialize a camera.'
| def __init__(self, hass, config, data, name):
| super().__init__()
self.data = data
self.hass = hass
self._name = name
self.notifications = self.data.cameras[self._name].notifications
self.response = None
_LOGGER.info('Initialized blink camera %s', self._name)
|
'Return the camera name.'
| @property
def name(self):
| return self._name
|
'Request a new image from Blink servers.'
| @Throttle(MIN_TIME_BETWEEN_UPDATES)
def request_image(self):
| _LOGGER.info('Requesting new image from blink servers')
image_url = self.check_for_motion()
header = self.data.cameras[self._name].header
self.response = requests.get(image_url, headers=header, stream=True)
|
'Check if motion has been detected since last update.'
| def check_for_motion(self):
| self.data.refresh()
notifs = self.data.cameras[self._name].notifications
if (notifs > self.notifications):
self.data.last_motion()
self.notifications = notifs
elif (notifs < self.notifications):
self.notifications = notifs
return self.data.camera_thumbs[self._name]
|
'Return a still image reponse from the camera.'
| def camera_image(self):
| self.request_image()
return self.response.content
|
'Initialize Axis Communications camera component.'
| def __init__(self, hass, config):
| super().__init__(hass, config)
async_dispatcher_connect(hass, (((DOMAIN + '_') + config[CONF_NAME]) + '_new_ip'), self._new_ip)
|
'Set new IP for video stream.'
| def _new_ip(self, host):
| self._mjpeg_url = _get_image_url(host, 'mjpeg')
self._still_image_url = _get_image_url(host, 'mjpeg')
|
'Initialize the MQTT Camera.'
| def __init__(self, name, topic):
| super().__init__()
self._name = name
self._topic = topic
self._qos = 0
self._last_image = None
|
'Return image response.'
| @asyncio.coroutine
def async_camera_image(self):
| return self._last_image
|
'Return the name of this camera.'
| @property
def name(self):
| return self._name
|
'Subscribe MQTT events.
This method must be run in the event loop and returns a coroutine.'
| def async_added_to_hass(self):
| @callback
def message_received(topic, payload, qos):
'Handle new MQTT messages.'
self._last_image = payload
return mqtt.async_subscribe(self.hass, self._topic, message_received, self._qos, None)
|
'Initialize demo camera component.'
| def __init__(self, hass, config, name):
| super().__init__()
self._parent = hass
self._name = name
self._motion_status = False
|
'Return a faked still image response.'
| def camera_image(self):
| now = dt_util.utcnow()
image_path = os.path.join(os.path.dirname(__file__), 'demo_{}.jpg'.format((now.second % 4)))
with open(image_path, 'rb') as file:
return file.read()
|
'Return the name of this camera.'
| @property
def name(self):
| return self._name
|
'Camera should poll periodically.'
| @property
def should_poll(self):
| return True
|
'Camera Motion Detection Status.'
| @property
def motion_detection_enabled(self):
| return self._motion_status
|
'Enable the Motion detection in base station (Arm).'
| def enable_motion_detection(self):
| self._motion_status = True
|
'Disable the motion detection in base station (Disarm).'
| def disable_motion_detection(self):
| self._motion_status = False
|
'Initialize the Verisure hub.'
| def __init__(self, domain_config, verisure):
| self.overview = {}
self.imageseries = {}
self.config = domain_config
self._verisure = verisure
self._lock = threading.Lock()
self.session = verisure.Session(domain_config[CONF_USERNAME], domain_config[CONF_PASSWORD])
import jsonpath
self.jsonpath = jsonpath.jsonpath
|
'Login to Verisure.'
| def login(self):
| try:
self.session.login()
except self._verisure.Error as ex:
_LOGGER.error('Could not log in to verisure, %s', ex)
return False
return True
|
'Logout from Verisure.'
| def logout(self):
| try:
self.session.logout()
except self._verisure.Error as ex:
_LOGGER.error('Could not log out from verisure, %s', ex)
return False
return True
|
'Update the overview.'
| @Throttle(timedelta(seconds=60))
def update_overview(self):
| try:
self.overview = self.session.get_overview()
except self._verisure.ResponseError as ex:
_LOGGER.error('Could not read overview, %s', ex)
if (ex.status_code == 503):
_LOGGER.info('Trying to log in again')
self.login()
else:
... |
'Update the image series.'
| @Throttle(timedelta(seconds=60))
def update_smartcam_imageseries(self):
| self.imageseries = self.session.get_camera_imageseries()
|
'Capture a new image from a smartcam.'
| @Throttle(timedelta(seconds=30))
def smartcam_capture(self, device_id):
| self.session.capture_image(device_id)
|
'Get values from the overview that matches the jsonpath.'
| def get(self, jpath, *args):
| res = self.jsonpath(self.overview, (jpath % args))
return (res if res else [])
|
'Get first value from the overview that matches the jsonpath.'
| def get_first(self, jpath, *args):
| res = self.get(jpath, *args)
return (res[0] if res else None)
|
'Get values from the imageseries that matches the jsonpath.'
| def get_image_info(self, jpath, *args):
| res = self.jsonpath(self.imageseries, (jpath % args))
return (res if res else [])
|
'Initialie Asterisk mailbox.'
| def __init__(self, hass, name):
| super().__init__(hass, name)
async_dispatcher_connect(self.hass, SIGNAL_MESSAGE_UPDATE, self._update_callback)
|
'Update the message count in HA, if needed.'
| @callback
def _update_callback(self, msg):
| self.async_update()
|
'Return the supported media type.'
| @property
def media_type(self):
| return CONTENT_TYPE_MPEG
|
'Return the media blob for the msgid.'
| @asyncio.coroutine
def async_get_media(self, msgid):
| from asterisk_mbox import ServerError
client = self.hass.data[DOMAIN].client
try:
return client.mp3(msgid, sync=True)
except ServerError as err:
raise StreamError(err)
|
'Return a list of the current messages.'
| @asyncio.coroutine
def async_get_messages(self):
| return self.hass.data[DOMAIN].messages
|
'Delete the specified messages.'
| def async_delete(self, msgid):
| client = self.hass.data[DOMAIN].client
_LOGGER.info('Deleting: %s', msgid)
client.delete(msgid)
return True
|
'Initialize Demo mailbox.'
| def __init__(self, hass, name):
| super().__init__(hass, name)
self._messages = {}
txt = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '
for idx in range(0, 10):
msgtime = int((dt.as_timestamp(dt.utcnow()) - ((3600 * 24) * (10 - idx))))
msgtxt = 'Message {}. {}'.format((idx + 1),... |
'Return the supported media type.'
| @property
def media_type(self):
| return CONTENT_TYPE_MPEG
|
'Return the media blob for the msgid.'
| @asyncio.coroutine
def async_get_media(self, msgid):
| if (msgid not in self._messages):
raise StreamError('Message not found')
audio_path = os.path.join(os.path.dirname(__file__), '..', 'tts', 'demo.mp3')
with open(audio_path, 'rb') as file:
return file.read()
|
'Return a list of the current messages.'
| @asyncio.coroutine
def async_get_messages(self):
| return sorted(self._messages.values(), key=(lambda item: item['info']['origtime']), reverse=True)
|
'Delete the specified messages.'
| def async_delete(self, msgid):
| if (msgid in self._messages):
_LOGGER.info('Deleting: %s', msgid)
del self._messages[msgid]
self.async_update()
return True
|
'Init velux scene.'
| def __init__(self, hass, scene):
| _LOGGER.info('Adding VELUX scene: %s', scene)
self.hass = hass
self.scene = scene
|
'Return the name of the scene.'
| @property
def name(self):
| return self.scene.name
|
'Return that polling is not necessary.'
| @property
def should_poll(self):
| return False
|
'There is no way of detecting if a scene is active (yet).'
| @property
def is_on(self):
| return False
|
'Activate the scene.'
| def activate(self, **kwargs):
| self.hass.async_add_job(self.scene.run())
|
'Initialize the Lutron Caseta scene.'
| def __init__(self, scene, bridge):
| self._scene_name = scene['name']
self._scene_id = scene['scene_id']
self._bridge = bridge
|
'Return the name of the scene.'
| @property
def name(self):
| return self._scene_name
|
'Return that polling is not necessary.'
| @property
def should_poll(self):
| return False
|
'There is no way of detecting if a scene is active (yet).'
| @property
def is_on(self):
| return False
|
'Activate the scene.'
| def activate(self, **kwargs):
| self._bridge.activate_scene(self._scene_id)
|
'Initialize the scene.'
| def __init__(self, lj, i, name):
| self._lj = lj
self._index = i
self._name = name
|
'Return the name of the scene.'
| @property
def name(self):
| return self._name
|
'Return that polling is not necessary.'
| @property
def should_poll(self):
| return False
|
'Return the device-specific state attributes.'
| @property
def device_state_attributes(self):
| return {ATTR_NUMBER: self._index}
|
'Activate the scene.'
| def activate(self, **kwargs):
| self._lj.activate_scene(self._index)
|
'Initialize the Wink device.'
| def __init__(self, wink, hass):
| super().__init__(wink, hass)
hass.data[DOMAIN]['entities']['scene'].append(self)
|
'Callback when entity is added to hass.'
| @asyncio.coroutine
def async_added_to_hass(self):
| self.hass.data[DOMAIN]['entities']['scene'].append(self)
|
'Python-wink will always return False.'
| @property
def is_on(self):
| return self.wink.state()
|
'Activate the scene.'
| def activate(self, **kwargs):
| self.wink.activate()
|
'Initialize the Neato hub.'
| def __init__(self, hass, domain_config, neato):
| self.config = domain_config
self._neato = neato
self._hass = hass
self.my_neato = neato(domain_config[CONF_USERNAME], domain_config[CONF_PASSWORD])
self._hass.data[NEATO_ROBOTS] = self.my_neato.robots
self._hass.data[NEATO_MAP_DATA] = self.my_neato.maps
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.