{ DOMAIN: vol.Schema({ vol.Required(CONF_CLIENT_ID): cv.string, vol.Required(CONF_CLIENT_SECRET): cv.string, vol.Required(CONF_API_KEY): cv.string, vol.Required(CONF_REDIRECT_URI): cv.string, vol.Optional(CONF_SENSORS, default={}): SENSOR_SCHEMA, }) }, extra=vol.ALLOW_EXTRA, ) LOGI_CIRCLE_SERVICE_SET_CONFIG = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(ATTR_MODE): vol.In([LED_MODE_KEY, RECORDING_MODE_KEY]), vol.Required(ATTR_VALUE): cv.boolean, }) LOGI_CIRCLE_SERVICE_SNAPSHOT = CAMERA_SERVICE_SCHEMA.extend( {vol.Required(ATTR_FILENAME): cv.template}) LOGI_CIRCLE_SERVICE_RECORD = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(ATTR_FILENAME): cv.template, vol.Required(ATTR_DURATION): cv.positive_int, }) async def async_setup(hass, config):
_ZOOM_ACTIONS = ["ZoomWide", "ZoomTele"] _MOVE_1_ACTIONS = ["Right", "Left", "Up", "Down"] _MOVE_2_ACTIONS = ["RightDown", "RightUp", "LeftDown", "LeftUp"] _ACTION = _ZOOM_ACTIONS + _MOVE_1_ACTIONS + _MOVE_2_ACTIONS _DEFAULT_TT = 0.2 _ATTR_PRESET = "preset" _ATTR_COLOR_BW = "color_bw" _CBW_COLOR = "color" _CBW_AUTO = "auto" _CBW_BW = "bw" _CBW = [_CBW_COLOR, _CBW_AUTO, _CBW_BW] _SRV_GOTO_SCHEMA = CAMERA_SERVICE_SCHEMA.extend( {vol.Required(_ATTR_PRESET): vol.All(vol.Coerce(int), vol.Range(min=1))}) _SRV_CBW_SCHEMA = CAMERA_SERVICE_SCHEMA.extend( {vol.Required(_ATTR_COLOR_BW): vol.In(_CBW)}) _SRV_PTZ_SCHEMA = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(_ATTR_PTZ_MOV): vol.In(_MOV), vol.Optional(_ATTR_PTZ_TT, default=_DEFAULT_TT): cv.small_float, }) CAMERA_SERVICES = { _SRV_EN_REC: (CAMERA_SERVICE_SCHEMA, "async_enable_recording", ()), _SRV_DS_REC: (CAMERA_SERVICE_SCHEMA, "async_disable_recording", ()), _SRV_EN_AUD: (CAMERA_SERVICE_SCHEMA, "async_enable_audio", ()), _SRV_DS_AUD: (CAMERA_SERVICE_SCHEMA, "async_disable_audio", ()), _SRV_EN_MOT_REC:
from homeassistant.helpers import config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_FILE_PATH = 'file_path' DEFAULT_NAME = 'Local File' SERVICE_UPDATE_FILE_PATH = 'local_file_update_file_path' 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 = CAMERA_SERVICE_SCHEMA.extend( {vol.Required(CONF_FILE_PATH): cv.string}) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Camera that works with local files.""" file_path = config[CONF_FILE_PATH] camera = LocalFile(config[CONF_NAME], file_path) def update_file_path_service(call): """Update the file path.""" file_path = call.data.get(CONF_FILE_PATH) camera.update_file_path(file_path) return True hass.services.register(DOMAIN, SERVICE_UPDATE_FILE_PATH,
_SRV_DS_MOT_REC = 'disable_motion_recording' _SRV_GOTO = 'goto_preset' _SRV_CBW = 'set_color_bw' _SRV_TOUR_ON = 'start_tour' _SRV_TOUR_OFF = 'stop_tour' _ATTR_PRESET = 'preset' _ATTR_COLOR_BW = 'color_bw' _CBW_COLOR = 'color' _CBW_AUTO = 'auto' _CBW_BW = 'bw' _CBW = [_CBW_COLOR, _CBW_AUTO, _CBW_BW] _SRV_GOTO_SCHEMA = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(_ATTR_PRESET): vol.All(vol.Coerce(int), vol.Range(min=1)), }) _SRV_CBW_SCHEMA = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(_ATTR_COLOR_BW): vol.In(_CBW), }) CAMERA_SERVICES = { _SRV_EN_REC: (CAMERA_SERVICE_SCHEMA, 'async_enable_recording', ()), _SRV_DS_REC: (CAMERA_SERVICE_SCHEMA, 'async_disable_recording', ()), _SRV_EN_AUD: (CAMERA_SERVICE_SCHEMA, 'async_enable_audio', ()), _SRV_DS_AUD: (CAMERA_SERVICE_SCHEMA, 'async_disable_audio', ()), _SRV_EN_MOT_REC: ( CAMERA_SERVICE_SCHEMA, 'async_enable_motion_recording', ()), _SRV_DS_MOT_REC: ( CAMERA_SERVICE_SCHEMA, 'async_disable_motion_recording', ()), _SRV_GOTO: (_SRV_GOTO_SCHEMA, 'async_goto_preset', (_ATTR_PRESET,)),
SERVICE_DISABLE_MOTION_RECORDING = 'amcrest_disable_motion_recording' SERVICE_GOTO_PRESET = 'amcrest_goto_preset' SERVICE_SET_COLOR_BW = 'amcrest_set_color_bw' SERVICE_START_TOUR = 'amcrest_tour_on' SERVICE_STOP_TOUR = 'amcrest_tour_off' ATTR_PRESET = 'preset' ATTR_COLOR_BW = 'color_bw' CBW_COLOR = 'color' CBW_AUTO = 'auto' CBW_BW = 'bw' CBW = [CBW_COLOR, CBW_AUTO, CBW_BW] SERVICE_GOTO_PRESET_SCHEMA = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(ATTR_PRESET): vol.All(vol.Coerce(int), vol.Range(min=1)), }) SERVICE_SET_COLOR_BW_SCHEMA = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(ATTR_COLOR_BW): vol.In(CBW), }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up an Amcrest IP Camera.""" if discovery_info is None: return
cv.matches_regex( r"[0-3][0-9]/[0-1][0-9]/\d{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9]"), vol.Optional(CONF_PARAM_ENDTIME, default=EPOCH_END): cv.matches_regex( r"[0-3][0-9]/[0-1][0-9]/\d{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9]"), vol.Optional(CONF_PARAM_LASTHOURS, default=0.0): cv.positive_float, }) CAMERA_SERVICE_IMAGE_FILELIST = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(CONF_PATH): cv.isdir, vol.Optional(CONF_EXCLUDE, default=[]): cv.ensure_list, vol.Optional(CONF_PARAM_BEGINTIME, default=EPOCH_START): cv.matches_regex( r"[0-3][0-9]/[0-1][0-9]/\d{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9]"), vol.Optional(CONF_PARAM_ENDTIME, default=EPOCH_END): cv.matches_regex( r"[0-3][0-9]/[0-1][0-9]/\d{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9]"), vol.Optional(CONF_PARAM_LASTHOURS, default=0.0): cv.positive_float, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Camera that works with local files.""" if CONF_DATA_LOCAL_FILE not in hass.data: hass.data[CONF_DATA_LOCAL_FILE] = [] path = config[CONF_PATH] delaytime = config[CONF_DELAY_TIME]
_SRV_EN_MOT_REC = "enable_motion_recording" _SRV_DS_MOT_REC = "disable_motion_recording" _SRV_GOTO = "goto_preset" _SRV_CBW = "set_color_bw" _SRV_TOUR_ON = "start_tour" _SRV_TOUR_OFF = "stop_tour" _ATTR_PRESET = "preset" _ATTR_COLOR_BW = "color_bw" _CBW_COLOR = "color" _CBW_AUTO = "auto" _CBW_BW = "bw" _CBW = [_CBW_COLOR, _CBW_AUTO, _CBW_BW] _SRV_GOTO_SCHEMA = CAMERA_SERVICE_SCHEMA.extend( {vol.Required(_ATTR_PRESET): vol.All(vol.Coerce(int), vol.Range(min=1))}) _SRV_CBW_SCHEMA = CAMERA_SERVICE_SCHEMA.extend( {vol.Required(_ATTR_COLOR_BW): vol.In(_CBW)}) CAMERA_SERVICES = { _SRV_EN_REC: (CAMERA_SERVICE_SCHEMA, "async_enable_recording", ()), _SRV_DS_REC: (CAMERA_SERVICE_SCHEMA, "async_disable_recording", ()), _SRV_EN_AUD: (CAMERA_SERVICE_SCHEMA, "async_enable_audio", ()), _SRV_DS_AUD: (CAMERA_SERVICE_SCHEMA, "async_disable_audio", ()), _SRV_EN_MOT_REC: (CAMERA_SERVICE_SCHEMA, "async_enable_motion_recording", ()), _SRV_DS_MOT_REC: (CAMERA_SERVICE_SCHEMA, "async_disable_motion_recording", ()), _SRV_GOTO: (_SRV_GOTO_SCHEMA, "async_goto_preset", (_ATTR_PRESET, )), _SRV_CBW: (_SRV_CBW_SCHEMA, "async_set_color_bw", (_ATTR_COLOR_BW, )), _SRV_TOUR_ON: (CAMERA_SERVICE_SCHEMA, "async_start_tour", ()),
{ DOMAIN: vol.Schema({ vol.Required(CONF_CLIENT_ID): cv.string, vol.Required(CONF_CLIENT_SECRET): cv.string, vol.Required(CONF_API_KEY): cv.string, vol.Required(CONF_REDIRECT_URI): cv.string, vol.Optional(CONF_SENSORS, default={}): SENSOR_SCHEMA }) }, extra=vol.ALLOW_EXTRA, ) LOGI_CIRCLE_SERVICE_SET_CONFIG = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(ATTR_MODE): vol.In([LED_MODE_KEY, RECORDING_MODE_KEY]), vol.Required(ATTR_VALUE): cv.boolean }) LOGI_CIRCLE_SERVICE_SNAPSHOT = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(ATTR_FILENAME): cv.template }) LOGI_CIRCLE_SERVICE_RECORD = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(ATTR_FILENAME): cv.template, vol.Required(ATTR_DURATION): cv.positive_int }) async def async_setup(hass, config): """Set up configured Logi Circle component."""
Camera, CAMERA_SERVICE_SCHEMA, DOMAIN, PLATFORM_SCHEMA) from homeassistant.helpers import config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_FILE_PATH = 'file_path' DEFAULT_NAME = 'Local File' SERVICE_UPDATE_FILE_PATH = 'local_file_update_file_path' 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 = CAMERA_SERVICE_SCHEMA.extend({ vol.Required(CONF_FILE_PATH): cv.string }) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Camera that works with local files.""" file_path = config[CONF_FILE_PATH] camera = LocalFile(config[CONF_NAME], file_path) def update_file_path_service(call): """Update the file path.""" file_path = call.data.get(CONF_FILE_PATH) camera.update_file_path(file_path) return True hass.services.register(
_LOGGER = logging.getLogger(__name__) SCAN_INTERVAL = timedelta(seconds=60) SERVICE_SET_MODE = 'set_mode' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_FFMPEG_ARGUMENTS): cv.string, vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): cv.time_period, }) LOGI_SERVICE_SCHEMA = CAMERA_SERVICE_SCHEMA.extend({ vol.Required('mode'): cv.string, vol.Required('value'): cv.boolean }) async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up a Logi Circle Camera.""" logi = hass.data[DATA_LOGI] cameras = [] for camera in await logi.cameras: cameras.append(LogiCam(hass, camera, config))