Exemplo n.º 1
0
                    CONF_ID, CONF_DELTA, CONF_FRAMES, CONF_LOCATION))
    return config


LOCATIONS_MSG = "Set '{}' to one of: {}".format(CONF_LOCATION,
                                                ", ".join(sorted(LOCATIONS)))
XOR_MSG = f"Specify exactly one of '{CONF_ID}' or '{CONF_LOCATION}'"

PLATFORM_SCHEMA = vol.All(
    PLATFORM_SCHEMA.extend({
        vol.Exclusive(CONF_ID, "xor", msg=XOR_MSG):
        cv.string,
        vol.Exclusive(CONF_LOCATION, "xor", msg=XOR_MSG):
        vol.In(LOCATIONS, msg=LOCATIONS_MSG),
        vol.Optional(CONF_DELTA):
        cv.positive_int,
        vol.Optional(CONF_FRAMES):
        cv.positive_int,
        vol.Optional(CONF_NAME):
        cv.string,
        vol.Optional(CONF_OUTFILE):
        cv.string,
    }),
    _validate_schema,
)


def setup_platform(opp, config, add_entities, discovery_info=None):
    """Set up BOM radar-loop camera component."""
    location = config.get(CONF_LOCATION) or "ID {}".format(config.get(CONF_ID))
    name = config.get(CONF_NAME) or f"BOM Radar Loop - {location}"
    args = [
Exemplo n.º 2
0
_LOGGER = logging.getLogger(__name__)

CONF_NVR = "nvr"
CONF_KEY = "key"

DEFAULT_PASSWORD = "******"
DEFAULT_PORT = 7080
DEFAULT_SSL = False

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_NVR):
    cv.string,
    vol.Required(CONF_KEY):
    cv.string,
    vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD):
    cv.string,
    vol.Optional(CONF_PORT, default=DEFAULT_PORT):
    cv.port,
    vol.Optional(CONF_SSL, default=DEFAULT_SSL):
    cv.boolean,
})


def setup_platform(opp, config, add_entities, discovery_info=None):
    """Discover cameras on a Unifi NVR."""
    addr = config[CONF_NVR]
    key = config[CONF_KEY]
    password = config[CONF_PASSWORD]
    port = config[CONF_PORT]
    ssl = config[CONF_SSL]
Exemplo n.º 3
0
DEFAULT_NAME = "Generic Camera"
GET_IMAGE_TIMEOUT = 10

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_STILL_IMAGE_URL):
    cv.template,
    vol.Optional(CONF_STREAM_SOURCE):
    cv.template,
    vol.Optional(CONF_AUTHENTICATION, default=HTTP_BASIC_AUTHENTICATION):
    vol.In([HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION]),
    vol.Optional(CONF_LIMIT_REFETCH_TO_URL_CHANGE, default=False):
    cv.boolean,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Optional(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_CONTENT_TYPE, default=DEFAULT_CONTENT_TYPE):
    cv.string,
    vol.Optional(CONF_FRAMERATE, default=2):
    vol.Any(cv.small_float, cv.positive_int),
    vol.Optional(CONF_VERIFY_SSL, default=True):
    cv.boolean,
    vol.Optional(CONF_RTSP_TRANSPORT):
    vol.In(ALLOWED_RTSP_TRANSPORT_PROTOCOLS),
})


async def async_setup_platform(opp,
                               config,
Exemplo n.º 4
0
CONF_MJPEG_URL = "mjpeg_url"
CONF_STILL_IMAGE_URL = "still_image_url"
CONTENT_TYPE_HEADER = "Content-Type"

DEFAULT_NAME = "Mjpeg Camera"
DEFAULT_VERIFY_SSL = True

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_MJPEG_URL):
    cv.url,
    vol.Optional(CONF_STILL_IMAGE_URL):
    cv.url,
    vol.Optional(CONF_AUTHENTICATION, default=HTTP_BASIC_AUTHENTICATION):
    vol.In([HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION]),
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Optional(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL):
    cv.boolean,
})


async def async_setup_platform(opp,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up a MJPEG IP Camera."""
    filter_urllib3_logging()
Exemplo n.º 5
0
from .const import (
    CONF_RTSP_PORT,
    CONF_STREAM,
    DOMAIN,
    LOGGER,
    SERVICE_PTZ,
    SERVICE_PTZ_PRESET,
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required("ip"):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_NAME, default="Foscam Camera"):
    cv.string,
    vol.Optional(CONF_PORT, default=88):
    cv.port,
    vol.Optional(CONF_RTSP_PORT):
    cv.port,
})

DIR_UP = "up"
DIR_DOWN = "down"
DIR_LEFT = "left"
DIR_RIGHT = "right"

DIR_TOPLEFT = "top_left"
DIR_TOPRIGHT = "top_right"
DIR_BOTTOMLEFT = "bottom_left"
Exemplo n.º 6
0
    MqttDiscoveryUpdate,
    MqttEntityDeviceInfo,
    subscription,
)
from .discovery import MQTT_DISCOVERY_NEW, clear_discovery_hash

_LOGGER = logging.getLogger(__name__)

CONF_TOPIC = "topic"
DEFAULT_NAME = "MQTT Camera"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Required(CONF_TOPIC):
    mqtt.valid_subscribe_topic,
    vol.Optional(CONF_UNIQUE_ID):
    cv.string,
    vol.Optional(CONF_DEVICE):
    mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA,
})


async def async_setup_platform(opp: OpenPeerPowerType,
                               config: ConfigType,
                               async_add_entities,
                               discovery_info=None):
    """Set up MQTT camera through configuration.yaml."""
    await _async_setup_entity(config, async_add_entities)


async def async_setup_entry(opp, config_entry, async_add_entities):
Exemplo n.º 7
0
CONF_FFMPEG_ARGUMENTS = "ffmpeg_arguments"
CONF_MODEL = "model"

MODEL_YI = "yi"
MODEL_XIAOFANG = "xiaofang"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_NAME):
    cv.string,
    vol.Required(CONF_HOST):
    cv.template,
    vol.Required(CONF_MODEL):
    vol.Any(MODEL_YI, MODEL_XIAOFANG),
    vol.Optional(CONF_PORT, default=DEFAULT_PORT):
    cv.port,
    vol.Optional(CONF_PATH, default=DEFAULT_PATH):
    cv.string,
    vol.Optional(CONF_USERNAME, default=DEFAULT_USERNAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_FFMPEG_ARGUMENTS, default=DEFAULT_ARGUMENTS):
    cv.string,
})


async def async_setup_platform(opp,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up a Xiaomi Camera."""
Exemplo n.º 8
0
from .const import (
    CONF_FFMPEG_ARGUMENTS,
    DATA_COORDINATOR,
    DEFAULT_FFMPEG_ARGUMENTS,
    DEFAULT_TIMEOUT,
    DOMAIN,
    MANUFACTURER,
)
from .coordinator import CanaryDataUpdateCoordinator

MIN_TIME_BETWEEN_SESSION_RENEW: Final = timedelta(seconds=90)

PLATFORM_SCHEMA: Final = vol.All(
    cv.deprecated(CONF_FFMPEG_ARGUMENTS),
    PARENT_PLATFORM_SCHEMA.extend({
        vol.Optional(CONF_FFMPEG_ARGUMENTS, default=DEFAULT_FFMPEG_ARGUMENTS):
        cv.string
    }),
)


async def async_setup_entry(
    opp: OpenPeerPower,
    entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up Canary sensors based on a config entry."""
    coordinator: CanaryDataUpdateCoordinator = opp.data[DOMAIN][
        entry.entry_id][DATA_COORDINATOR]
    ffmpeg_arguments: str = entry.options.get(CONF_FFMPEG_ARGUMENTS,
                                              DEFAULT_FFMPEG_ARGUMENTS)
    cameras: list[CanaryCamera] = []
Exemplo n.º 9
0
)

_LOGGER = logging.getLogger(__name__)

# Maximum range according to docs
DIM_RANGE = vol.All(vol.Coerce(int), vol.Range(min=120, max=700))

# Multiple choice for available Radar Map URL
SUPPORTED_COUNTRY_CODES = ["NL", "BE"]

PLATFORM_SCHEMA = vol.All(
    PLATFORM_SCHEMA.extend(
        {
            vol.Optional(CONF_DIMENSION, default=512): DIM_RANGE,
            vol.Optional(CONF_DELTA, default=600.0): cv.positive_float,
            vol.Optional(CONF_NAME, default="Buienradar loop"): cv.string,
            vol.Optional(CONF_COUNTRY, default="NL"): vol.All(
                vol.Coerce(str), vol.In(SUPPORTED_COUNTRY_CODES)
            ),
        }
    )
)


async def async_setup_platform(opp, config, async_add_entities, discovery_info=None):
    """Set up buienradar camera platform."""
    _LOGGER.warning(
        "Platform configuration is deprecated, will be removed in a future release"
    )


async def async_setup_entry(
Exemplo n.º 10
0
ATTR_UPDATED = "updated"

CONF_ATTRIBUTION = "Data provided by Environment Canada"
CONF_STATION = "station"
CONF_LOOP = "loop"
CONF_PRECIP_TYPE = "precip_type"

MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(minutes=10)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_LOOP, default=True):
    cv.boolean,
    vol.Optional(CONF_NAME):
    cv.string,
    vol.Optional(CONF_STATION):
    cv.matches_regex(r"^C[A-Z]{4}$|^[A-Z]{3}$"),
    vol.Inclusive(CONF_LATITUDE, "latlon"):
    cv.latitude,
    vol.Inclusive(CONF_LONGITUDE, "latlon"):
    cv.longitude,
    vol.Optional(CONF_PRECIP_TYPE):
    vol.In(["RAIN", "SNOW"]),
})


def setup_platform(opp, config, add_devices, discovery_info=None):
    """Set up the Environment Canada camera."""

    if config.get(CONF_STATION):
        radar_object = ECRadar(station_id=config[CONF_STATION],
                               precip_type=config.get(CONF_PRECIP_TYPE))
    else:
Exemplo n.º 11
0
MODE_RESIZE = "resize"
MODE_CROP = "crop"

DEFAULT_BASENAME = "Camera Proxy"
DEFAULT_QUALITY = 75

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_ENTITY_ID): cv.entity_id,
        vol.Optional(CONF_NAME): cv.string,
        vol.Optional(CONF_CACHE_IMAGES, False): cv.boolean,
        vol.Optional(CONF_FORCE_RESIZE, False): cv.boolean,
        vol.Optional(CONF_MODE, default=MODE_RESIZE): vol.In([MODE_RESIZE, MODE_CROP]),
        vol.Optional(CONF_IMAGE_QUALITY): int,
        vol.Optional(CONF_IMAGE_REFRESH_RATE): float,
        vol.Optional(CONF_MAX_IMAGE_WIDTH): int,
        vol.Optional(CONF_MAX_IMAGE_HEIGHT): int,
        vol.Optional(CONF_MAX_STREAM_WIDTH): int,
        vol.Optional(CONF_MAX_STREAM_HEIGHT): int,
        vol.Optional(CONF_IMAGE_LEFT): int,
        vol.Optional(CONF_IMAGE_TOP): int,
        vol.Optional(CONF_STREAM_QUALITY): int,
    }
)


async def async_setup_platform(opp, config, async_add_entities, discovery_info=None):
    """Set up the Proxy camera platform."""
    async_add_entities([ProxyCamera(opp, config)])

Exemplo n.º 12
0
"""Family Hub camera for Samsung Refrigerators."""
from pyfamilyhublocal import FamilyHubCam
import voluptuous as vol

from openpeerpower.components.camera import PLATFORM_SCHEMA, Camera
from openpeerpower.const import CONF_IP_ADDRESS, CONF_NAME
from openpeerpower.helpers.aiohttp_client import async_get_clientsession
import openpeerpower.helpers.config_validation as cv

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(opp, config, async_add_entities, discovery_info=None):
    """Set up the Family Hub Camera."""

    address = config.get(CONF_IP_ADDRESS)
    name = config.get(CONF_NAME)

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

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

Exemplo n.º 13
0
DEFAULT_NAME = "VIVOTEK Camera"
DEFAULT_EVENT_0_KEY = "event_i0_enable"
DEFAULT_SECURITY_LEVEL = "admin"
DEFAULT_STREAM_SOURCE = "live.sdp"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_IP_ADDRESS):
    cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_AUTHENTICATION, default=HTTP_BASIC_AUTHENTICATION):
    vol.In([HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION]),
    vol.Optional(CONF_SSL, default=False):
    cv.boolean,
    vol.Optional(CONF_VERIFY_SSL, default=True):
    cv.boolean,
    vol.Optional(CONF_FRAMERATE, default=2):
    cv.positive_int,
    vol.Optional(CONF_SECURITY_LEVEL, default=DEFAULT_SECURITY_LEVEL):
    cv.string,
    vol.Optional(CONF_STREAM_PATH, default=DEFAULT_STREAM_SOURCE):
    cv.string,
})


def setup_platform(opp, config, add_entities, discovery_info=None):
    """Set up a Vivotek IP Camera."""
    creds = f"{config[CONF_USERNAME]}:{config[CONF_PASSWORD]}"
Exemplo n.º 14
0
CONF_BUFFER_SIZE = "buffer"
CONF_IMAGE_FIELD = "field"

DEFAULT_NAME = "Push Camera"

ATTR_FILENAME = "filename"
ATTR_LAST_TRIP = "last_trip"

PUSH_CAMERA_DATA = "push_camera"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
        vol.Optional(CONF_BUFFER_SIZE, default=1): cv.positive_int,
        vol.Optional(CONF_TIMEOUT, default=timedelta(seconds=5)): vol.All(
            cv.time_period, cv.positive_timedelta
        ),
        vol.Optional(CONF_IMAGE_FIELD, default="image"): cv.string,
        vol.Required(CONF_WEBHOOK_ID): cv.string,
    }
)


async def async_setup_platform(opp, config, async_add_entities, discovery_info=None):
    """Set up the Push Camera platform."""
    if PUSH_CAMERA_DATA not in opp.data:
        opp.data[PUSH_CAMERA_DATA] = {}

    webhook_id = config.get(CONF_WEBHOOK_ID)

    cameras = [
Exemplo n.º 15
0
    DEFAULT_CAMERA_USERNAME,
    DEFAULT_FFMPEG_ARGUMENTS,
    DEFAULT_RTSP_PORT,
    DOMAIN,
    MANUFACTURER,
)

CAMERA_SCHEMA = vol.Schema({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_CAMERAS, default={}): {
        cv.string: CAMERA_SCHEMA
    },
})

_LOGGER = logging.getLogger(__name__)

MIN_TIME_BETWEEN_SESSION_RENEW = timedelta(seconds=90)


async def async_setup_platform(opp,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up a Ezviz IP Camera from platform config."""
    _LOGGER.warning(
Exemplo n.º 16
0
from . import DOMAIN as SKYBELL_DOMAIN, SkybellDevice

_LOGGER = logging.getLogger(__name__)

SCAN_INTERVAL = timedelta(seconds=90)

IMAGE_AVATAR = "avatar"
IMAGE_ACTIVITY = "activity"

CONF_ACTIVITY_NAME = "activity_name"
CONF_AVATAR_NAME = "avatar_name"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_MONITORED_CONDITIONS, default=[IMAGE_AVATAR]):
    vol.All(cv.ensure_list, [vol.In([IMAGE_AVATAR, IMAGE_ACTIVITY])]),
    vol.Optional(CONF_ACTIVITY_NAME):
    cv.string,
    vol.Optional(CONF_AVATAR_NAME):
    cv.string,
})


def setup_platform(opp, config, add_entities, discovery_info=None):
    """Set up the platform for a Skybell device."""
    cond = config[CONF_MONITORED_CONDITIONS]
    names = {}
    names[IMAGE_ACTIVITY] = config.get(CONF_ACTIVITY_NAME)
    names[IMAGE_AVATAR] = config.get(CONF_AVATAR_NAME)
    skybell = opp.data.get(SKYBELL_DOMAIN)

    sensors = []
    for device in skybell.get_devices():
Exemplo n.º 17
0
DEFAULT_BRAND = "YI Home Camera"
DEFAULT_PASSWORD = ""
DEFAULT_PATH = "/tmp/sd/record"  # nosec
DEFAULT_PORT = 21
DEFAULT_USERNAME = "******"
DEFAULT_ARGUMENTS = "-pred 1"

CONF_FFMPEG_ARGUMENTS = "ffmpeg_arguments"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_NAME): cv.string,
        vol.Required(CONF_HOST): cv.string,
        vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
        vol.Optional(CONF_PATH, default=DEFAULT_PATH): cv.string,
        vol.Optional(CONF_USERNAME, default=DEFAULT_USERNAME): cv.string,
        vol.Required(CONF_PASSWORD): cv.string,
        vol.Optional(CONF_FFMPEG_ARGUMENTS, default=DEFAULT_ARGUMENTS): cv.string,
    }
)


async def async_setup_platform(opp, config, async_add_entities, discovery_info=None):
    """Set up a Yi Camera."""
    async_add_entities([YiCamera(opp, config)], True)


class YiCamera(Camera):
    """Define an implementation of a Yi Camera."""
Exemplo n.º 18
0
import voluptuous as vol

from openpeerpower.components.camera import PLATFORM_SCHEMA, SUPPORT_STREAM, Camera
from openpeerpower.const import CONF_NAME
from openpeerpower.helpers.aiohttp_client import async_aiohttp_proxy_stream
import openpeerpower.helpers.config_validation as cv

from . import CONF_EXTRA_ARGUMENTS, CONF_INPUT, DATA_FFMPEG, async_get_image

DEFAULT_NAME = "FFmpeg"
DEFAULT_ARGUMENTS = "-pred 1"

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


async def async_setup_platform(opp,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up a FFmpeg camera."""
    async_add_entities([FFmpegCamera(opp, config)])


class FFmpegCamera(Camera):
    """An implementation of an FFmpeg camera."""
Exemplo n.º 19
0
import mimetypes
import os

import voluptuous as vol

from openpeerpower.components.camera import PLATFORM_SCHEMA, Camera
from openpeerpower.const import ATTR_ENTITY_ID, CONF_FILE_PATH, CONF_NAME
from openpeerpower.helpers import config_validation as cv

from .const import DATA_LOCAL_FILE, DEFAULT_NAME, DOMAIN, SERVICE_UPDATE_FILE_PATH

_LOGGER = logging.getLogger(__name__)

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

CAMERA_SERVICE_UPDATE_FILE_PATH = vol.Schema({
    vol.Optional(ATTR_ENTITY_ID):
    cv.comp_entity_ids,
    vol.Required(CONF_FILE_PATH):
    cv.string,
})


def setup_platform(opp, config, add_entities, discovery_info=None):
    """Set up the Camera that works with local files."""
    if DATA_LOCAL_FILE not in opp.data:
        opp.data[DATA_LOCAL_FILE] = []