def __init__(self, hass, manager, config): """Initialize ffmpeg motion binary sensor.""" from haffmpeg import SensorMotion super().__init__(hass, config) self.ffmpeg = SensorMotion( manager.binary, hass.loop, self._async_callback)
class FFmpegMotion(FFmpegBinarySensor): """A binary sensor which use ffmpeg for noise detection.""" def __init__(self, hass, manager, config): """Initialize ffmpeg motion binary sensor.""" from haffmpeg import SensorMotion super().__init__(hass, config) self.ffmpeg = SensorMotion( manager.binary, hass.loop, self._async_callback) def async_start_ffmpeg(self): """Start a FFmpeg instance. This method must be run in the event loop and returns a coroutine. """ # init config self.ffmpeg.set_options( time_reset=self._config.get(CONF_RESET), time_repeat=self._config.get(CONF_REPEAT_TIME, 0), repeat=self._config.get(CONF_REPEAT, 0), changes=self._config.get(CONF_CHANGES), ) # run return self.ffmpeg.open_sensor( input_source=self._config.get(CONF_INPUT), extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS), ) @property def device_class(self): """Return the class of this sensor, from DEVICE_CLASSES.""" return "motion"
class FFmpegMotion(FFmpegBinarySensor): """A binary sensor which use ffmpeg for noise detection.""" def __init__(self, hass, manager, config): """Initialize ffmpeg motion binary sensor.""" from haffmpeg import SensorMotion super().__init__(hass, config) self.ffmpeg = SensorMotion( manager.binary, hass.loop, self._async_callback) def async_start_ffmpeg(self): """Start a FFmpeg instance. This method must be run in the event loop and returns a coroutine. """ # init config self.ffmpeg.set_options( time_reset=self._config.get(CONF_RESET), time_repeat=self._config.get(CONF_REPEAT_TIME, 0), repeat=self._config.get(CONF_REPEAT, 0), changes=self._config.get(CONF_CHANGES), ) # run return self.ffmpeg.open_sensor( input_source=self._config.get(CONF_INPUT), extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS), ) @property def sensor_class(self): """Return the class of this sensor, from SENSOR_CLASSES.""" return "motion"
def __init__(self, hass, manager, config): """Initialize FFmpeg motion binary sensor.""" from haffmpeg import SensorMotion super().__init__(config) self.ffmpeg = SensorMotion( manager.binary, hass.loop, self._async_callback)
def cli(ffmpeg, source, reset, repeat_time, repeat, changes, extra, wait): """FFMPEG noise detection.""" def callback(state): print("Motion detection is: %s" % str(state)) sensor = SensorMotion(ffmpeg_bin=ffmpeg, callback=callback) sensor.set_options(time_reset=reset, changes=changes, repeat=repeat, time_repeat=repeat_time) sensor.open_sensor(input_source=source, extra_cmd=extra) # wait sleep(wait) sensor.close()
class FFmpegMotion(FFmpegBinarySensor): """A binary sensor which use FFmpeg for noise detection.""" def __init__(self, hass, manager, config): """Initialize FFmpeg motion binary sensor.""" from haffmpeg import SensorMotion super().__init__(config) self.ffmpeg = SensorMotion( manager.binary, hass.loop, self._async_callback) @asyncio.coroutine def _async_start_ffmpeg(self, entity_ids): """Start a FFmpeg instance. This method is a coroutine. """ if entity_ids is not None and self.entity_id not in entity_ids: return # init config self.ffmpeg.set_options( time_reset=self._config.get(CONF_RESET), time_repeat=self._config.get(CONF_REPEAT_TIME, 0), repeat=self._config.get(CONF_REPEAT, 0), changes=self._config.get(CONF_CHANGES), ) # run yield from self.ffmpeg.open_sensor( input_source=self._config.get(CONF_INPUT), extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS), ) @property def device_class(self): """Return the class of this sensor, from DEVICE_CLASSES.""" return 'motion'